Mail Archives: djgpp/2015/05/24/12:10:46
> Date: Sun, 24 May 2015 17:46:42 +0200
> From: "Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de)" <djgpp AT delorie DOT com>
>
> The following test program has been compiled using -O0 -ggdb:
What does -ggdb mean with the DJGPP build of GCC 4.9.2? It is better
to use an explicit debug info option (see below).
What does GDB say when you step into 'main' and type
(gdb) info source
One of the things it should announce is the type of debug info it
found in the program.
In any case, I suggest to try this experiment with all 3 debug info
types, COFF, stabs, and DWARF. To that end, instead of -ggdb, please
use "-gcoff -g3", "-gstabs -g3", and "-gdwarf-2 -g3", respectively.
(You could also try -gdwarf-3 and -gdwarf-4, not sure if the DJGPP
build of GCC supports that.)
> If I step into printf() and I issue the bt command I get the following
> output:
>
> (gdb) r
> Starting program: c:/tmp/5/a.exe
>
> Breakpoint 1, main () at a.c:15
> 15 int written = 0;
> (gdb) s
> 17 written = print("qwertz");
> (gdb)
> print (message=0x1f35 <print+33> "qwertz") at a.c:8
> 8 written = printf("%s\n", message);
> (gdb)
> printf (fmt=0x1f10 <_crt0_init_mcount+10> "%s\n") at printf.c:10
> 10 {
> (gdb)
> printf (fmt=0x1f10 <_crt0_init_mcount+10> "%s\n") at printf.c:14
> 14 va_start(args, fmt);
> (gdb) n
> 15 len = _doprnt(fmt, args, stdout);
> (gdb) bt
> #0 printf (fmt=0x1f10 <_crt0_init_mcount+10> "%s\n") at printf.c:15
> #1 0x00003316 in nofpsig () at npxsetup.c:51
> #2 0x00000006 in ?? ()
> #3 0x00001f2a in print (message=0x1f35 <print+33> "qwertz") at a.c:8
> #4 0x00001f61 in main () at a.c:17
> (gdb)
>
> The remarkable issue is that although I used the n command to avoid stepping
> into _doprnt() gdb behaves as if the s command had been used.
This backtrace is obviously bogus: the 0x00000006 address cannot be an
address of any function, and nofpsig is not called by 'print'.
Can you try compiling the program with an older compiler, and try
debugging the program compiled by GCC 4.9.2 with a pre-7.7 version of
GDB? It's important to understand if this is a GCC bug or GDB bug.
- Raw text -