aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2012-07-26 11:35:50 -0700
committerPaul Eggert2012-07-26 11:35:50 -0700
commit5eceb8fb134263b05608532afb33fdf43c1e3713 (patch)
tree45086aac676975ccd028122a2379095e1c885173 /src
parentf8b91036c9ce5e524ca3d21badee83a3c6794941 (diff)
downloademacs-5eceb8fb134263b05608532afb33fdf43c1e3713.tar.gz
emacs-5eceb8fb134263b05608532afb33fdf43c1e3713.zip
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 <http://bugs.gnu.org/1995-05-30T23:07:27Z!kwzh@gnu.org#13> 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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog21
-rw-r--r--src/alloc.c26
-rw-r--r--src/emacs.c47
-rw-r--r--src/lisp.h40
-rw-r--r--src/mem-limits.h4
5 files changed, 82 insertions, 56 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b4e5fe84879..06633ba7165 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,24 @@
12012-07-26 Paul Eggert <eggert@cs.ucla.edu>
2
3 Fix export of symbols to GDB (Bug#12036).
4 * alloc.c (ARRAY_MARK_FLAG_VAL, PSEUDOVECTOR_FLAG_VAL, VALMASK_VAL)
5 (ARRAY_MARK_FLAG, PSEUDOVECTOR_FLAG, VALMASK): Move these here from
6 emacs.c, as this is a more-suitable home. Had this been done earlier
7 the fix for 12036 would have avoided some of the problems noted in
8 <http://bugs.gnu.org/12036#13> by Eli Zaretskii, as the scope problems
9 would have been more obvious.
10 * emacs.c (gdb_CHECK_LISP_OBJECT_TYPE, gdb_DATA_SEG_BITS)
11 (gdb_GCTYPEBITS, gdb_USE_LSB_TAG)
12 (CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS, GCTYPEBITS, USE_LSB_TAG):
13 Remove; now done in lisp.h.
14 * lisp.h (PUBLISH_TO_GDB): New macro.
15 (GCTYPEBITS, USE_LSB_TAG, CHECK_LISP_OBJECT_TYPE, enum pvec_type)
16 (DATA_SEG_BITS): Use it.
17 (GCTYPEBITS, USE_LSB_TAG): Now also an enum, for GDB.
18 (CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS): Now just an enum, for GDB.
19 * mem-limits.h (EXCEEDS_LISP_PTR): Redo so that DATA_SEG_BITS need
20 not be usable in #if. This simplifies things.
21
12012-07-26 Juanma Barranquero <lekktu@gmail.com> 222012-07-26 Juanma Barranquero <lekktu@gmail.com>
2 23
3 * makefile.w32-in ($(BLD)/emacs.$(O)): Update dependencies. 24 * 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. */);
6875 defsubr (&Sgc_status); 6875 defsubr (&Sgc_status);
6876#endif 6876#endif
6877} 6877}
6878
6879/* Make some symbols visible to GDB. These cannot be done as enums, like
6880 GCTYPEBITS or USE_LSB_TAG, since values might not be in 'int' range.
6881 Each symbol X has a corresponding X_VAL symbol, verified to have
6882 the correct value.
6883
6884 This is last, so that the #undef lines don't mess up later code. */
6885
6886#define ARRAY_MARK_FLAG_VAL PTRDIFF_MIN
6887#define PSEUDOVECTOR_FLAG_VAL (PTRDIFF_MAX - PTRDIFF_MAX / 2)
6888#define VALMASK_VAL (USE_LSB_TAG ? -1 << GCTYPEBITS : VAL_MAX)
6889
6890verify (ARRAY_MARK_FLAG_VAL == ARRAY_MARK_FLAG);
6891verify (PSEUDOVECTOR_FLAG_VAL == PSEUDOVECTOR_FLAG);
6892verify (VALMASK_VAL == VALMASK);
6893
6894#undef ARRAY_MARK_FLAG
6895#undef PSEUDOVECTOR_FLAG
6896#undef VALMASK
6897
6898ptrdiff_t const EXTERNALLY_VISIBLE
6899 ARRAY_MARK_FLAG = ARRAY_MARK_FLAG_VAL,
6900 PSEUDOVECTOR_FLAG = PSEUDOVECTOR_FLAG_VAL;
6901
6902EMACS_INT const EXTERNALLY_VISIBLE
6903 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. */);
2490 /* Make sure IS_DAEMON starts up as false. */ 2490 /* Make sure IS_DAEMON starts up as false. */
2491 daemon_pipe[1] = 0; 2491 daemon_pipe[1] = 0;
2492} 2492}
2493
2494/* Make these values available in GDB, which doesn't see macros.
2495 This is last, so that the #undef lines don't mess up later code. */
2496
2497enum
2498 {
2499 gdb_CHECK_LISP_OBJECT_TYPE = CHECK_LISP_OBJECT_TYPE,
2500 gdb_DATA_SEG_BITS = DATA_SEG_BITS,
2501 gdb_GCTYPEBITS = GCTYPEBITS,
2502 gdb_USE_LSB_TAG = USE_LSB_TAG
2503 };
2504
2505#undef CHECK_LISP_OBJECT_TYPE
2506#undef DATA_SEG_BITS
2507#undef GCTYPEBITS
2508#undef USE_LSB_TAG
2509
2510enum
2511 {
2512 CHECK_LISP_OBJECT_TYPE = gdb_CHECK_LISP_OBJECT_TYPE,
2513 DATA_SEG_BITS = gdb_DATA_SEG_BITS,
2514 GCTYPEBITS = gdb_GCTYPEBITS,
2515 USE_LSB_TAG = gdb_USE_LSB_TAG
2516 };
2517
2518/* These are trickier since they might fall out of int range. Each
2519 symbol X has a corresponding X_VAL symbol, verified to have the
2520 correct value. */
2521
2522#define ARRAY_MARK_FLAG_VAL PTRDIFF_MIN
2523#define PSEUDOVECTOR_FLAG_VAL (PTRDIFF_MAX - PTRDIFF_MAX / 2)
2524#define VALMASK_VAL (USE_LSB_TAG ? -1 << GCTYPEBITS : VAL_MAX)
2525
2526verify (ARRAY_MARK_FLAG_VAL == ARRAY_MARK_FLAG);
2527verify (PSEUDOVECTOR_FLAG_VAL == PSEUDOVECTOR_FLAG);
2528verify (VALMASK_VAL == VALMASK);
2529
2530#undef ARRAY_MARK_FLAG
2531#undef PSEUDOVECTOR_FLAG
2532#undef VALMASK
2533
2534ptrdiff_t const EXTERNALLY_VISIBLE
2535 ARRAY_MARK_FLAG = ARRAY_MARK_FLAG_VAL,
2536 PSEUDOVECTOR_FLAG = PSEUDOVECTOR_FLAG_VAL;
2537
2538EMACS_INT const EXTERNALLY_VISIBLE
2539 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;
64# endif 64# endif
65#endif 65#endif
66 66
67/* If an enum type is not used, the enum symbols are not put into the
68 executable so the debugger cannot see them on many systems, e.g.,
69 GCC 4.7.1 + GDB 7.4.1 + GNU/Linux. Work around this problem by
70 explicitly using the names in the integer constant expression EXPR. */
71#define PUBLISH_TO_GDB(expr) extern int (*gdb_dummy (int))[(expr) || 1]
72
67/* Number of bits in some machine integer types. */ 73/* Number of bits in some machine integer types. */
68enum 74enum
69 { 75 {
@@ -155,7 +161,10 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
155 variable VAR of type TYPE with the added requirement that it be 161 variable VAR of type TYPE with the added requirement that it be
156 TYPEBITS-aligned. */ 162 TYPEBITS-aligned. */
157 163
158/* Number of bits in a Lisp_Object tag. This can be used in #if. */ 164/* Number of bits in a Lisp_Object tag. This can be used in #if,
165 and for GDB's sake also as a regular symbol. */
166enum { GCTYPEBITS = 3 };
167PUBLISH_TO_GDB (GCTYPEBITS);
159#define GCTYPEBITS 3 168#define GCTYPEBITS 3
160 169
161/* Number of bits in a Lisp_Object value, not counting the tag. */ 170/* Number of bits in a Lisp_Object value, not counting the tag. */
@@ -202,7 +211,16 @@ enum { VALBITS = BITS_PER_EMACS_INT - GCTYPEBITS };
202# endif 211# endif
203# endif 212# endif
204#endif 213#endif
205#ifndef USE_LSB_TAG 214/* USE_LSB_TAG can be used in #if; default it to 0 and make it visible
215 to GDB. */
216#ifdef USE_LSB_TAG
217# undef USE_LSB_TAG
218enum { USE_LSB_TAG = 1 };
219PUBLISH_TO_GDB (USE_LSB_TAG);
220# define USE_LSB_TAG 1
221#else
222enum { USE_LSB_TAG = 0 };
223PUBLISH_TO_GDB (USE_LSB_TAG);
206# define USE_LSB_TAG 0 224# define USE_LSB_TAG 0
207#endif 225#endif
208 226
@@ -317,6 +335,8 @@ LISP_MAKE_RVALUE (Lisp_Object o)
317} 335}
318 336
319#define LISP_INITIALLY_ZERO {0} 337#define LISP_INITIALLY_ZERO {0}
338#undef CHECK_LISP_OBJECT_TYPE
339enum { CHECK_LISP_OBJECT_TYPE = 1 };
320 340
321#else /* CHECK_LISP_OBJECT_TYPE */ 341#else /* CHECK_LISP_OBJECT_TYPE */
322 342
@@ -327,8 +347,9 @@ typedef EMACS_INT Lisp_Object;
327#define XIL(i) (i) 347#define XIL(i) (i)
328#define LISP_MAKE_RVALUE(o) (0+(o)) 348#define LISP_MAKE_RVALUE(o) (0+(o))
329#define LISP_INITIALLY_ZERO 0 349#define LISP_INITIALLY_ZERO 0
330#define CHECK_LISP_OBJECT_TYPE 0 350enum { CHECK_LISP_OBJECT_TYPE = 0 };
331#endif /* CHECK_LISP_OBJECT_TYPE */ 351#endif /* CHECK_LISP_OBJECT_TYPE */
352PUBLISH_TO_GDB (CHECK_LISP_OBJECT_TYPE);
332 353
333/* In the size word of a vector, this bit means the vector has been marked. */ 354/* In the size word of a vector, this bit means the vector has been marked. */
334 355
@@ -368,6 +389,7 @@ enum pvec_type
368 PVEC_SUB_CHAR_TABLE = 0x30, 389 PVEC_SUB_CHAR_TABLE = 0x30,
369 PVEC_FONT = 0x40 390 PVEC_FONT = 0x40
370}; 391};
392PUBLISH_TO_GDB ((enum pvec_type) 0); /* This also publishes PVEC_*. */
371 393
372/* For convenience, we also store the number of elements in these bits. 394/* For convenience, we also store the number of elements in these bits.
373 Note that this size is not necessarily the memory-footprint size, but 395 Note that this size is not necessarily the memory-footprint size, but
@@ -386,10 +408,16 @@ enum
386enum { BOOL_VECTOR_BITS_PER_CHAR = 8 }; 408enum { BOOL_VECTOR_BITS_PER_CHAR = 8 };
387 409
388/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers 410/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers
389 which were stored in a Lisp_Object */ 411 which were stored in a Lisp_Object. It is not needed in #if, so
390#ifndef DATA_SEG_BITS 412 for GDB's sake change it from a macro to a regular symbol. */
391# define DATA_SEG_BITS 0 413#ifdef DATA_SEG_BITS
414enum { gdb_DATA_SEG_BITS = DATA_SEG_BITS };
415# undef DATA_SEG_BITS
416enum { DATA_SEG_BITS = gdb_DATA_SEG_BITS };
417#else
418enum { DATA_SEG_BITS = 0 };
392#endif 419#endif
420PUBLISH_TO_GDB (DATA_SEG_BITS);
393 421
394/* These macros extract various sorts of values from a Lisp_Object. 422/* These macros extract various sorts of values from a Lisp_Object.
395 For example, if tem is a Lisp_Object whose type is Lisp_Cons, 423 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;
36extern char *start_of_data (void) ATTRIBUTE_CONST; 36extern char *start_of_data (void) ATTRIBUTE_CONST;
37#if USE_LSB_TAG || UINTPTR_MAX <= VAL_MAX 37#if USE_LSB_TAG || UINTPTR_MAX <= VAL_MAX
38#define EXCEEDS_LISP_PTR(ptr) 0 38#define EXCEEDS_LISP_PTR(ptr) 0
39#elif DATA_SEG_BITS 39#else
40#define EXCEEDS_LISP_PTR(ptr) \ 40#define EXCEEDS_LISP_PTR(ptr) \
41 (((uintptr_t) (ptr) & ~DATA_SEG_BITS) >> VALBITS) 41 (((uintptr_t) (ptr) & ~DATA_SEG_BITS) >> VALBITS)
42#else
43#define EXCEEDS_LISP_PTR(ptr) ((uintptr_t) (ptr) >> VALBITS)
44#endif 42#endif