[next] [prev] [prev-tail] [tail] [up]

### 10.3 Caveats when debugging with gdb

There are some peculiarities of Free Pascal which you should be aware of when using gdb. We list the main ones here:

1. 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 its 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

2. gdb does not know sets.
3. 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.
4. 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

5. Global overloaded functions confuse gdb because they have the same name. Thus you cannot set a breakpoint at an overloaded function, unless you know its line number, in which case you can set a breakpoint at the starting linenumber of the function.

[next] [prev] [prev-tail] [front] [up]