From 1781b9e935bea6cf2905e612da94b70028b25733 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 26 Jul 2012 01:12:03 -0700 Subject: Simplify export of symbols to GDB; fix related .gdbinit bugs. * etc/emacs-buffer.gdb ($tagmask, $valmask): Remove. (ygetptr): Adjust to recent changes in lisp.h and emacs.c, by using VALMASK instead of $valmask, CHECK_LISP_OBJECT_TYPE instead of gdb_use_union, and DATA_SEG_BITS instead of gdb_data_seg_bits. Also, use $ptr.i rather than $ptr.u.val. * src/.gdbinit (xgetptr, xgetint, xgettype): Don't use "set $bugfix = $bugfix.i", as this doesn't work (with GDB 7.4.1, anyway). (xgetptr, xgetint, xgettype, xcoding, xcharset, xprintbytestr): Adjust to changes in lisp.h and emacs.c, by using CHECK_LISP_OBJECT_TYPE rather than gdb_use_struct, VALMASK instead of $valmask, DATA_SEG_BITS instead of gdb_data_seg_bits, INTTYPEBITS instead of gdb_gctypebits - 1, USE_LSB_TAG instead of gdb_use_lsb, (1 << GCTYPEBITS) - 1 instead of $tagmask, VALBITS instead of gdb_valbits. (xvectype, xvector, xpr, xprintstr, xbacktrace): Similarly, use PSEUDOVECTOR_FLAG instead of PVEC_FLAG, and ARRAY_MARK_FLAG instead of gdb_array_mark_flag. (xboolvector): Get size from $->size, not $->header.size. Use BOOL_VECTOR_BITS_PER_CHAR rather than mystery constants. (xreload, hook-run, hookpost-run): Remove. * src/emacs.c: Include . (gdb_use_lsb, gdb_use_struct, gdb_valbits, gdb_gctypebits) (gdb_data_seg_bits, PVEC_FLAG, gdb_array_mark_flag, gdb_pvec_type): Remove. (gdb_CHECK_LISP_OBJECT_TYPE, gdb_DATA_SEG_BITS, gdb_GCTYPEBITS) (gdb_USE_LSB_TAG): New enum constants. (CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS, GCTYPEBITS, USE_LSB_TAG): Also define these as enum constants, so they're visible to GDB. (ARRAY_MARK_FLAG_VAL, PSEUDOVECTOR_FLAG_VAL, VALMASK_VAL): New macros. (ARRAY_MARK_FLAG, PSEUDOVECTOR_FLAG, VALMASK): Also define these as constants, so they're visible to GDB. * src/lisp.h (VALBITS, INTTYPEBITS, FIXNUM_BITS, PSEUDOVECTOR_SIZE_BITS) (PSEUDOVECTOR_SIZE_MASK, PVEC_TYPE_MASK, BOOL_VECTOR_BITS_PER_CHAR): Now enum constants, not macros, so they're visible to GDB. (CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS): Default to 0, as this is more convenient now. All uses changed. (VALMASK) [USE_LSB_TAG]: Also define in this case. * src/mem-limits.h (EXCEEDS_LISP_PTR): Adjust to DATA_SEG_BITS change. --- src/.gdbinit | 69 ++++++++++++++++-------------------------------------------- 1 file changed, 18 insertions(+), 51 deletions(-) (limited to 'src/.gdbinit') diff --git a/src/.gdbinit b/src/.gdbinit index 379a14b2ea5..c044b404f9b 100644 --- a/src/.gdbinit +++ b/src/.gdbinit @@ -17,7 +17,7 @@ # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301, USA. -# Force loading of symbols, enough to give us gdb_valbits etc. +# Force loading of symbols, enough to give us VALBITS etc. set main # With some compilers, we need this to give us struct Lisp_Symbol etc.: set Fmake_symbol @@ -43,32 +43,21 @@ handle SIGUSR2 noprint pass # debugging. handle SIGALRM ignore -# $valmask and $tagmask are mask values set up by the xreload macro below. - # Use $bugfix so that the value isn't a constant. # Using a constant runs into GDB bugs sometimes. define xgetptr - set $bugfix = $arg0 - if gdb_use_struct - set $bugfix = $bugfix.i - end - set $ptr = $bugfix & $valmask | gdb_data_seg_bits + set $bugfix = CHECK_LISP_OBJECT_TYPE ? $arg0.i : $arg0 + set $ptr = ($bugfix & VALMASK) | DATA_SEG_BITS end define xgetint - set $bugfix = $arg0 - if gdb_use_struct - set $bugfix = $bugfix.i - end - set $int = gdb_use_lsb ? $bugfix >> (gdb_gctypebits - 1) : $bugfix << (gdb_gctypebits - 1) >> (gdb_gctypebits - 1) + set $bugfix = CHECK_LISP_OBJECT_TYPE ? $arg0.i : $arg0 + set $int = USE_LSB_TAG ? $bugfix >> INTTYPEBITS : $bugfix << INTTYPEBITS >> INTTYPEBITS end define xgettype - set $bugfix = $arg0 - if gdb_use_struct - set $bugfix = $bugfix.i - end - set $type = (enum Lisp_Type) (gdb_use_lsb ? $bugfix & $tagmask : $bugfix >> gdb_valbits) + set $bugfix = CHECK_LISP_OBJECT_TYPE ? $arg0.i : $arg0 + set $type = (enum Lisp_Type) (USE_LSB_TAG ? $bugfix & (1 << GCTYPEBITS) - 1 : $bugfix >> VALBITS) end # Set up something to print out s-expressions. @@ -652,7 +641,7 @@ end define xvectype xgetptr $ set $size = ((struct Lisp_Vector *) $ptr)->header.size - output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag + output ($size & PSEUDOVECTOR_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~ARRAY_MARK_FLAG echo \n end document xvectype @@ -738,7 +727,7 @@ end define xvector xgetptr $ print (struct Lisp_Vector *) $ptr - output ($->header.size > 50) ? 0 : ($->contents[0])@($->header.size & ~gdb_array_mark_flag) + output ($->header.size > 50) ? 0 : ($->contents[0])@($->header.size & ~ARRAY_MARK_FLAG) echo \n end document xvector @@ -847,7 +836,7 @@ end define xboolvector xgetptr $ print (struct Lisp_Bool_Vector *) $ptr - output ($->header.size > 256) ? 0 : ($->data[0])@((($->header.size & ~gdb_array_mark_flag) + 7)/ 8) + output ($->size > 256) ? 0 : ($->data[0])@(($->size + BOOL_VECTOR_BITS_PER_CHAR - 1)/ BOOL_VECTOR_BITS_PER_CHAR) echo \n end document xboolvector @@ -990,7 +979,7 @@ define xpr end if $type == Lisp_Vectorlike set $size = ((struct Lisp_Vector *) $ptr)->header.size - if ($size & PVEC_FLAG) + if ($size & PSEUDOVECTOR_FLAG) set $vec = (enum pvec_type) ($size & PVEC_TYPE_MASK) if $vec == PVEC_NORMAL_VECTOR xvector @@ -1036,7 +1025,7 @@ end define xprintstr set $data = (char *) $arg0->data - output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte) + output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~ARRAY_MARK_FLAG : $arg0->size_byte) end define xprintsym @@ -1051,8 +1040,8 @@ document xprintsym end define xcoding - set $tmp = (struct Lisp_Hash_Table *) ((Vcoding_system_hash_table & $valmask) | gdb_data_seg_bits) - set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & $valmask) | gdb_data_seg_bits) + set $tmp = (struct Lisp_Hash_Table *) ((Vcoding_system_hash_table & VALMASK) | DATA_SEG_BITS) + set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & VALMASK) | DATA_SEG_BITS) set $name = $tmp->contents[$arg0 * 2] print $name pr @@ -1064,8 +1053,8 @@ document xcoding end define xcharset - set $tmp = (struct Lisp_Hash_Table *) ((Vcharset_hash_table & $valmask) | gdb_data_seg_bits) - set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & $valmask) | gdb_data_seg_bits) + set $tmp = (struct Lisp_Hash_Table *) ((Vcharset_hash_table & VALMASK) | DATA_SEG_BITS) + set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & VALMASK) | DATA_SEG_BITS) p $tmp->contents[charset_table[$arg0].hash_index * 2] pr end @@ -1126,7 +1115,7 @@ define xbacktrace if $type == Lisp_Vectorlike xgetptr (*$bt->function) set $size = ((struct Lisp_Vector *) $ptr)->header.size - output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag + output ($size & PSEUDOVECTOR_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~ARRAY_MARK_FLAG else printf "Lisp type %d", $type end @@ -1144,7 +1133,7 @@ end define xprintbytestr set $data = (char *) $arg0->data printf "Bytecode: " - output/u ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte) + output/u ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~ARRAY_MARK_FLAG : $arg0->size_byte) end document xprintbytestr Print a string of byte code. @@ -1188,19 +1177,6 @@ define hookpost-backtrace end end -define xreload - set $tagmask = ((1 << gdb_gctypebits) - 1) - set $valmask = gdb_use_lsb ? ~($tagmask) : ((EMACS_INT) 1 << gdb_valbits) - 1 -end -document xreload - When starting Emacs a second time in the same gdb session under - FreeBSD 2.2.5, gdb 4.13, $valmask have lost - their values. (The same happens on current (2000) versions of GNU/Linux - with gdb 5.0.) - This function reloads them. -end -xreload - # Flush display (X only) define ff set x_flush (0) @@ -1211,15 +1187,6 @@ Works only when an inferior emacs is executing. end -define hook-run - xreload -end - -# Call xreload if a new Emacs executable is loaded. -define hookpost-run - xreload -end - set print pretty on set print sevenbit-strings -- cgit v1.2.1