[Lazarus] Conditional Debugger breakpoints not working ?

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


Hi,

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

I have a local variable aUnit, type string:

var
   aUnit : string;

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

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

aUnit='termio'

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:

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

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:

https://wiki.lazarus.freepascal.org/Debugger_Setup
https://wiki.lazarus.freepascal.org/IDE_Window:_Breakpoints#Breakpoint_properties

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">
^done,bkpt={number="7",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000401fe7",func="ADDRECIPE",file="domakefile.lpr",fullname="/home/michael/domakefile.lpr",line="161",thread-groups=["i1"],times="0",original-location="/home/michael/domakefile.lpr:161"}
(gdb) 
<-break-condition 7 AUNIT="termio">
^done
(gdb) 
<-break-enable 7>
^done

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 ?

Michael.


More information about the lazarus mailing list