From 0fe91bcfe2ba87be40050e214284a995a2a54900 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 12 Oct 2021 10:47:33 +0200 Subject: [PATCH] Change --fingerprint to output to stdout * src/pdumper.c (dump_fingerprint): Add argument OUTPUT, use it instead of stderr, update all uses. Don't print colon if LABEL is empty. * src/pdumper.h (dump_fingerprint): Adjust. * src/emacs.c (main): Print fingerprint to stdout, without label. * Makefile.in (EMACS_PDMP): Adjust. --- Makefile.in | 2 +- src/emacs.c | 5 +++-- src/pdumper.c | 11 ++++++----- src/pdumper.h | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Makefile.in b/Makefile.in index c6c507fd42b..300340c6e82 100644 --- a/Makefile.in +++ b/Makefile.in @@ -313,7 +313,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 +EMACS_PDMP = `./src/emacs${EXEEXT} --fingerprint`.pdmp # Subdirectories to make recursively. SUBDIR = $(NTDIR) lib lib-src src lisp diff --git a/src/emacs.c b/src/emacs.c index cda7a9bf77f..b178c6a06cf 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -933,7 +933,7 @@ load_pdump (int argc, char **argv) copies and renames it. */ hexbuf_size = 2 * sizeof fingerprint; hexbuf = xmalloc (hexbuf_size + 1); - hexbuf_digest (hexbuf, (char *)fingerprint, sizeof fingerprint); + hexbuf_digest (hexbuf, (char *) fingerprint, sizeof fingerprint); hexbuf[hexbuf_size] = '\0'; needed = (strlen (path_exec) + 1 @@ -1403,7 +1403,8 @@ main (int argc, char **argv) { if (initialized) { - dump_fingerprint ("fingerprint", (unsigned char *)fingerprint); + dump_fingerprint (stdout, "", + (unsigned char *) fingerprint); exit (0); } else diff --git a/src/pdumper.c b/src/pdumper.c index 977f4fb2a85..96fbd56a236 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -313,13 +313,14 @@ dump_reloc_set_offset (struct dump_reloc *reloc, dump_off offset) } void -dump_fingerprint (char const *label, +dump_fingerprint (FILE *output, char const *label, unsigned char const xfingerprint[sizeof fingerprint]) { enum { hexbuf_size = 2 * sizeof fingerprint }; char hexbuf[hexbuf_size]; hexbuf_digest (hexbuf, xfingerprint, sizeof fingerprint); - fprintf (stderr, "%s: %.*s\n", label, hexbuf_size, hexbuf); + fprintf (output, "%s%s%.*s\n", label, *label ? ": " : "", + hexbuf_size, hexbuf); } /* To be used if some order in the relocation process has to be enforced. */ @@ -4127,7 +4128,7 @@ types. */) ctx->header.fingerprint[i] = fingerprint[i]; const dump_off header_start = ctx->offset; - dump_fingerprint ("Dumping fingerprint", ctx->header.fingerprint); + dump_fingerprint (stderr, "Dumping fingerprint", ctx->header.fingerprint); dump_write (ctx, &ctx->header, sizeof (ctx->header)); const dump_off header_end = ctx->offset; @@ -5596,8 +5597,8 @@ pdumper_load (const char *dump_filename, char *argv0) desired[i] = fingerprint[i]; if (memcmp (header->fingerprint, desired, sizeof desired) != 0) { - dump_fingerprint ("desired fingerprint", desired); - dump_fingerprint ("found fingerprint", header->fingerprint); + dump_fingerprint (stderr, "desired fingerprint", desired); + dump_fingerprint (stderr, "found fingerprint", header->fingerprint); goto out; } diff --git a/src/pdumper.h b/src/pdumper.h index bc339c42da5..87de592b819 100644 --- a/src/pdumper.h +++ b/src/pdumper.h @@ -50,7 +50,7 @@ enum { PDUMPER_NO_OBJECT = -1 }; #define PDUMPER_REMEMBER_SCALAR(thing) \ pdumper_remember_scalar (&(thing), sizeof (thing)) -extern void dump_fingerprint (const char *label, +extern void dump_fingerprint (FILE *output, const char *label, const unsigned char *xfingerprint); extern void pdumper_remember_scalar_impl (void *data, ptrdiff_t nbytes);