From: Paul Eggert Date: Thu, 26 Jul 2012 18:35:50 +0000 (-0700) Subject: Fix export of symbols to GDB. X-Git-Tag: emacs-24.2.90~1069 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5eceb8fb134263b05608532afb33fdf43c1e3713;p=emacs.git Fix export of symbols to GDB. * alloc.c (ARRAY_MARK_FLAG_VAL, PSEUDOVECTOR_FLAG_VAL, VALMASK_VAL) (ARRAY_MARK_FLAG, PSEUDOVECTOR_FLAG, VALMASK): Move these here from emacs.c, as this is a more-suitable home. Had this been done earlier the fix for 1995-05-30T23:07:27Z!kwzh@gnu.org would have avoided some of the problems noted in by Eli Zaretskii, as the scope problems would have been more obvious. * emacs.c (gdb_CHECK_LISP_OBJECT_TYPE, gdb_DATA_SEG_BITS) (gdb_GCTYPEBITS, gdb_USE_LSB_TAG) (CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS, GCTYPEBITS, USE_LSB_TAG): Remove; now done in lisp.h. * lisp.h (PUBLISH_TO_GDB): New macro. (GCTYPEBITS, USE_LSB_TAG, CHECK_LISP_OBJECT_TYPE, enum pvec_type) (DATA_SEG_BITS): Use it. (GCTYPEBITS, USE_LSB_TAG): Now also an enum, for GDB. (CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS): Now just an enum, for GDB. * mem-limits.h (EXCEEDS_LISP_PTR): Redo so that DATA_SEG_BITS need not be usable in #if. This simplifies things. --- diff --git a/src/ChangeLog b/src/ChangeLog index b4e5fe84879..06633ba7165 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,24 @@ +2012-07-26 Paul Eggert + + Fix export of symbols to GDB (Bug#12036). + * alloc.c (ARRAY_MARK_FLAG_VAL, PSEUDOVECTOR_FLAG_VAL, VALMASK_VAL) + (ARRAY_MARK_FLAG, PSEUDOVECTOR_FLAG, VALMASK): Move these here from + emacs.c, as this is a more-suitable home. Had this been done earlier + the fix for 12036 would have avoided some of the problems noted in + by Eli Zaretskii, as the scope problems + would have been more obvious. + * emacs.c (gdb_CHECK_LISP_OBJECT_TYPE, gdb_DATA_SEG_BITS) + (gdb_GCTYPEBITS, gdb_USE_LSB_TAG) + (CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS, GCTYPEBITS, USE_LSB_TAG): + Remove; now done in lisp.h. + * lisp.h (PUBLISH_TO_GDB): New macro. + (GCTYPEBITS, USE_LSB_TAG, CHECK_LISP_OBJECT_TYPE, enum pvec_type) + (DATA_SEG_BITS): Use it. + (GCTYPEBITS, USE_LSB_TAG): Now also an enum, for GDB. + (CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS): Now just an enum, for GDB. + * mem-limits.h (EXCEEDS_LISP_PTR): Redo so that DATA_SEG_BITS need + not be usable in #if. This simplifies things. + 2012-07-26 Juanma Barranquero * makefile.w32-in ($(BLD)/emacs.$(O)): Update dependencies. diff --git a/src/alloc.c b/src/alloc.c index d9c56b5c7c8..ac6cb861c4d 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -6875,3 +6875,29 @@ The time is in seconds as a floating point value. */); defsubr (&Sgc_status); #endif } + +/* Make some symbols visible to GDB. These cannot be done as enums, like + GCTYPEBITS or USE_LSB_TAG, since values might not be in 'int' range. + Each symbol X has a corresponding X_VAL symbol, verified to have + the correct value. + + This is last, so that the #undef lines don't mess up later code. */ + +#define ARRAY_MARK_FLAG_VAL PTRDIFF_MIN +#define PSEUDOVECTOR_FLAG_VAL (PTRDIFF_MAX - PTRDIFF_MAX / 2) +#define VALMASK_VAL (USE_LSB_TAG ? -1 << GCTYPEBITS : VAL_MAX) + +verify (ARRAY_MARK_FLAG_VAL == ARRAY_MARK_FLAG); +verify (PSEUDOVECTOR_FLAG_VAL == PSEUDOVECTOR_FLAG); +verify (VALMASK_VAL == VALMASK); + +#undef ARRAY_MARK_FLAG +#undef PSEUDOVECTOR_FLAG +#undef VALMASK + +ptrdiff_t const EXTERNALLY_VISIBLE + ARRAY_MARK_FLAG = ARRAY_MARK_FLAG_VAL, + PSEUDOVECTOR_FLAG = PSEUDOVECTOR_FLAG_VAL; + +EMACS_INT const EXTERNALLY_VISIBLE + VALMASK = VALMASK_VAL; diff --git a/src/emacs.c b/src/emacs.c index c737a41974f..7dad87ef38b 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2490,50 +2490,3 @@ libraries; only those already known by Emacs will be loaded. */); /* Make sure IS_DAEMON starts up as false. */ daemon_pipe[1] = 0; } - -/* Make these values available in GDB, which doesn't see macros. - This is last, so that the #undef lines don't mess up later code. */ - -enum - { - gdb_CHECK_LISP_OBJECT_TYPE = CHECK_LISP_OBJECT_TYPE, - gdb_DATA_SEG_BITS = DATA_SEG_BITS, - gdb_GCTYPEBITS = GCTYPEBITS, - gdb_USE_LSB_TAG = USE_LSB_TAG - }; - -#undef CHECK_LISP_OBJECT_TYPE -#undef DATA_SEG_BITS -#undef GCTYPEBITS -#undef USE_LSB_TAG - -enum - { - CHECK_LISP_OBJECT_TYPE = gdb_CHECK_LISP_OBJECT_TYPE, - DATA_SEG_BITS = gdb_DATA_SEG_BITS, - GCTYPEBITS = gdb_GCTYPEBITS, - USE_LSB_TAG = gdb_USE_LSB_TAG - }; - -/* These are trickier since they might fall out of int range. Each - symbol X has a corresponding X_VAL symbol, verified to have the - correct value. */ - -#define ARRAY_MARK_FLAG_VAL PTRDIFF_MIN -#define PSEUDOVECTOR_FLAG_VAL (PTRDIFF_MAX - PTRDIFF_MAX / 2) -#define VALMASK_VAL (USE_LSB_TAG ? -1 << GCTYPEBITS : VAL_MAX) - -verify (ARRAY_MARK_FLAG_VAL == ARRAY_MARK_FLAG); -verify (PSEUDOVECTOR_FLAG_VAL == PSEUDOVECTOR_FLAG); -verify (VALMASK_VAL == VALMASK); - -#undef ARRAY_MARK_FLAG -#undef PSEUDOVECTOR_FLAG -#undef VALMASK - -ptrdiff_t const EXTERNALLY_VISIBLE - ARRAY_MARK_FLAG = ARRAY_MARK_FLAG_VAL, - PSEUDOVECTOR_FLAG = PSEUDOVECTOR_FLAG_VAL; - -EMACS_INT const EXTERNALLY_VISIBLE - VALMASK = VALMASK_VAL; diff --git a/src/lisp.h b/src/lisp.h index 8f309617e69..f845ea6bd12 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -64,6 +64,12 @@ typedef unsigned int EMACS_UINT; # endif #endif +/* If an enum type is not used, the enum symbols are not put into the + executable so the debugger cannot see them on many systems, e.g., + GCC 4.7.1 + GDB 7.4.1 + GNU/Linux. Work around this problem by + explicitly using the names in the integer constant expression EXPR. */ +#define PUBLISH_TO_GDB(expr) extern int (*gdb_dummy (int))[(expr) || 1] + /* Number of bits in some machine integer types. */ enum { @@ -155,7 +161,10 @@ extern int suppress_checking EXTERNALLY_VISIBLE; variable VAR of type TYPE with the added requirement that it be TYPEBITS-aligned. */ -/* Number of bits in a Lisp_Object tag. This can be used in #if. */ +/* Number of bits in a Lisp_Object tag. This can be used in #if, + and for GDB's sake also as a regular symbol. */ +enum { GCTYPEBITS = 3 }; +PUBLISH_TO_GDB (GCTYPEBITS); #define GCTYPEBITS 3 /* Number of bits in a Lisp_Object value, not counting the tag. */ @@ -202,7 +211,16 @@ enum { VALBITS = BITS_PER_EMACS_INT - GCTYPEBITS }; # endif # endif #endif -#ifndef USE_LSB_TAG +/* USE_LSB_TAG can be used in #if; default it to 0 and make it visible + to GDB. */ +#ifdef USE_LSB_TAG +# undef USE_LSB_TAG +enum { USE_LSB_TAG = 1 }; +PUBLISH_TO_GDB (USE_LSB_TAG); +# define USE_LSB_TAG 1 +#else +enum { USE_LSB_TAG = 0 }; +PUBLISH_TO_GDB (USE_LSB_TAG); # define USE_LSB_TAG 0 #endif @@ -317,6 +335,8 @@ LISP_MAKE_RVALUE (Lisp_Object o) } #define LISP_INITIALLY_ZERO {0} +#undef CHECK_LISP_OBJECT_TYPE +enum { CHECK_LISP_OBJECT_TYPE = 1 }; #else /* CHECK_LISP_OBJECT_TYPE */ @@ -327,8 +347,9 @@ typedef EMACS_INT Lisp_Object; #define XIL(i) (i) #define LISP_MAKE_RVALUE(o) (0+(o)) #define LISP_INITIALLY_ZERO 0 -#define CHECK_LISP_OBJECT_TYPE 0 +enum { CHECK_LISP_OBJECT_TYPE = 0 }; #endif /* CHECK_LISP_OBJECT_TYPE */ +PUBLISH_TO_GDB (CHECK_LISP_OBJECT_TYPE); /* In the size word of a vector, this bit means the vector has been marked. */ @@ -368,6 +389,7 @@ enum pvec_type PVEC_SUB_CHAR_TABLE = 0x30, PVEC_FONT = 0x40 }; +PUBLISH_TO_GDB ((enum pvec_type) 0); /* This also publishes PVEC_*. */ /* For convenience, we also store the number of elements in these bits. Note that this size is not necessarily the memory-footprint size, but @@ -386,10 +408,16 @@ enum enum { BOOL_VECTOR_BITS_PER_CHAR = 8 }; /* DATA_SEG_BITS forces extra bits to be or'd in with any pointers - which were stored in a Lisp_Object */ -#ifndef DATA_SEG_BITS -# define DATA_SEG_BITS 0 + which were stored in a Lisp_Object. It is not needed in #if, so + for GDB's sake change it from a macro to a regular symbol. */ +#ifdef DATA_SEG_BITS +enum { gdb_DATA_SEG_BITS = DATA_SEG_BITS }; +# undef DATA_SEG_BITS +enum { DATA_SEG_BITS = gdb_DATA_SEG_BITS }; +#else +enum { DATA_SEG_BITS = 0 }; #endif +PUBLISH_TO_GDB (DATA_SEG_BITS); /* These macros extract various sorts of values from a Lisp_Object. For example, if tem is a Lisp_Object whose type is Lisp_Cons, diff --git a/src/mem-limits.h b/src/mem-limits.h index 0376f407217..57a0ca6fefd 100644 --- a/src/mem-limits.h +++ b/src/mem-limits.h @@ -36,9 +36,7 @@ extern int etext; extern char *start_of_data (void) ATTRIBUTE_CONST; #if USE_LSB_TAG || UINTPTR_MAX <= VAL_MAX #define EXCEEDS_LISP_PTR(ptr) 0 -#elif DATA_SEG_BITS +#else #define EXCEEDS_LISP_PTR(ptr) \ (((uintptr_t) (ptr) & ~DATA_SEG_BITS) >> VALBITS) -#else -#define EXCEEDS_LISP_PTR(ptr) ((uintptr_t) (ptr) >> VALBITS) #endif