Article View: gnu.gdb.bug
Article #149gdb-4.6 dumps core setting breakpoint on destructors
From: Dave Daney
Date: Fri, 31 Jul 1992 11:53
Date: Fri, 31 Jul 1992 11:53
149 lines
6106 bytes
6106 bytes
Here is the problem:
gdb-4.6 dumps core setting breakpoint on destructor when command
completion is not used.
My system configuration:
gdb-4.6 running on Interactive UNIX 2.2.1
configure i386-none-sysv32
trad-core patch, and patches for debug register use.
#define CPLUS_MARKER '.'
None of these patches are responsible for this problem.
Here is what I did.
Concider this c++ program compiled thusly:
> gcc -v -g -o test test.cc
Reading specs from /usr/local/lib/gcc-lib/i386-isc/2.2.2/specs
gcc version 2.2.2
/usr/local/lib/gcc-lib/i386-isc/2.2.2/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__
GNUG__=2 -D__cplusplus -Dunix -Di386 -D__unix__ -D__i386__ -D__unix -D__i386 -g
test.cc /usr/tmp/cca06705.i
GNU CPP version 2.2.2 (80386, ATT syntax)
/usr/local/lib/gcc-lib/i386-isc/2.2.2/cc1plus /usr/tmp/cca06705.i -quiet -dumpb
ase test.cc -g -version -o /usr/tmp/cca06705.s
GNU C++ version 2.2.2 (80386, ATT syntax) compiled by GNU C version 2.2.2.
as -o test.o /usr/tmp/cca06705.s
ld -o test /lib/crt1.o /usr/local/lib/gcc-lib/i386-isc/2.2.2/crtbegin.o -L/usr/
local/lib/gcc-lib/i386-isc/2.2.2 -L/usr/local/lib test.o -lgcc -lc -lg -lgcc /us
r/local/lib/gcc-lib/i386-isc/2.2.2/crtend.o /lib/crtn.o
>
//------ test.cc ---------------------------------------------------------
class tree_element {
int value;
tree_element *larger;
tree_element *smaller;
tree_element *parent;
public:
int get() {return value;};
tree_element(void) {value = 0; parent = larger = smaller = 0;};
tree_element(int i) {value = i; parent = larger = smaller = 0;};
~tree_element();
};
tree_element::~tree_element()
{
if(larger) delete larger;
if(smaller) delete smaller;
}
int main(int argc, char *argv[])
{
tree_element e(3);
int i = e.get() + 1;
return(0);
}
//------------------------------------------------------------------
set a break point using command completion works fine.
first I do this b tree_ele<TAB>::~tree<TAB><CR>
> gdb test
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) b 'tree_element::~tree_element(void)'
Breakpoint 1 at 0x1ff: file test.cc, line 16.
(gdb)
If I try this with out using command completion (because I am using
gdb mode in emacs).
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) file test
Reading symbols from test...done.
(gdb) b tree_element::~tree_element
Program received signal 11, Segmentation fault
0x23179 in decode_line_1 (argptr=0x7ffffcf4, funfirstline=1,
default_symtab=0x0, default_line=0) at symtab.c:1611
symtab.c:1611: No such file or directory.
(top-gdb) bt
#0 0x23179 in decode_line_1 (argptr=0x7ffffcf4, funfirstline=1,
default_symtab=0x0, default_line=0) at symtab.c:1611
#1 0x708f in break_command_1 (arg=0x42d025 "", tempflag=0, from_tty=1)
at breakpoint.c:1596
#2 0x7314 in break_command (arg=0x42d00a "tree_element::~tree_element",
from_tty=1) at breakpoint.c:1681
#3 0x1659 in execute_command (p=0x42d00a "tree_element::~tree_element",
from_tty=1) at main.c:915
#4 0x17dd in command_loop () at main.c:976
#5 0x1496 in main (argc=1, argv=0x7ffffe20) at main.c:853
(top-gdb) l
1606 if (destructor_name_p (copy, t))
1607 {
1608 /* destructors are a special case. */
1609 struct fn_field *f = TYPE_FN_FIELDLIST1 (t, 0);
1610 int len = TYPE_FN_FIELDLIST_LENGTH (t, 0) - 1;
1611 char *phys_name = TYPE_FN_FIELD_PHYSNAME (f, len);
1612 physnames[i1] = (char *)alloca (strlen (phys_name) + 1
);
1613 strcpy (physnames[i1], phys_name);
1614 sym_arr[i1] =
1615 lookup_symbol (phys_name, SYMBOL_BLOCK_VALUE (sym_cl
ass),
(top-gdb) print *t
$1 = {code = TYPE_CODE_STRUCT, name = 0x430528 "struct tree_element",
length = 16, objfile = 0x443e08, target_type = 0x0, pointer_type = 0x4460e4,
reference_type = 0x0, function_type = 0x0, flags = 0, nfields = 4,
fields = 0x446118, vptr_basetype = 0x0, vptr_fieldno = -1, type_specific = {
arg_types = 0x425020, cplus_stuff = 0x425020}}
(top-gdb) print t->type_specific.cplus_stuff
$2 = (struct <opaque> *) 0x425020
(top-gdb) print *(struct cplus_struct_type *)t->type_specific.cplus_stuff
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
WHY DO I HAVE TO DO THIS????????????????????????
THIS MAKES ME SOOOOOOOO MADDD. (a limitation of coff???)
$3 = {virtual_field_bits = 0x0, private_field_bits = 0x0,
protected_field_bits = 0x0, nfn_fields = 0, n_baseclasses = 0,
nfn_fields_total = 0, fn_fieldlists = 0x0, via_protected = 0 '\000',
via_public = 0 '\000'}
(top-gdb) print &cplus_struct_default
$4 = (struct cplus_struct_type *) 0x425020
As you can see here the cplus_stuff is set to the default. I think the
default values need to be chosen a bit better. I am not sure what to
do about this so I did this
1606 if (destructor_name_p (copy, t) && 0)
Now I get a message saying I should be using command completion, but at
least I don't blow core.
Dave Daney daney@mermaid.micro.umn.edu
Technical Details
Message-ID:
<199207312153.AA14486@mermaid.micro.umn.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!mermaid.micro.umn.edu!daneyShow Full Headers
Complete Article Headers
Newsgroups: gnu.gdb.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!mermaid.micro.umn.edu!daney From: daney@mermaid.micro.umn.edu (Dave Daney) Subject: gdb-4.6 dumps core setting breakpoint on destructors Message-ID: <199207312153.AA14486@mermaid.micro.umn.edu> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Fri, 31 Jul 1992 11:53:55 GMT Approved: bug-gdb@prep.ai.mit.edu Lines: 150