Convert safe_call to use variable number of arguments.
[bpt/emacs.git] / src / .gdbinit
index b60c14f..620ca63 100644 (file)
@@ -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,23 +43,33 @@ 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
-  set $ptr = (gdb_use_union ? (gdb_use_lsb ? $bugfix.u.val << gdb_gctypebits : $bugfix.u.val) : $bugfix & $valmask) | gdb_data_seg_bits
+  if (CHECK_LISP_OBJECT_TYPE)
+    set $bugfix = $arg0.i
+  else
+    set $bugfix = $arg0
+  end
+  set $ptr = ($bugfix & VALMASK) | DATA_SEG_BITS
 end
 
 define xgetint
-  set $bugfix = $arg0
-  set $int = gdb_use_union ? $bugfix.s.val : (gdb_use_lsb ? $bugfix : $bugfix << gdb_gctypebits) >> gdb_gctypebits
+  if (CHECK_LISP_OBJECT_TYPE)
+    set $bugfix = $arg0.i
+  else
+    set $bugfix = $arg0
+  end
+  set $int = $bugfix << (USE_LSB_TAG ? 0 : INTTYPEBITS) >> INTTYPEBITS
 end
 
 define xgettype
-  set $bugfix = $arg0
-  set $type = gdb_use_union ? $bugfix.s.type : (enum Lisp_Type) (gdb_use_lsb ? $bugfix & $tagmask : $bugfix >> gdb_valbits)
+  if (CHECK_LISP_OBJECT_TYPE)
+    set $bugfix = $arg0.i
+  else
+    set $bugfix = $arg0
+  end
+  set $type = (enum Lisp_Type) (USE_LSB_TAG ? $bugfix & (1 << GCTYPEBITS) - 1 : $bugfix >> VALBITS)
 end
 
 # Set up something to print out s-expressions.
@@ -67,10 +77,7 @@ end
 # from calling OutputDebugString, which causes GDB to display each
 # character twice (yuk!).
 define pr
-  set $output_debug = print_output_debug_flag
-  set print_output_debug_flag = 0
-  set debug_print ($)
-  set print_output_debug_flag = $output_debug
+  pp $
 end
 document pr
 Print the emacs s-expression which is $.
@@ -90,48 +97,17 @@ Print the argument as an emacs s-expression
 Works only when an inferior emacs is executing.
 end
 
-# Print out s-expressions from tool bar
-define pp1
-  set $tmp = $arg0
-  set $output_debug = print_output_debug_flag
-  set print_output_debug_flag = 0
-  set safe_debug_print ($tmp)
-  set print_output_debug_flag = $output_debug
-end
-document pp1
-Print the argument as an emacs s-expression.
-Works only when an inferior emacs is executing.
-For use on tool bar when debugging in Emacs
-where the variable name would not otherwise
-be recorded in the GUD buffer.
-end
-
 # Print value of lisp variable
 define pv
-  set $tmp = "$arg0"
-  set $output_debug = print_output_debug_flag
-  set print_output_debug_flag = 0
-  set safe_debug_print ( find_symbol_value (intern ($tmp)))
-  set print_output_debug_flag = $output_debug
-end
-document pv
-Print the value of the lisp variable given as argument.
-Works only when an inferior emacs is executing.
-end
-
-# Print value of lisp variable
-define pv1
   set $tmp = "$arg0"
   set $output_debug = print_output_debug_flag
   set print_output_debug_flag = 0
   set safe_debug_print (find_symbol_value (intern ($tmp)))
   set print_output_debug_flag = $output_debug
 end
-document pv1
+document pv
 Print the value of the lisp variable given as argument.
 Works only when an inferior emacs is executing.
-For use when debugging in Emacs where the variable
-name would not otherwise be recorded in the GUD buffer.
 end
 
 # Print out current buffer point and boundaries
@@ -288,8 +264,8 @@ define pitx
   while ($i < $it->sp && $i < 4)
     set $e = $it->stack[$i]
     printf "stack[%d]: ", $i
-    pitmethod $e->method
-    printf "[%d]", $e->position.charpos
+    pitmethod $e.method
+    printf "[%d]", $e.position.charpos
     printf "\n"
     set $i = $i + 1
   end
@@ -677,7 +653,11 @@ 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
+  if ($size & PSEUDOVECTOR_FLAG)
+    output (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_SIZE_BITS)
+  else
+    output $size & ~ARRAY_MARK_FLAG
+  end
   echo \n
 end
 document xvectype
