From: mly@ai.mit.edu (Richard Mlynarik)
Subject: GDB expression-evaluation blowout
Organization: GNUs Not Usenet
Distribution: gnu
Date: Wed, 19 Aug 1992 23:43:34 GMT

GDB blows chunks on the el-grosso-kludgeo && || concoctions I used to
use to debug "union" datatypes.

The backtrace below is from running GDB 4.6 on Emacs 18.58.

I'd love a patch.

(I'd love it even more if GDB used Scheme as an extension language and
if there were a front-end/back-end split which used s-expressions to
communicate.  Then I could just use COND like God intended.)

(gdb) file /import/gnu/src/gdb-4.6/gdb/gdb
Warning: core file may not match specified executable file.
Load new symbol table from "/import/gnu/src/gdb-4.6/gdb/gdb"? (y or n) y
Reading symbols from /import/gnu/src/gdb-4.6/gdb/gdb...done.
(gdb) set prompt (0gdb)
###### Debugging Emacs is GDB's purpose in life.
(0gdb) run /import/emacs-18.58/src/xemacs
Starting program: /import/gnu/src/gdb-4.6/gdb/gdb /import/emacs-18.58/src/xemacs
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
(gdb) set prompt (1gdb)
(1gdb) break Fsignal
Breakpoint 1 at 0x4fd9c: file eval.c, line 1030.
(1gdb) run -q
Starting program: /import/emacs-18.58/src/xemacs -q
###### Type c-G at Emacs to get a GDB breakpoint.
Breakpoint 1, Fsignal (sig=18308368, data=18308108) at eval.c:1030
1030	  register struct handler *allhandlers = handlerlist;
###### Read in the evil user-commands (see below for listing)
(1gdb) source ~/e/.gdbinit
Source directories searched: $cdir:$cwd
(1gdb) p sig
$2 = 18308368
###### DIE!
(1gdb) xfrob
dtpLisp_Int (mark1),$3 = 18308368

Program received signal 11, Segmentation fault
lookup_struct_elt_type (type=0x0, name=0xe74b8 "data", noerr=1)
    at gdbtypes.c:630
(0gdb) bt
#0  lookup_struct_elt_type (type=0x0, name=0xe74b8 "data", noerr=1)
    at gdbtypes.c:630
#1  0x15400 in evaluate_subexp (expect_type=0xe9e08, exp=0xe7408, 
    pos=0xf7ffe984, noside=EVAL_AVOID_SIDE_EFFECTS) at eval.c:456
#2  0x161c4 in evaluate_subexp (expect_type=0xe9e08, exp=0xe7408, 
    pos=0xf7ffe984, noside=EVAL_AVOID_SIDE_EFFECTS) at eval.c:818
#3  0x15550 in evaluate_subexp (expect_type=0x0, exp=0xe7408, pos=0xf7ffe984, 
    noside=EVAL_AVOID_SIDE_EFFECTS) at eval.c:495
#4  0x158f4 in evaluate_subexp (expect_type=0x0, exp=0xe7408, pos=0xf7ffe984, 
    noside=EVAL_NORMAL) at eval.c:584
#5  0x159bc in evaluate_subexp (expect_type=0xe9e88, exp=0xe7408, 
    pos=0xf7ffe984, noside=EVAL_NORMAL) at eval.c:602
#6  0x15550 in evaluate_subexp (expect_type=0x0, exp=0xe7408, pos=0xf7ffe984, 
    noside=EVAL_NORMAL) at eval.c:495
#7  0x1487c in evaluate_expression (exp=0xe7408) at eval.c:142
#8  0x200b4 in set_command (
    exp=0xfa10c "$ignore = (($type == Lisp_String) && ($tem = (char *) ($tem->data))) || (($type == Lisp_Symbol) && ($tem = (char *) (((struct Lisp_String *) ($tem->name))->data)))", from_tty=0) at printcmd.c:867
#9  0x38cc in execute_command (
    p=0xfa10c "$ignore = (($type == Lisp_String) && ($tem = (char *) ($tem->data))) || (($type == Lisp_Symbol) && ($tem = (char *) (((struct Lisp_String *) ($tem->name))->data)))", from_tty=0) at main.c:915
#10 0x3850 in execute_command (p=0x210d0f "", from_tty=2165928) at main.c:905
#11 0x3850 in execute_command (p=0xe5bee "", from_tty=2165608) at main.c:905
#12 0x3850 in execute_command (p=0x1de80d "", from_tty=961416) at main.c:905
#13 0x3a8c in command_loop () at main.c:976
#14 0x36cc in main (argc=2, argv=0xf7ffeec4) at main.c:853
(0gdb) up 9
#9  0x38cc in execute_command (
    p=0xfa10c "$ignore = (($type == Lisp_String) && ($tem = (char *) ($tem->data))) || (($type == Lisp_Symbol) && ($tem = (char *) (((struct Lisp_String *) ($tem->name))->data)))", from_tty=0) at main.c:915
(0gdb) do 9
#0  lookup_struct_elt_type (type=0x0, name=0xe74b8 "data", noerr=1)
    at gdbtypes.c:630
(0gdb) 
----------------------------------------------------------------------
##### .gdbinit
define xfrob
set $tem = $
xxfrob
end

define xxfrob
set $type = (((int) $tem) >> 26) & 037
set $tem = ((int) $tem) & ((1<<26)-1)
xxxfrob
end

define xxxfrob
set $type = ((int) $type) & 037
set $markbit = ((int) $tem) & (1<<31)
set $ignore = (($type == (int)Lisp_Symbol) && ($tem = (struct Lisp_Symbol *) $tem)) || (($type == (int)Lisp_String) && ($tem = (struct Lisp_String *) $tem)) || (($type == (int)Lisp_Vector) && ($tem = (struct Lisp_Vector *) $tem)) || (($type == (int)Lisp_Cons) && ($tem = (struct Lisp_Cons *) $tem))
# || (($type == (int)Lisp_Record) && ($tem = (struct lrecord_header *) $tem))
#set $ignore = ($type == (int)Lisp_Record) && ((($tem->implementation == &lrecord_buffer) && ($tem = (struct buffer *) $tem)) || (($tem->implementation == &lrecord_marker) && ($tem = (struct Lisp_Marker *) $tem)) || (($tem->implementation == &lrecord_window) && ($tem = (struct window *) $tem)) || (($tem->implementation == &lrecord_window_configuration) && ($tem = (struct save_window_data *) $tem)) || (($tem->implementation == &lrecord_event) && ($tem = (struct Lisp_Event *) $tem)) || (($tem->implementation
 == &lrecord_keymap) && ($tem = (struct Lisp_Keymap *) $tem)) || (($tem->implementation == &lrecord_process) && ($tem = (struct Lisp_Process *) $tem)) || (($tem->implementation == &lrecord_subr) && ($tem = (struct Lisp_Subr *) $tem)))
echo dtp 
output (enum Lisp_Type) $type
echo \ (mark 
output ($markbit == 0)
echo ),
print $tem
##### This is where the chunk-blowing occurs
set $ignore = (($type == Lisp_String) && ($tem = (char *) ($tem->data))) || (($type == Lisp_Symbol) && ($tem = (char *) (((struct Lisp_String *) ($tem->name))->data)))
# || ($tem = $empty_string)
output $tem
echo \n
set $type = (enum Lisp_Type $type)
end


Newsgroups: gnu.gdb.bug