>From 8dd5b6ea56c38669bc98104ee2d6b31496624d28 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 23 Jul 2019 09:19:09 -0700 Subject: [PATCH] Improve pdumper doc; say unexec is deprecated Say that pdumping cannot redump unless -batch is used. Say that the traditional unexec dumping method is by default not available, and is deprecated. Don't call dump files "portable", as dump files are not any more portable than the Emacs executables themselves. Just call them "dump files". Similar, prefer "portable dumper" (since the dumper code is portable) to "portable dumping" (since the dump file is not). Be more systematic about calling them "dump files" instead of "dumped images" or whatnot. --- doc/lispref/internals.texi | 34 ++++++++++++++++++++-------------- etc/NEWS | 14 +++++++++----- etc/TODO | 6 +----- lib/fingerprint.h | 3 +-- lisp/startup.el | 4 ++-- src/alloc.c | 4 ++-- src/emacs.c | 6 +++--- src/minibuf.c | 2 +- src/pdumper.c | 10 +++++----- src/pdumper.h | 4 ++-- src/unexaix.c | 2 +- 11 files changed, 47 insertions(+), 42 deletions(-) diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi index 72066d34f4..f85c266ede 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi @@ -61,10 +61,10 @@ Building Emacs @table @samp @item pdump -@cindex portable dump file -Record the preloaded Lisp data in a @dfn{portable dump} file. This +@cindex dump file +Record the preloaded Lisp data in a @dfn{dump file}. This method produces an additional data file which Emacs will load at -startup. The portable dump file is usually called @file{emacs.pdmp}, +startup. The produced dump file is usually called @file{emacs.pdmp}, and is installed in the Emacs @code{exec-directory} (@pxref{Help Functions}). This method is the most preferred one, as it does not require Emacs to employ any special techniques of memory allocation, @@ -75,7 +75,7 @@ Building Emacs @cindex bootstrapping Emacs Like @samp{pdump}, but used while @dfn{bootstrapping} Emacs, when no previous Emacs binary and no @file{*.elc} byte-compiled Lisp files are -available. The produced portable dump file is usually named +available. The produced dump file is usually named @file{bootstrap-emacs.pdmp} in this case. @item dump @@ -88,6 +88,8 @@ Building Emacs dumped Emacs.) This method is also known as @dfn{unexec}, because it produces a program file from a running process, and thus is in some sense the opposite of executing a program to start a process. +Although this method was the way that Emacs traditionally saved its +state, it is now deprecated. @item bootstrap Like @samp{dump}, but used when bootstrapping Emacs with the @@ -97,11 +99,11 @@ Building Emacs @cindex preloaded Lisp files @vindex preloaded-file-list The dumped @file{emacs} executable (also called a @dfn{pure} Emacs) -is the one which is installed. If the portable dumping was used to +is the one which is installed. If the portable dumper was used to build Emacs, the @file{emacs} executable is actually an exact copy of @file{temacs}, and the corresponding @file{emacs.pdmp} file is installed as well. The variable @code{preloaded-file-list} stores a -list of the preloaded Lisp files recorded in the portable dump file or +list of the preloaded Lisp files recorded in the dump file or in the dumped Emacs executable. If you port Emacs to a new operating system, and are not able to implement dumping of any kind, then Emacs must load @file{loadup.el} each time it starts. @@ -201,15 +203,19 @@ Building Emacs @code{before-init-hook} (@pxref{Startup Summary}). @defun dump-emacs-portable to-file &optional track-referrers -This function dumps the current state of Emacs into a portable dump +This function dumps the current state of Emacs into a dump file @var{to-file}, using the @code{pdump} method. Normally, the -portable dump file is called @file{@var{emacs-name}.dmp}, where +dump file is called @file{@var{emacs-name}.dmp}, where @var{emacs-name} is the name of the Emacs executable file. The optional argument @var{track-referrers}, if non-@code{nil}, causes the -portable dumping process keep additional information to help track +portable dumper to keep additional information to help track down the provenance of object types that are not yet supported by the @code{pdump} method. +Although the portable dumper code can run on many platforms, the dump +files that it produces are not portable---they can be loaded only by +the Emacs executable that dumped them. + If you want to use this function in an Emacs that was already dumped, you must run Emacs with the @samp{-batch} option. @end defun @@ -220,20 +226,20 @@ Building Emacs @var{to-file}, using the @code{unexec} method. It takes symbols from @var{from-file} (this is normally the executable file @file{temacs}). -This function cannot be used in an Emacs that was already dumped. If -Emacs was built without @code{unexec} support, this function will not -be available. +This function cannot be used in an Emacs that was already dumped. +This function is deprecated, and by default Emacs is built without +@code{unexec} support so this function is not available. @end defun @defun pdumper-stats -If the current Emacs session restored its state from a portable dump +If the current Emacs session restored its state from a dump file, this function returns information about the dump file and the time it took to restore the Emacs state. The value is an alist @w{@code{((dumped-with-pdumper . t) (load-time . @var{time}) (dump-file-name . @var{file}))}}, where @var{file} is the name of the dump file, and @var{time} is the time in seconds it took to restore the state from the dump file. -If the current session was not restored from a portable dump file, the +If the current session was not restored from a dump file, the value is nil. @end defun diff --git a/etc/NEWS b/etc/NEWS index 5378e56bca..7fd2214582 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -92,11 +92,6 @@ and in particular better supports the Address Space Layout Randomization (ASLR) feature, a security technique used by most modern operating systems. -Portable dumping can be disabled at configure time via the configure -option '--with-dumping=unexec' (but we don't recommend that, unless -the portable dumping doesn't work on your system for some -reason---please report such systems to the Emacs developers as bugs). - When built with the portable dumping support (which is the default), Emacs looks for the 'emacs.pdmp' file, generated during the build, in its data directory at startup, and loads the dumped state from there. @@ -104,6 +99,15 @@ The new command-line argument '--dump-file=FILE' allows to specify a non-default '.pdmp' file to load the state from; see the node "Initial Options" in the Emacs manual for more information. +An Emacs started via a dump file can create a new dump file only if it +was invoked with the -batch option. + +Although the portable dumper has been tested, it may have a bug on +unusual platforms. If you require traditional unexec dumping you can +use the configure-time option '--with-dumping=unexec'; however, please +file a bug report describing the situation, as unexec dumping is +deprecated. + +++ ** The new configure option '--enable-checking=structs' attempts to check that the portable dumper code has been updated to match the last diff --git a/etc/TODO b/etc/TODO index b2446b0d91..a065763933 100644 --- a/etc/TODO +++ b/etc/TODO @@ -297,11 +297,7 @@ One way of doing this is to start with fx's dynamic loading, and use it to implement things like auto-loaded buffer parsers and database access in cases which need more than Lisp. -** Replace unexec with a more portable form of dumping -See eg https://lists.gnu.org/r/emacs-devel/2014-01/msg01034.html - https://lists.gnu.org/r/emacs-devel/2014-06/msg00452.html - -One way is to provide portable undumping using mmap (per gerd design). +** Fix portable dumping so that you can redump without using -batch. ** Imenu could be extended into a file-structure browsing mechanism using code like that of customize-groups. diff --git a/lib/fingerprint.h b/lib/fingerprint.h index ba2e740cd9..7d2160c988 100644 --- a/lib/fingerprint.h +++ b/lib/fingerprint.h @@ -22,8 +22,7 @@ along with GNU Emacs. If not, see . */ /* We generate fingerprint.c and fingerprint.o from all the sources in Emacs. This way, we have a unique value that we can use to pair - data files (like a portable dump image) with a specific build of - Emacs. */ + data files (like a dump file) with a specific build of Emacs. */ extern volatile unsigned char fingerprint[32]; #endif diff --git a/lisp/startup.el b/lisp/startup.el index 7759ed5aed..564428580b 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -354,8 +354,8 @@ site-run-file "File containing site-wide run-time initializations. This file is loaded at run-time before `~/.emacs'. It contains inits that need to be in place for the entire site, but which, due to their -higher incidence of change, don't make sense to load into Emacs's -dumped image. Thus, the run-time load order is: 1. file described in +higher incidence of change, don't make sense to put into Emacs's +dump file. Thus, the run-time load order is: 1. file described in this variable, if non-nil; 2. `~/.emacs'; 3. `default.el'. Don't use the `site-start.el' file for things some users may not like. diff --git a/src/alloc.c b/src/alloc.c index 5d8003ffb5..f256ff71b0 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -4531,9 +4531,9 @@ mark_maybe_object (Lisp_Object obj) void *po = XPNTR (obj); - /* If the pointer is in the dumped image and the dump has a record + /* If the pointer is in the dump image and the dump has a record of the object starting at the place where the pointer points, we - definitely have an object. If the pointer is in the dumped image + definitely have an object. If the pointer is in the dump image and the dump has no idea what the pointer is pointing at, we definitely _don't_ have an object. */ if (pdumper_object_p (po)) diff --git a/src/emacs.c b/src/emacs.c index ad661a081b..cc5818393a 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -686,7 +686,7 @@ dump_error_to_string (enum pdumper_load_result result) } /* Find a path (absolute or relative) to the Emacs executable. - Called early in initialization by portable dump loading code, so we + Called early in initialization by portable dumper loading code, so we can't use lisp and associated machinery. On success, *EXENAME is set to a heap-allocated string giving a path to the Emacs executable or to NULL if we can't determine the path immediately. @@ -801,12 +801,12 @@ load_pdump (int argc, char **argv) ; /* TODO: maybe more thoroughly scrub process environment in order to - make this use case (loading a pdumper image in an unexeced emacs) + make this use case (loading a dump file in an unexeced emacs) possible? Right now, we assume that things we don't touch are zero-initialized, and in an unexeced Emacs, this assumption doesn't hold. */ if (initialized) - fatal ("cannot load pdumper image in unexeced Emacs"); + fatal ("cannot load dump file in unexeced Emacs"); /* Look for an explicitly-specified dump file. */ const char *path_exec = PATH_EXEC; diff --git a/src/minibuf.c b/src/minibuf.c index d9a6e15b05..8920f37827 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -1885,7 +1885,7 @@ init_minibuf_once_for_pdumper (void) PDUMPER_IGNORE (minibuf_prompt_width); /* We run this function on first initialization and whenever we - restore from a pdumper image. pdumper doesn't try to preserve + restore from a dump file. pdumper doesn't try to preserve frames, windows, and so on, so reset everything related here. */ Vminibuffer_list = Qnil; minibuf_level = 0; diff --git a/src/pdumper.c b/src/pdumper.c index cda8b40be4..84147353e8 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -333,8 +333,8 @@ dump_fingerprint (char const *label, fprintf (stderr, "%s: %.*s\n", label, hexbuf_size, hexbuf); } -/* Format of an Emacs portable dump file. All offsets are relative to - the beginning of the file. An Emacs portable dump file is coupled +/* Format of an Emacs dump file. All offsets are relative to + the beginning of the file. An Emacs dump file is coupled to exactly the Emacs binary that produced it, so details of alignment and endianness are unimportant. @@ -3990,7 +3990,7 @@ dump_drain_deferred_symbols (struct dump_context *ctx) DEFUN ("dump-emacs-portable", Fdump_emacs_portable, Sdump_emacs_portable, 1, 2, 0, - doc: /* Dump current state of Emacs into portable dump file FILENAME. + doc: /* Dump current state of Emacs into dump file FILENAME. If TRACK-REFERRERS is non-nil, keep additional debugging information that can help track down the provenance of unsupported object types. */) @@ -5470,14 +5470,14 @@ pdumper_record_wd (const char *wd) DEFUN ("pdumper-stats", Fpdumper_stats, Spdumper_stats, 0, 0, 0, doc: /* Return statistics about portable dumping used by this session. -If this Emacs sesion was started from a portable dump file, +If this Emacs session was started from a dump file, the return value is an alist of the form: ((dumped-with-pdumper . t) (load-time . TIME) (dump-file-name . FILE)) where TIME is the time in seconds it took to restore Emacs state from the dump file, and FILE is the name of the dump file. -Value is nil if this session was not started using a portable dump file.*/) +Value is nil if this session was not started using a dump file.*/) (void) { if (!dumped_with_pdumper_p ()) diff --git a/src/pdumper.h b/src/pdumper.h index ab2f426c1e..5d1e9c3aea 100644 --- a/src/pdumper.h +++ b/src/pdumper.h @@ -35,7 +35,7 @@ INLINE_HEADER_BEGIN variables to which the Lisp heap points. It doesn't know anything about other C variables. The functions below allow code from other parts of Emacs to tell the portable dumper about other bits of - information to preserve in dumped images. + information to preserve in dump files. These memory-records are themselves preserved in the dump, so call the functions below only on the !initialized init path, just @@ -44,7 +44,7 @@ INLINE_HEADER_BEGIN There are no special functions to preserve a global Lisp_Object. You should just staticpro these. */ -/* Remember the value of THING in dumped images. THING must not +/* Remember the value of THING in dump files. THING must not contain any pointers or Lisp_Object variables: these values are not valid across dump and load. */ #define PDUMPER_REMEMBER_SCALAR(thing) \ diff --git a/src/unexaix.c b/src/unexaix.c index 349d365383..c95486cf72 100644 --- a/src/unexaix.c +++ b/src/unexaix.c @@ -1,4 +1,4 @@ -/* Dump an executable image. +/* Dump an executable file. Copyright (C) 1985-1988, 1999, 2001-2019 Free Software Foundation, Inc. -- 2.17.1