[Lazarus] Conditional Debugger breakpoints not working ?

Michael Van Canneyt michael at freepascal.org
Mon Feb 20 12:31:15 CET 2023


I'm trying to set a condition on a breakpoint.

I have a local variable aUnit, type string:

   aUnit : string;

I wish the breakpoint is only triggered when aUnit equals 'termio'.

So, in the breakpoint properties dialog, I enter the condition:


It seems to have no effect whatsoever. The breakpoint is triggered always at
the first traversal of the line.

I tried variations (uppercase, lowercase) , but to no avail.

Looking at the debug internals window, I see that the expression is
only (correctly) evaluated by gdb when I move the mouse over the identifier
in the sources:

<ptype AUNIT>
&"ptype AUNIT\n"
~"type = ^Char\n"
<ptype AUNIT^>
&"ptype AUNIT^\n"
~"type = Char\n"
<whatis AUNIT>
&"whatis AUNIT\n"
~"type = ANSISTRING\n"
<-data-evaluate-expression AUNIT>
^done,value="0x7ffff7f73b18 'si_prc'"

So it can correctly evaluate the value aUnit. 
The question is, why is it ignoring my condition ?

After some digging in the gdb output I find this:

&"Error in testing breakpoint condition:\n"
&"evaluation of this expression requires the program to have a function \"malloc\".\n"

Hm. No mention of this in:


OK, File under 'undocumented' and ignore for the time being, but I add cmem unit
to my program.

Seemingly, gdb now accepts the breakpoint condition:

<-break-insert  "\"/home/michael/domakefile.lpr\":161">
<-break-condition 7 AUNIT="termio">
<-break-enable 7>

That makes it even worse: the breakpoint is simply never observed.

If I do a poor man's conditional breakpoint:

   if (aUnit='termio') then
     Writeln('Aloha'); <-- set breakpoint on this line

and run, I see that unit 'termio' is definitely encountered.

So, "Houston, we have a problem..."

Suggestions, things I maybe forgot ?


More information about the lazarus mailing list