[fpc-devel] Conditional Breakpoints using FPC and GDB

Jonas Maebe jonas.maebe at elis.ugent.be
Fri Aug 13 15:35:17 CEST 2010


On 13 Aug 2010, at 14:52, Graeme Geldenhuys wrote:

> Op 2010-08-13 14:46, Jonas Maebe het geskryf:
>>
>> Programming them in Pascal code that is linked into the target  
>> program
>> moreover has the advantage that GDB (or any other debugger, even one
>
> Do you have any web link on how to do this, or a small single case  
> example
> that could be built on to?  I don't mind working on this, I just don't
> really know how or what is required - and thus where to start.


{ the "export" is so the compiler uses C-style name mangling, which is  
required to get predictable function names in the machine code }
function debugger_compare_ansistr(const a1,a2: ansistring): longint;  
cdecl; export;
begin
   result:=SysUtils.AnsiCompareStr(a1,a2);
end;


procedure debugger_assign_ansistr(var dest: ansistring; const src:  
ansistring); cdecl; export;
begin
   dest:=src;
end;

...

Create such routines for any operation on any type that GDB cannot  
handle directly (assigning, comparing, printing, modifying, ...). You  
can probably even add support for properties via RTTI lookups this way.

One main rule I can think of: parameters of automated types *must* all  
be either "var" or "const" parameters (because otherwise the caller  
side has to call special routines prior to invoking the helper, which  
the debugger won't do).

After this unit is implemented, debugger frontends will obviously  
still need to get support for calling these helpers whenever they  
detect that types are involved in expressions.


Jonas



More information about the fpc-devel mailing list