Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-03

Conditional Breakpoints - are they supported yet?

10 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

I remember a couple of years back I asked this question, but then it wasn't implemented yet. Is this functional yet? I see the wiki page for that dialog mentions it, so it seems to be possible.

http://wiki.lazarus.freepascal.org/IDE_Window:_Break_Points#Breakpoint_properties

But how do I use it?

eg: I set a breakpoint, then adjust it's properties and add the condition: ActualTag = '<h1>'

I also tried
ActualTag = "<h1>"

  ActualTag := '<h1>'
  ActualTag := '<h1>';
  etc.

None of them worked. The breakpoint acted like a normal breakpoint and stopped execution no matter what the value is of ActualTag variable.

I know the wiki set simple expressions/conditions, and thought the above is as basic as you can get. Any additional info on this topic?

I'm using Lazarus 1.3 r46051 FPC 2.6.4 x86_64-freebsd-gtk 2 with GDB 7.8.1

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Martin Frb
to Graeme Geldenhuys
Graeme Geldenhuys wrote 28 lines
Hi, I remember a couple of years back I asked this question, but then it wasn't implemented yet. Is this functional yet? I see the wiki page for that dialog mentions it, so it seems to be possible. http://wiki.lazarus.freepascal.org/IDE_Window:_Break_Points#Breakpoint_properties But how do I use it? eg: I set a breakpoint, then adjust it's properties and add the condition: ActualTag = '<h1>' I also tried ActualTag = "<h1>" ActualTag := '<h1>' ActualTag := '<h1>'; etc. None of them worked. The breakpoint acted like a normal breakpoint and stopped execution no matter what the value is of ActualTag variable. I know the wiki set simple expressions/conditions, and thought the above is as basic as you can get. Any additional info on this topic? I'm using Lazarus 1.3 r46051 FPC 2.6.4 x86_64-freebsd-gtk 2 with GDB 7.8.1

Interesting, for me using a condition on string, the condition is never true, so it never stops.

