delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2015/05/25/08:43:03

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Message-ID: <55631918.2060108@gmx.de>
Date: Mon, 25 May 2015 14:44:08 +0200
From: "Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de)" <djgpp AT delorie DOT com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: New GDB versions and DJGPP (Was: ANNOUNCE: DJGPP 2.05 beta 1)
References: <201505042003 DOT t44K3odg011007 AT delorie DOT com> <CAA2C=vA73qPvoDFytp3FeW6bCD1-XuGsFFoDinoKn2KYY1fkow AT mail DOT gmail DOT com> <555870E8 DOT 7040302 AT iki DOT fi> <CAA2C=vDhD6BJj89o1i0FRd2U0H4bTpGGN4zH6qs7FJKxzqhuQg AT mail DOT gmail DOT com> <201505180114 DOT t4I1EiaX017288 AT envy DOT delorie DOT com> <CAA2C=vCyrQ_+Yq6XsRD-UO4r=j9WoGGiXoqQFrkbiEQpzX+=MA AT mail DOT gmail DOT com> <201505181216 DOT t4ICGaKO014123 AT envy DOT delorie DOT com> <CAA2C=vCk5MY74z+HNVzzdLByg71Y_9ObK-1jPxJ_KF8eqRDZMQ AT mail DOT gmail DOT com> <83zj52dkns DOT fsf AT gnu DOT org> <CAA2C=vAPcN+MKC_2tcZqVmo9gvF2Cxdo+K+-qfKaNrQuCkMnEw AT mail DOT gmail DOT com> <555A0DD5 DOT 1010607 AT iki DOT fi> <83r3qdemuj DOT fsf AT gnu DOT org> <555AADE6 DOT 3030905 AT iki DOT f> <83lhgkehn4 DOT fsf AT gnu DOT org> <201505191714 DOT t4JHEr0B010992 AT envy DOT delorie DOT com> <83vbfo7a74 DOT fsf AT gnu DOT org> <201505191729 DOT t4JHTIRe011541 AT envy DOT delorie DOT com> <83sias77km DOT fsf AT gnu DOT org> <555CFF9C DOT 1050301 AT gmx DOT de> <555D5E30 DOT 7020107 AT iki DOT fi> <83vbfl6hs9 DOT fsf AT gnu DOT org> <55618917.7@[87.69.4.28]> <83d21q1g6n DOT fsf AT gnu DOT org> <5561C8A0 DOT 2010401 AT gmx DOT de> <5561F262 DOT 2010001 AT gmx DOT de> <83wpzyyn0u DOT fsf AT gnu DOT org>
In-Reply-To: <83wpzyyn0u.fsf@gnu.org>
X-Provags-ID: V03:K0:W2ufRXXWDgm/E+BYPoOPJsn4THVawCZx5kMOXX7RIfH9x9wJJM9
OOp21/0h+IUsQ5w2+F84bfB67Ak4zQZOh5wSF+uxAy49YeC9/FVoC2OTLgRkes+/pOyJlNZ
eC8H9UGbkyv4JzpTVFz0yhdPrCUPIfrCpGjHqMYKF5GrHv3pd+ES9LLp+zhY6+hCkLGa8F7
RAISanvZTyh7zs+Fd8G9A==
X-UI-Out-Filterresults: notjunk:1;
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019