From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.bugs Subject: bug#42790: [PATH] 27.1; Add version info into file name "emacs.pdmp" to avoid mismatch pdmp file Date: Sun, 15 Nov 2020 20:03:57 -0500 Message-ID: References: <87ft8unbwe.fsf@igel.home> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32378"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) Cc: schwab@linux-m68k.org, 42790@debbugs.gnu.org To: lin.sun@zoom.us Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 16 02:05:26 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1keSxR-0008HY-TN for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 16 Nov 2020 02:05:26 +0100 Original-Received: from localhost ([::1]:45518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keSxQ-0000Z7-EI for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 15 Nov 2020 20:05:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keSx4-0000Yv-MF for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2020 20:05:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43093) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1keSx4-0000VW-Ci for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2020 20:05:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1keSx4-0005UB-6O for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2020 20:05:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 16 Nov 2020 01:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42790 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed patch Original-Received: via spool by 42790-submit@debbugs.gnu.org id=B42790.160548864821019 (code B ref 42790); Mon, 16 Nov 2020 01:05:02 +0000 Original-Received: (at 42790) by debbugs.gnu.org; 16 Nov 2020 01:04:08 +0000 Original-Received: from localhost ([127.0.0.1]:54639 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1keSwB-0005Sx-Li for submit@debbugs.gnu.org; Sun, 15 Nov 2020 20:04:07 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43076) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1keSw9-0005ST-Hx for 42790@debbugs.gnu.org; Sun, 15 Nov 2020 20:04:06 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:51149) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keSw3-0000Su-EZ; Sun, 15 Nov 2020 20:03:59 -0500 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1keSw1-0008SI-3m; Sun, 15 Nov 2020 20:03:57 -0500 X-Spook: underground Bletchley Park United Nations Magnitude X-Ran: `4=Ly_|:e>:+K4/$&-Rc(#:?6G_9QYAVq9GLrlPv*x~NY=Y2JR`Pm!wGi^1{#HvVPn*4Q+ X-Hue: blue X-Attribution: GM In-Reply-To: (lin sun's message of "Mon, 10 Aug 2020 17:24:48 +0800") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:193399 Archived-At: I have also had problems with configure's transform argument being ignored for the pdmp file, and with the pdmp file not being found. Here is a simple-minded proof-of-concept patch for installing the pdmp file with the fingerprint in the name. It needs cleaning up (compilation warnings; hexbuf stuff is awful; should look for FINGERPRINT.pdmp first, then fall back to less specific names, finishing with emacs.pdmp; etc). Hopefully people who know more about this stuff than me will feel like finishing this off... diff --git a/Makefile.in b/Makefile.in index fbb1891ba7..d1c228c5f3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -309,6 +309,7 @@ TRANSFORM = @program_transform_name@ EMACS_NAME = `echo emacs | sed '$(TRANSFORM)'` EMACS = ${EMACS_NAME}${EXEEXT} EMACSFULL = `echo emacs-${version} | sed '$(TRANSFORM)'`${EXEEXT} +EMACS_PDMP = `./src/emacs${EXEEXT} --fingerprint 2>&1 | sed 's/.* //'`.pdmp # Subdirectories to make recursively. SUBDIR = $(NTDIR) lib lib-src src lisp @@ -495,7 +496,7 @@ install-arch-dep: src install-arch-indep install-etcdoc install-$(NTDIR) ifeq (${ns_self_contained},no) ${INSTALL_PROGRAM} $(INSTALL_STRIP) src/emacs${EXEEXT} "$(DESTDIR)${bindir}/$(EMACSFULL)" ifeq (${DUMPING},pdumper) - ${INSTALL_DATA} src/emacs.pdmp "$(DESTDIR)${libexecdir}/emacs/${version}/${configuration}"/emacs.pdmp + ${INSTALL_DATA} src/emacs.pdmp "$(DESTDIR)${libexecdir}/emacs/${version}/${configuration}"/${EMACS_PDMP} endif -chmod 755 "$(DESTDIR)${bindir}/$(EMACSFULL)" ifndef NO_BIN_LINK diff --git a/src/emacs.c b/src/emacs.c index 172e460769..1743e1cc99 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -117,6 +117,7 @@ extern char etext; #endif #include "pdumper.h" +#include "fingerprint.h" #include "epaths.h" static const char emacs_version[] = PACKAGE_VERSION; @@ -238,6 +239,7 @@ Initialization options:\n\ #ifdef HAVE_PDUMPER "\ --dump-file FILE read dumped state from FILE\n\ +--fingerprint output fingerprint and exit\n\ ", #endif "\ @@ -868,9 +870,15 @@ load_pdump (int argc, char **argv) "emacs.pdmp" so that the Emacs binary still works if the user copies and renames it. */ const char *argv0_base = "emacs"; + enum { hexbuf_size = 2 * sizeof fingerprint }; + char hexbuf[hexbuf_size]; + hexbuf_digest (hexbuf, fingerprint, sizeof fingerprint); + char finger[hexbuf_size]; + strcpy (finger, hexbuf); + finger[sizeof hexbuf] = '\0'; ptrdiff_t needed = (strlen (path_exec) + 1 - + strlen (argv0_base) + + strlen (finger) + strlen (suffix) + 1); if (bufsize < needed) @@ -879,7 +887,7 @@ load_pdump (int argc, char **argv) dump_file = xpalloc (NULL, &bufsize, needed - bufsize, -1, 1); } sprintf (dump_file, "%s%c%s%s", - path_exec, DIRECTORY_SEP, argv0_base, suffix); + path_exec, DIRECTORY_SEP, finger, suffix); result = pdumper_load (dump_file); if (result == PDUMPER_LOAD_FILE_NOT_FOUND) @@ -1129,6 +1137,22 @@ main (int argc, char **argv) exit (0); } +#ifdef HAVE_PDUMPER + if (argmatch (argv, argc, "-fingerprint", "--fingerprint", 4, NULL, &skip_args)) + { + if (initialized) + { + dump_fingerprint ("fingerprint", fingerprint); + exit (0); + } + else + { + fputs ("Not initialized\n", stderr); + exit (1); + } + } +#endif + emacs_wd = emacs_get_current_dir_name (); #ifdef HAVE_PDUMPER if (dumped_with_pdumper_p ()) diff --git a/src/pdumper.c b/src/pdumper.c index b5b4050b93..c8d7378221 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -311,7 +311,7 @@ dump_reloc_set_offset (struct dump_reloc *reloc, dump_off offset) error ("dump relocation out of range"); } -static void +void dump_fingerprint (char const *label, unsigned char const xfingerprint[sizeof fingerprint]) { diff --git a/src/pdumper.h b/src/pdumper.h index c793fb4058..2028b44f81 100644 --- a/src/pdumper.h +++ b/src/pdumper.h @@ -50,6 +50,10 @@ enum { PDUMPER_NO_OBJECT = -1 }; #define PDUMPER_REMEMBER_SCALAR(thing) \ pdumper_remember_scalar (&(thing), sizeof (thing)) +extern void dump_fingerprint (const char *label, + const unsigned char *xfingerprint); + + extern void pdumper_remember_scalar_impl (void *data, ptrdiff_t nbytes); INLINE void