[Lazarus] BreakIf

JuuS JuuS at mykolab.ch
Fri Mar 27 16:27:39 CET 2015



On 03/27/2015 03:22 PM, Henry Vermaak wrote:
> 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.

Super, thanks Henry, this also works, started the day with no breakif,
end up with several. Greatly appreciated.


> 


> Henry
> 
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
> 




More information about the Lazarus mailing list