[Lazarus] BreakIf

JuuS JuuS at mykolab.ch
Fri Mar 27 15:06:57 CET 2015



On 03/27/2015 02:50 PM, Sven Barth wrote:
> Am 27.03.2015 14:32 schrieb "JuuS" <JuuS at mykolab.ch
> <mailto:JuuS at mykolab.ch>>:
>>
>>
>>
>> On 03/27/2015 02:17 PM, Joost van der Sluis wrote:
>> > On 03/27/2015 01:45 PM, JuuS wrote:
>> >> 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.
>> >>
>> >> The question is:
>> >>
>> >> This does not work in Linux and I wonder if there is a similar way to
>> >> achieve this in Linux environment?
>> >
>> > Wow.. that's a nasty trick....
>>
>> Mmmm, nasty maybe...but cool! Just tried it again and it won't compile
>> "INT 3" line because "invalid reference syntax".
> 
> You need to write either "INT $3" or switch the assembler syntax to
> Intel ({$asmmode intel}) as the default one is AT&T on Linux.
> 

Awesome. It works! I have no idea about assembler and had no clue about
this syntax, my breakif code came from a windows environment.

It does raise a "SIGTRAP" message in the IDE which must be dealt with
but I can live with this (though ideas to suppress it appreciated).

Thanks Sven. (I will still look into the other stuff as time permits
Giuliano).

It's nice to have this back for when I really need it.

> Please note that INT 3 is specific to x86 (and will likely also work on
> x86_64), but for other architectures you'll need to look up their
> specific breakpoint sequences.
> 
> Please state beforehand next time whether you can't compile or can't
> run. We have no crystal balls after all...

I came into Lazarus about a year ago, that's when I tested breakif and
it failed and that was all I remembered. Had no idea of the Lazarus
mailing list at that time and only today was thinking about it again.
Will do my utmost to be more proactive next time.

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




More information about the Lazarus mailing list