@@ -737,60 +717,6 @@ Print $ as a misc free-cell pointer.
 This command assumes that $ is an Emacs Lisp Misc value.
 end
 
-define xintfwd
-  xgetptr $
-  print (struct Lisp_Intfwd *) $ptr
-end
-document xintfwd
-Print $ as an integer forwarding pointer.
-This command assumes that $ is an Emacs Lisp Misc value.
-end
-
-define xboolfwd
-  xgetptr $
-  print (struct Lisp_Boolfwd *) $ptr
-end
-document xboolfwd
-Print $ as a boolean forwarding pointer.
-This command assumes that $ is an Emacs Lisp Misc value.
-end
-
-define xobjfwd
-  xgetptr $
-  print (struct Lisp_Objfwd *) $ptr
-end
-document xobjfwd
-Print $ as an object forwarding pointer.
-This command assumes that $ is an Emacs Lisp Misc value.
-end
-
-define xbufobjfwd
-  xgetptr $
-  print (struct Lisp_Buffer_Objfwd *) $ptr
-end
-document xbufobjfwd
-Print $ as a buffer-local object forwarding pointer.
-This command assumes that $ is an Emacs Lisp Misc value.
-end
-
-define xkbobjfwd
-  xgetptr $
-  print (struct Lisp_Kboard_Objfwd *) $ptr
-end
-document xkbobjfwd
-Print $ as a kboard-local object forwarding pointer.
-This command assumes that $ is an Emacs Lisp Misc value.
-end
-
-define xbuflocal
-  xgetptr $
-  print (struct Lisp_Buffer_Local_Value *) $ptr
-end
-document xbuflocal
-Print $ as a buffer-local-value pointer.
-This command assumes that $ is an Emacs Lisp Misc value.
-end
-
 define xsymbol
   set $sym = $
   xgetptr $sym
@@ -817,7 +743,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
@@ -926,7 +852,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
@@ -1037,7 +963,7 @@ end
 
 define xpr
   xtype
-  if $type == Lisp_Int
+  if $type == Lisp_Int0 || $type == Lisp_Int1
     xint
   end
   if $type == Lisp_Symbol
@@ -1057,44 +983,20 @@ define xpr
     if $misc == Lisp_Misc_Free
       xmiscfree
     end
-    if $misc == Lisp_Misc_Boolfwd
-      xboolfwd
-    end
     if $misc == Lisp_Misc_Marker
       xmarker
     end
-    if $misc == Lisp_Misc_Intfwd
-      xintfwd
-    end
-    if $misc == Lisp_Misc_Boolfwd
-      xboolfwd
-    end
-    if $misc == Lisp_Misc_Objfwd
-      xobjfwd
-    end
-    if $misc == Lisp_Misc_Buffer_Objfwd
-      xbufobjfwd
-    end
-    if $misc == Lisp_Misc_Buffer_Local_Value
-      xbuflocal
-    end
-#    if $misc == Lisp_Misc_Some_Buffer_Local_Value
-#      xvalue
-#    end
     if $misc == Lisp_Misc_Overlay
       xoverlay
     end
-    if $misc == Lisp_Misc_Kboard_Objfwd
-      xkbobjfwd
-    end
 #    if $misc == Lisp_Misc_Save_Value
 #      xsavevalue
 #    end
   end
   if $type == Lisp_Vectorlike
     set $size = ((struct Lisp_Vector *) $ptr)->header.size
-    if ($size & PVEC_FLAG)
-      set $vec = (enum pvec_type) ($size & PVEC_TYPE_MASK)
+    if ($size & PSEUDOVECTOR_FLAG)
+      set $vec = (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_SIZE_BITS)
       if $vec == PVEC_NORMAL_VECTOR
        xvector
       end
@@ -1139,7 +1041,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
@@ -1154,8 +1056,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
@@ -1167,8 +1069,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
@@ -1229,7 +1131,11 @@ 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
+        if ($size & PSEUDOVECTOR_FLAG)
+         output (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_SIZE_BITS)
+       else
+         output $size & ~ARRAY_MARK_FLAG
+       end
       else
         printf "Lisp type %d", $type
       end
@@ -1247,7 +1153,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.
@@ -1291,19 +1197,6 @@ define hookpost-backtrace
   end
 end
 
-define xreload
-  set $tagmask = (((long)1 << gdb_gctypebits) - 1)
-  set $valmask = gdb_use_lsb ? ~($tagmask) : ((long)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)
@@ -1314,15 +1207,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