Commit 9994bf17 authored by Paul Eggert's avatar Paul Eggert

Bring back dmpstruct.h

Bring back the dmpstruct.h checking, and use it when
--enable-checking=structs is specified.  The checking can be helpful
to some developers, although it gets in the way of others and is
not needed for ordinary tarball builds.
* src/dmpstruct.awk: Restore this file, with mode 644 not 755.
* configure.ac: New option-arg --enable-checking=structs,
implied by --enable-checking.
(CHECK_STRUCTS): New macro and var.
* src/Makefile.in (CHECK_STRUCTS): New macro.
(dmpstruct_headers, dmpstruct.h, dmpstruct.h):
Restore these macros and rules.
(pdumper.o): Restore this dependency if $(CHECK_STRUCTS) is true.
(mostlyclean): Remove dmpstruct.h.
* src/pdumper.c [CHECK_STRUCTS]: Include dmpstruct.h,
and restore checks against hashes.
parent 0627a8d7
Pipeline #1243 failed with stage
in 50 minutes
......@@ -186,6 +186,7 @@ src/emacs
src/emacs-[0-9]*
src/temacs
src/fingerprint.c
src/dmpstruct.h
src/*.pdmp
# Character-set info.
......
......@@ -537,19 +537,21 @@ fi)
AC_ARG_ENABLE(checking,
[AS_HELP_STRING([--enable-checking@<:@=LIST@:>@],
[enable expensive run-time checks. With LIST,
[enable expensive checks. With LIST,
enable only specific categories of checks.
Categories are: all,yes,no.
Flags are: stringbytes, stringoverrun, stringfreelist,
xmallocoverrun, conslist, glyphs])],
structs, xmallocoverrun, conslist, glyphs])],
[ac_checking_flags="${enableval}"],[])
IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="$IFS,"
CHECK_STRUCTS=false
for check in $ac_checking_flags
do
case $check in
# these set all the flags to specific states
yes) ac_enable_checking=1 ;;
no) ac_enable_checking= ;
CHECK_STRUCTS=false
ac_gc_check_stringbytes= ;
ac_gc_check_string_overrun= ;
ac_gc_check_string_free_list= ;
......@@ -557,6 +559,7 @@ do
ac_gc_check_cons_list= ;
ac_glyphs_debug= ;;
all) ac_enable_checking=1 ;
CHECK_STRUCTS=true
ac_gc_check_stringbytes=1 ;
ac_gc_check_string_overrun=1 ;
ac_gc_check_string_free_list=1 ;
......@@ -567,6 +570,7 @@ do
stringbytes) ac_gc_check_stringbytes=1 ;;
stringoverrun) ac_gc_check_string_overrun=1 ;;
stringfreelist) ac_gc_check_string_free_list=1 ;;
structs) CHECK_STRUCTS=true ;;
xmallocoverrun) ac_xmalloc_overrun=1 ;;
conslist) ac_gc_check_cons_list=1 ;;
glyphs) ac_glyphs_debug=1 ;;
......@@ -579,6 +583,15 @@ if test x$ac_enable_checking != x ; then
AC_DEFINE(ENABLE_CHECKING, 1,
[Define to 1 if expensive run-time data type and consistency checks are enabled.])
fi
if $CHECK_STRUCTS; then
AC_DEFINE([CHECK_STRUCTS], 1,
[Define this to check whether someone updated the portable dumper
code after changing the layout of a structure that it uses.
If you change one of these structures, check that the pdumper.c
code is still valid, and update the pertinent hash in pdumper.c
by manually copying the hash from the newly-generated dmpstruct.h.])
fi
AC_SUBST([CHECK_STRUCTS])
if test x$ac_gc_check_stringbytes != x ; then
AC_DEFINE(GC_CHECK_STRING_BYTES, 1,
[Define this temporarily to hunt a bug. If defined, the size of
......
......@@ -84,6 +84,11 @@ 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.
+++
** The new configure option '--enable-checking=structs' attempts to
check that the portable dumper code has been updated to match the last
change to one of the data structures that it relies on.
* Startup Changes in Emacs 27.1
......
......@@ -331,6 +331,7 @@ BUILD_DETAILS = @BUILD_DETAILS@
UNEXEC_OBJ = @UNEXEC_OBJ@
DUMPING=@DUMPING@
CHECK_STRUCTS = @CHECK_STRUCTS@
# 'make' verbosity.
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
......@@ -456,6 +457,16 @@ ALLOBJS = $(FIRSTFILE_OBJ) $(VMLIMIT_OBJ) $(obj) $(otherobj)
all: emacs$(EXEEXT) $(pdmp) $(OTHER_FILES)
.PHONY: all
dmpstruct_headers=$(srcdir)/lisp.h $(srcdir)/buffer.h \
$(srcdir)/intervals.h $(srcdir)/charset.h $(srcdir)/bignum.h
ifeq ($(CHECK_STRUCTS),true)
pdumper.o: dmpstruct.h
endif
dmpstruct.h: $(srcdir)/dmpstruct.awk
dmpstruct.h: $(libsrc)/make-fingerprint$(EXEEXT) $(dmpstruct_headers)
$(AM_V_GEN)POSIXLY_CORRECT=1 awk -f $(srcdir)/dmpstruct.awk \
$(dmpstruct_headers) > $@
AUTO_DEPEND = @AUTO_DEPEND@
DEPDIR = deps
ifeq ($(AUTO_DEPEND),yes)
......@@ -665,7 +676,7 @@ ns-app: emacs$(EXEEXT) $(pdmp)
mostlyclean:
rm -f temacs$(EXEEXT) core ./*.core \#* ./*.o
rm -f fingerprint.c
rm -f dmpstruct.h fingerprint.c
rm -f emacs.pdmp
rm -f ../etc/DOC
rm -f bootstrap-emacs$(EXEEXT) $(bootstrap_pdmp)
......
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
#
# This file is part of GNU Emacs.
#
# GNU Emacs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# GNU Emacs is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
BEGIN {
print "/* Generated by dmpstruct.awk */"
print "#ifndef EMACS_DMPSTRUCT_H"
print "#define EMACS_DMPSTRUCT_H"
struct_name = ""
tmpfile = "dmpstruct.tmp"
}
# Match a type followed by optional syntactic whitespace
/^(enum|struct|union) [a-zA-Z0-9_]+([\t ]|\/\*.*\*\/)*$/ {
struct_name = $2
close (tmpfile)
}
/^(enum|struct|union) [a-zA-Z0-9_]+([\t ]|\/\*.*\*\/)*$/, /^( )?};$/ {
print $0 > tmpfile
}
/^( )?} *(GCALIGNED_STRUCT)? *;$/ {
if (struct_name != "") {
fflush (tmpfile)
cmd = "../lib-src/make-fingerprint -r " tmpfile
cmd | getline hash
close (cmd)
printf "#define HASH_%s_%.10s\n", struct_name, hash
struct_name = ""
}
}
END {
print "#endif /* EMACS_DMPSTRUCT_H */"
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment