[fpc-devel] AnsiString in DWARF2 vs DWARF3

Joost van der Sluis joost at cnoc.nl
Tue Oct 26 10:23:00 CEST 2010


On Sun, 2010-10-24 at 23:28 +0200, Graeme Geldenhuys wrote:
> Hi,
> 
> Recently I mentioned a issue with debugging (using GDB) and indexing
> in a AnsiString to retrieve a specific character from that string.
> 
> DWARF2
> -----------
> eg:
>   S := 'mystring';
> GDB can display the value of S without problems because it is treated
> as a PChar (from what I can see and understand).
> 
>   c := s[1]
> GDB displays the wrong character from the string. GDB displays the 'y'
> character instead of the 'm' character. GDB or DWARF2 treats a
> AnsiString (or an array of char) being 0-indexing instead of
> 1-indexed.
> 
> 
> DWARF3
> -----------
>    c := s[1]
> GDB correctly displays the first character of the string stored in s.
> This is accomplished by using tho lower_bound = 1 attribute in DWARF3.
> 
>   s := 'mystring'
> GDB cannot display the value of the ansistring stored in s, even thou
> DW_AT_type is set as well. It seems GDB cannot figure out how to
> handle displaying s, even though it knows it's an character array.
> 
> 
> It seems the DWARF2/3 support with GDB is playing the vice-versa game.
> Fix one, break one.
> 
> 
> This last part in DWARF3 above... it seems FPC has fulfilled the specs
> for DWARF3 (again from what I can understand from the DWARF3 spec
> inself) by correctly describing a AnsiString, so what is the issue now
> - why can't GDB display the value (full string value) of a ansistring
> variable? Is it now the lack of Object Pascal support in GDB giving us
> the problems?
> 
> 
> Sorry if this sounds dumb, but I'm new to DWARF and debuggers, so I
> just want to try and get my bearings with where exactly the problem
> sits. Is it with FPC, or with GDB, or both.

Nothing new. The problem with debugging is not only a fpc-problem, there
are problems with gdb also. The problem is that if a problem in fpc is
fixed properly, that will lead to problems in gdb. And the other way
around. Only way to fix those is to update both at the same time. This
is difficult because of the different release-cycles.

As I try to do things now, is to fix these problems in the Dwarf-3 debug
information. (Even it's not a Dwarf-3 issue. See for example the
case-sensitivity) This will lead to problems with debugging with Dwarf-3
at the short-term. (Ie: with unpatched gdb versions) But it won't affect
the debugging with Dwarf-2. So you can use the default Dwarf-debug
format for normal circumstances. And if you want to test and improve the
debugging, try Dwarf-3. (Although improving the debugging with Dwarf 2
isn't forbidden, offcourse.)

Joost.






More information about the fpc-devel mailing list