It is something to do what gdb sees as the actual value. (Unlike watches, the IDE does not apply any pascal syntax fixing to the condition. I tested with an integer "i=2" that works.

And on top of all your mail just made me realize that string literals are broken. They get uppercased, because of a gdb bug, where class members are only found if they are uppercase and the ide simple fixes that by uppercasing all. That affect watches too.

Reply by email

Martin Frb
to Martin Frb
Martin Frb wrote 25 lines
On 05/03/2015 20:11, Graeme Geldenhuys wrote: > > eg: I set a breakpoint, then adjust it's properties and add the > condition: ActualTag = '<h1>' > > I also tried > ActualTag = "<h1>" > ActualTag := '<h1>' > ActualTag := '<h1>'; > etc. > > Interesting, for me using a condition on string, the condition is never true, so it never stops. It is something to do what gdb sees as the actual value. (Unlike watches, the IDE does not apply any pascal syntax fixing to the condition. I tested with an integer "i=2" that works. And on top of all your mail just made me realize that string literals are broken. They get uppercased, because of a gdb bug, where class members are only found if they are uppercase and the ide simple fixes that by uppercasing all. That affect watches too.

Just tested, condition on strings are not possible.

gdb see the string as pointer, and compares the address. This condition would work (if you have the desired address) str=0x5a0b40

Reply by email

Graeme Geldenhuys
to Martin Frb
Martin Frb wrote 5 lines
Just tested, condition on strings are not possible. gdb see the string as pointer, and compares the address. This condition would work (if you have the desired address) str=0x5a0b40

Thanks for testing and the info.

I'm about to test, but first need to update my Lazaurs. Would any of this be fixable/possible via the fpdebuger? Surely we shouldn't have the same problems as GDB - the whole reason of creating fpdebug? Or is conditional breakpoints something not yet implemented in fpdebug?

[couldn't resist - and no reflection on your hard work Martin] Now anybody still wondering why I am so pro CodeSite and other "logging debuggers". Having multiple debug options is always a bonus for us developers.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Martin Frb
to Graeme Geldenhuys
Graeme Geldenhuys wrote 12 lines
On 2015-03-05 21:26, Martin Frb wrote: > Just tested, condition on strings are not possible. > > gdb see the string as pointer, and compares the address. > This condition would work (if you have the desired address) > str=0x5a0b40 Thanks for testing and the info. I'm about to test, but first need to update my Lazaurs. Would any of this be fixable/possible via the fpdebuger? Surely we shouldn't have the same problems as GDB - the whole reason of creating fpdebug? Or is conditional breakpoints something not yet implemented in fpdebug?

fixable: yes.

Not sure if conditions are implemented at all in fpdebug yet.

And also there is still prenty of work on expressions. that is watches are currently identifier only. Most operators have yet to be implemented. But once they are it should work.

-------------------
Theoretical in gdb it should be possible (zero based!!!) (s[0]='<')and(s[1]='a')and(....)

But it does not work due to an bug in the IDE part.

Reply by email

Martin Frb
to Martin Frb
Martin Frb wrote
Theoretical in gdb it should be possible (zero based!!!) (s[0]='<')and(s[1]='a')and(....)

Fixed (I hope). You can now compare chars in the condition (chars, not strings)

Its a crude workaround, but it works.

remember that strings are (in stabs and dwarf2) just pchar. Therefore zero based.

Reply by email

Graeme Geldenhuys
to Martin Frb
Martin Frb wrote
Fixed (I hope). You can now compare chars in the condition (chars, not strings)

Hi Martin, thanks for trying, but it still doesn't work. Just got the latest Lazarus from trunk a few minutes ago. See attached screenshot. Compare the breakpoint condition (comparing chars only) to the local variable value. The breakpoint always breaks no matter the condition.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ -------------- next part -------------- A non-text attachment was scrubbed... Name: Untitled.png Type: image/png Size: 10750 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150306/566c27bb/attachment.png>

Reply by email

Martin Frb
to Graeme Geldenhuys
Graeme Geldenhuys wrote 8 lines
On 2015-03-06 00:37, Martin Frb wrote: > Fixed (I hope). You can now compare chars in the condition (chars, not > strings) Hi Martin, thanks for trying, but it still doesn't work. Just got the latest Lazarus from trunk a few minutes ago. See attached screenshot. Compare the breakpoint condition (comparing chars only) to the local variable value. The breakpoint always breaks no matter the condition.

You need single quotes as in my example. Double quotes make it a string to gdb, and gdb does not compare string to char.

Also I have not tested if it works with spaces, I tested only with no spaces at all

If the problem persists:
- See if the condition works if entered as a watch.
- Copy and pashe from the "debug output" window

I did test using dwarf2 (withSets). No idea about stabs.

I might do more complete tests at some point...

Reply by email

Graeme Geldenhuys
to Graeme Geldenhuys: Hi Martin, thanks for trying, but it still doesn't work. Just got the latest Lazarus from…
Graeme Geldenhuys wrote
variable value. The breakpoint always breaks no matter the condition.

Ah, found my problem - I'm getting mixed up between Lazarus IDE and MSEide syntax behaviours I think. I had to change my condition to use single quotes around the char values. Now it breaks on the specific condition only.
eg:
(ActualTag[0]='<') and (ActualTag[1]='h') and (ActualTag[2]='1')

Martin Schreiber gave me a quick workaround solution for MSEide, which works for Lazarus too. Simply use the following code, and remove when you are done debugging. Keeping to the same "testvar" name, means you can quickly search for the debug code and remove it when done (or just use 'git reset').

"
var
 testvar: integer;
[...]
if SomeVariable = 'some text' then begin
 testvar:= 0; //<<<--- set a breakpoint here
end;
"

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Graeme Geldenhuys
to Martin Frb: You need single quotes as in my example. Double quotes make it a string to gdb, and gdb…
Martin Frb wrote
Also I have not tested if it works with spaces, I tested only with no spaces at all

Spaces don't seem to be a problem in the condition. I just tested with the following condition and it worked too.

(ActualTag[0] = '<') and (ActualTag[1] = 'h') and (ActualTag[2] = '1')

Thanks again for the prompt replies and support. It is much appreciated.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email