[Lazarus] BreakIf
Henry Vermaak
henry.vermaak at gmail.com
Fri Mar 27 15:22:21 CET 2015
On Fri, Mar 27, 2015 at 01:45:31PM +0100, JuuS wrote:
> Good morning, all...
>
> >From my Delphi days we had the following procedure:
>
> procedure BreakIf( b : Boolean );
> begin
> if b then
> asm
> INT 3 <======debugger would then stop here
> and one could then F8 step to the offending
> routine based on the boolean condition passed
> end;
> end;
>
> I believe this is windows specific (?) and I'm now working on Linux
> machines.
On Windows you can use DebugBreak() instead of the asm.
> The question is:
>
> This does not work in Linux and I wonder if there is a similar way to
> achieve this in Linux environment?
To be more portable, you can send the SIGTRAP signal, just make sure
that your program ignores it so it doesn't die. Try this with/without
GDB:
program bp;
uses BaseUnix;
begin
FpSignal(SIGTRAP, signalhandler_t(SIG_IGN));
writeln('hi there');
FpKill(FpGetpid, SIGTRAP); { <-- breakpoint here }
writeln('exiting');
end.
Henry
More information about the Lazarus
mailing list