There are some peculiarities of Free Pascal which you should be aware of when using
gdb. We list the main ones here:
- Free Pascal generates information for GDB in uppercare letters. This is a
consequence of the fact that pascal is a case insensitive language. So, when
referring to a variable or function, you need to make it's name all
uppercase.
As an example, of you want to watch the value of a loop variable
count, you should type
watch COUNT
Or if you want stop when a certain function (e.g MyFunction) is called,
type
break MYFUNCTION
- Line numbers may be off by a little. This is a bug in Free Pascal and will be
fixed as soon as possible.
- gdb does not know sets.
- gdb doesn't know strings. Strings are represented in gdb
as records with a length field and an array of char contaning the string.
You can also use the following user function to print strings:
define pst
set $pos=&$arg0
set $strlen = {byte}$pos
print {char}&$arg0.st@($strlen+1)
end
document pst
Print out a Pascal string
end
If you insert it in your gdb.ini file, you can look at a string with this
function. There is a sample gdb.ini in appendix F. - Objects are difficult to handle, mainly because gdb is oriented
towards C and C++. The workaround implemented in Free Pascal is that object methods
are represented as functions, with an extra parameter this (all
lowercase !) The name of this function is a concatenation of the object type
and the function name, separated by two underscore characters.
For example, the method TPoint.Draw would be converted to
TPOINT__DRAW, and could be stopped at with
break TPOINT__DRAW
- Global overloaded functions confuse gdb because they have the same
name. Thus you cannot set a breakpoint at an overloaded function, unless you
know it's line number, in which case you can set a breakpoint at the
starting linenumber of the function.