This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [PATCH] Fix coff symbol table reading problem for C code compiledby g++
On Sat, 14 Aug 2004, Eli Zaretskii wrote:
> > Date: Fri, 13 Aug 2004 02:06:00 +0200 (CEST)
> > From: Ton van Overbeek <v-overbeek@cistron.nl>
> >
> > I found a bug/problem in the symbol reading code in symtab.c in gdb-6.2.
>
> Thanks for the report and the patch.
>
> Could you please also provide a short test case and an example
> compile-link-GDB session script which both shows how to eproduce the
> problem and the exact outputs from GDB?
>
Here is a script illustrating the problem. Since I am working on a gdb-6.x
port for m68k-palmos the script is m68k-palmos specific (main has to be
called PilotMain), but it should be easy to adapt to the general case.
-------------------------------------------------------------------------------
#!/bin/sh
set -x
# Set to gdb used
GDB=./gdb
cat << EOF > test.c
/* Following #ifdef m68k-palmos specific */
#ifdef __cplusplus
extern "C" {
int PilotMain(void);
}
#endif
void g (void)
{
}
void f (void)
{
}
/* In m68k-palmos no main(), but PilotMain() */
int PilotMain (void)
{
f();
g();
return 0;
}
EOF
cat <<EOF > test.cmd
file test
break f
info break
quit
EOF
m68k-palmos-g++ --version
echo "Compiling & Linking test program"
m68k-palmos-g++ -g -o test test.c
echo "Running gdb"
$GDB --command test.cmd
rm -f test.c test.cmd test
-------------------------------------------------------------------------------
Here is the output from the script when runnin with a gdb without the
patch:
-------------------------------------------------------------------------------
+ GDB=./gdb
+ cat
+ cat
+ m68k-palmos-g++ --version
2.95.3-kgpd
+ echo Compiling & Linking test program
Compiling & Linking test program
+ m68k-palmos-g++ -g -o test test.c
+ echo Running gdb
Running gdb
+ ./gdb --command test.cmd
GNU gdb 6.2
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or 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.
This GDB was configured as "--host=i686-pc-cygwin --target=m68k-palmos".
Breakpoint 1 at 0x138: file test.c, line 9.
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000138 in g__Fv at test.c:9
+ rm -f test.c test.cmd test
------------------------------------------------------------------------------
Note the breakpoint is set at the end of the preceding function and the
preceding function name g__Fv is the mangled name.
Now the output of the patched gdb:
------------------------------------------------------------------------------
+ GDB=./gdb-new
+ cat
+ cat
+ m68k-palmos-g++ --version
2.95.3-kgpd
+ echo Compiling & Linking test program
Compiling & Linking test program
+ m68k-palmos-g++ -g -o test test.c
+ echo Running gdb
Running gdb
+ ./gdb-new --command test.cmd
GNU gdb 6.2
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or 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.
This GDB was configured as "--host=i686-pc-cygwin --target=m68k-palmos".
Breakpoint 1 at 0x148: file test.c, line 13.
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000148 in f(void) at test.c:13
+ rm -f test.c test.cmd test
------------------------------------------------------------------------------
Now the breakpoint is reported correctly.
I hope you can convert this to a test program + expect script for the
testsuite.
Let me know i this is sufficient.
Ton van Overbeek