[fpc-devel] Dwarf3 and the encoding of classes

Joost van der Sluis joost at cnoc.nl
Mon Jan 3 12:30:30 CET 2011

Hi all,

When you specify -gw3 to create Dwarf-3 debug information, there is no
'reference' pointer to a class in the debug information.

This means that when you evaluate a class-variable, it will show the
contents of the variable, not the pointer pointing at it. If you want to
see the address of the class, you have to use @classname.

There are a few issues, though:
 - If a class is not assigned (=nil), gdb shows the message that the
class is not assigned. It doesn't show that it is nil. (Effectively this
means the same offcourse, is this a problem? Should gdb be patched to
show nil?)

- You can not compare two classes in gdb. It will complain that there is
no operator to compare two classes. Which is right, offcourse. But in
Pascal normally the addresses of the classes are compared when you
compare two classes. Gdb can't handle that.

- There is an issue with Lazarus. With other debug-formats, the class of
a type is often reported as '^Tfoo'. With Dwarf-3 it correctly reports
TFoo. But when you ask for @FooInstance, it will give you (correctly)
^TFoo as it's type. But Lazarus doesn't recognize this as pointer to a
class, because in the other debug-formats, this is considered the class

The debug-tests from Lazarus helped me a lot with this, thanks Martin
for that.

I also promised to build a Windows-gdb binary with the latest Dwarf-3
patches from the Archer-project. This can be downloaded here:


You can use this gdb version to test the Dwarf-3 format (strings, open
arrays), and the borland-fastcall calling convention. (ie: you can call
functions/procedures from within the debugger)

And please report issues with the Dwarf-3 format in combination with
this version of gdb.


More information about the fpc-devel mailing list