Mail Archives: djgpp/2013/08/13/16:25:01
Am 12.08.2013 21:06, schrieb Andris Pavenis:
> 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
>
Yes, this seems to be the reason. I was able to step through the code compiled with
gcc481 if I use -gdwarf-2 flag. Now , the question arises, shall djgpp also use DWARF4?
How much work it will be to implement this?
Regards,
Juan M. Guerrero
- Raw text -