Mail Archives: djgpp/2015/05/25/08:43:03
Am 24.05.2015 18:10, schrieb Eli Zaretskii (eliz AT gnu DOT org):
>> 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.
To make the long story short: the error was to use the -ggdb flag. The djgpp
port of gcc seems not to understand this. The right flag is -gdwarf-2. It is
also possible to compile with -gdwarf-3 and -gdwarf-4 but later the info source
command always claims that the debug format is DWARF2. It seems to be of no
benefit to use either the -gdwarf-3 or -gdwarf4 flag. Compiling with -gstabs
still works but makes no major sense to me because all source files must be
located in the same cwd or the debugger will not find them. Using -gcoff makes
no sense at all for debugging because it makes gdb crash like this:
C:\tmp\5>gdb a.exe
GNU gdb (GDB) 7.9.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i786-pc-msdosdjgpp --target=djgpp".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.exe...rmvfromfree: memory fouled
Exiting due to signal SIGABRT
Raised at eip=003f96da
eax=005440e4 ebx=00000120 ecx=00000011 edx=00000000 esi=00000198 edi=00000198
ebp=000001a8 esp=005440d0 program=C:\DJGPP-2.04\BIN\GDB.EXE
cs: sel=01a7 base=02990000 limit=006affff
ds: sel=01af base=02990000 limit=006affff
es: sel=01af base=02990000 limit=006affff
fs: sel=017f base=00008e80 limit=0000ffff
gs: sel=01bf base=00000000 limit=0010ffff
ss: sel=01af base=02990000 limit=006affff
App stack: [00544788..004c478c] Exceptn stack: [004c46e8..004c27a8]
Call frame traceback EIPs:
0x003f96da
C:\tmp\5>
I do not think it make sense to investigate this issue any more.
Using -gdwarf-2 makes work gdb again at least for the test cases I have tried.
The bt command works and also the step and next commands work as they should.
I do not understand why -ggdb did not work. I expected the port of the compiler
to be clever enough to know that -ggdb means -gdwarf-2 for a DJGPP port of gcc.
But it seems to be that I am wrong.
Regards,
Juan M. Guerrero
- Raw text -