delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2013/08/12/15:06:29

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Message-ID: <52093221.9010206@iki.fi>
Date: Mon, 12 Aug 2013 22:06:09 +0300
From: Andris Pavenis <andris DOT pavenis AT iki DOT fi>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8
MIME-Version: 1.0
To: djgpp AT delorie DOT com
CC: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
Subject: Re: Programs compiled with gcc481 cannot be debugged with gdb.
References: <51B36263 DOT 6080309 AT gmx DOT de> <51B41437 DOT 6070003 AT iki DOT fi>
In-Reply-To: <51B41437.6070003@iki.fi>
Reply-To: djgpp AT delorie DOT com

On 06/09/2013 08:35 AM, Andris Pavenis wrote:
> On 06/08/2013 07:57 PM, Juan Manuel Guerrero wrote:
>> Please inspect the small program below:
>>
>> #include <stdio.h>
>>
>> void f(const int i)
>> {
>>    printf("a=%d\n", i);
>> }
>>
>> int main(void)
>> {
>>    int a = 1;
>>    f(a);
>>    return a;
>> }
>>
>>
>> I have compiled it using gcc-4.8.1 with the following command:
>>    gcc -Wall -g2 -O0 a.c
>> When I try to use gdb to step through the code I get
>> the following error message:
>>
>> GNU gdb (GDB) 7.6
>> Copyright (C) 2013 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".
>> For bug reporting instructions, please see:
>> <http://www.gnu.org/software/gdb/bugs/>...
>> Reading symbols from c:/tmp/a.exe...done.
>> (gdb) b main
>> Breakpoint 1 at 0x1eba: file 1.c, line 10.
>> (gdb) r
>> Starting program: c:/tmp/a.exe
>>
>> Breakpoint 1, main () at 1.c:10
>> 10        int a = 1;
>> (gdb) s
>> 11        f(a);
>> (gdb)
>> f (i=<error reading variable: can't compute CFA for this frame>) at 1.c:5
>> 5         printf("a=%d\n", i);
>> (gdb) p i
>> can't compute CFA for this frame
>> (gdb)
>>
>>
>> The important issue is to try to step into a function.
>> As long as I do not step into a function every thing works OK.
>> The same happens if I use gcc480.  If I use gcc473 every thing
>> works OK.  The program itself runs flawlessly.
>> Am I missing something?  Is the coff/dwarf support in gcc-4.8.N
>> brocken?
>>
>> If more info is needed, please tell.
>>
>
> I can reproduce the problem.
>
> 1) it depends on optimization level for DWARF4 and DWARF3. I have this
>     problem with -gdwarf-3 and -gdwarf-4 and -O0 and -O1,
>     but not with -O2 and -O3.
> 2) it does not seem to happen when -gdwarf-2 is being used
>
> I do not know which additional optimization option present with -O2 but bit
> -O1 causes the difference.

The reason is perhaps broken DWARF3 and DWARF4 support for DJGPP. According to
http://gcc.gnu.org/gcc-4.8/changes.html:

DWARF4 is now the default when generating DWARF debug information. When -g is used on a platform 
that uses DWARF debugging information, GCC will now default to -gdwarf-4 -fno-debug-types-section.
GDB 7.5, Valgrind 3.8.0 and elfutils 0.154 debug information consumers support DWARF4 by default. 
Before GCC 4.8 the default version used was DWARF2. To make GCC 4.8 generate an older DWARF version 
use -g together with -gdwarf-2 or -gdwarf-3. The default for Darwin and VxWorks is still -gdwarf-2 
-gstrict-dwarf.

Andris

- Raw text -


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