Sign in Join
Wiki copytemporary

Debugging - GDB tricks

Contents

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:

pascal
$0 = (MYPTR) 0x0202

If MYPTR is the correct type, you can just use

pascal
p ptrvar^

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

pascal
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:

pascal
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)

pascal
'unit1.pas'::form1

From the Free Pascal wiki, page "Debugging - GDB tricks", as the Internet Archive kept it on 2024-12-12, last changed on 2020-08-21. 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.

Revision 3, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.