Sign in Join
Wiki copytemporary

Revision 1 of 1, by Mnalis on 8-20-2020. The page as it is now.

Debugging - GDB tricks

General tricks

Examining Type Info

Inspecting an ansistring

Stop debugger on exception

Work with breakpoints

Pointer

When you print the value of a pointer gdb will say something like:

 $0 = (MYPTR) 0x0202

If MYPTR is the correct type, you can just use

 p ptrvar^

if it's not the correct type, you can typecast it:

 p realptrtype(ptrvar)^

If you do not have a separate type for the actual pointer type, but only a type for what it points to, then the syntax is somewhat awkward because the gdb parser is still showing its C heritage in that case:

 p ^myvartype(ptrvar)^

Accessing a symbol in a specific unit unitname.identifier

If you have several global variables of the same name in different units, GDB will not follow pascal scoping rules, but pick whatever it finds first. So you need to specify which one you want.

GDB does not know the unitname.ident syntax. But it can instead take the filename of a unit. (filenames with a dot must be in single quotes)

'unit1.pas'::form1


From the Free Pascal wiki, page "Debugging - GDB tricks", as it stood on 2020-08-20 after a change by Mnalis, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.