This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
c++/2116: gdb crashes when calling "C" function from "C++" code
- From: ppluzhnikov at charter dot net
- To: gdb-gnats at sources dot redhat dot com
- Date: 17 Apr 2006 23:24:40 -0000
- Subject: c++/2116: gdb crashes when calling "C" function from "C++" code
- Reply-to: ppluzhnikov at charter dot net
>Number: 2116
>Category: c++
>Synopsis: gdb crashes when calling "C" function from "C++" code
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Apr 17 23:28:01 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator: Paul Pluzhnikov
>Release: 6.4
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
Gdb crashes when calling plain-C function from C++ code.
AFAICT, this is a 6.4 regression (my 6.3 compile works fine).
>How-To-Repeat:
$ cat foo.c
int foo(int x) { return x; }
$ cat main.cpp
int func(int x)
{
return x;
}
int main()
{
return func(0);
}
$ /usr/local/gcc-3.4.6/bin/gcc -g -c foo.c
$ /usr/local/gcc-3.4.6/bin/g++ -g main.cpp foo.o
$ gdb-6.4 -q ./a.out
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) b func
Breakpoint 1 at 0x8048567: file main.cpp, line 3.
(gdb) r
Breakpoint 1, func (x=0) at main.cpp:3
3 return x;
(gdb) p foo(1)
Segmentation fault (core dumped)
##### And now for some debugging:
$ gdb-6.4 -q gdb-6.4 core
Using host libthread_db library "/lib/libthread_db.so.1".
Core was generated by `gdb-6.4 -q ./a.out'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib/libncurses.so.4...done.
...
#0 0x0818db3a in cp_demangled_name_to_comp (demangled_name=0x0, memory=0xbfffd72c, errmsg=0x0) at cp-name-parser.y:1990
1990 cp-name-parser.y: No such file or directory.
in cp-name-parser.y
(gdb) up 2
#2 0x080e60fd in find_overload_match (arg_types=0xbfffd7a0, nargs=1, name=0x0, method=0, lax=0, objp=0x0, fsym=0x831fdb0,
valp=0x0, symp=0xbfffd8fc, staticp=0x0) at /home/camel1/paul/Archive/gdb-6.4/gdb/valops.c:1850
1850 func_name = cp_func_name (qualified_name);
(gdb) p *fsym
$1 = {ginfo = {name = 0x831a460 "foo", value = {ivalue = 137494040, block = 0x831fe18,
bytes = 0x831fe18 "\230\205\004\b? \205\004\b?°?ý1\bx?þ1\b4?þ1\b", address = 137494040, chain = 0x831fe18},
language_specific = {cplus_specific = {demangled_name = 0x0}}, language = language_c, section = 11,
bfd_section = 0x830c7cc}, type = 0x831fd58, domain = VAR_DOMAIN, aclass = LOC_BLOCK, line = 1, ops = 0x825a558,
aux_value = {basereg = -552, ptr = 0x831fdd8}, hash_next = 0x0}
Note that 'foo' has language_c and no demangled_name ...
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: