Breakpoint condition: variable content

General questions regarding the usage of CodeLite
codemonster
CodeLite Enthusiast
Posts: 31
Joined: Tue Feb 26, 2019 12:50 am
Genuine User: Yes
IDE Question: C++
Contact:

Breakpoint condition: variable content

Post by codemonster »

Hello,
is it passible to set a breakpoint dependent on the value of a variable?

Thanks
DavidGH
CodeLite Plugin
Posts: 819
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

Re: Breakpoint condition: variable content

Post by DavidGH »

Hi,
is it possible to set a breakpoint dependent on the value of a variable?
Yes, of course; that's the sort of thing that Conditional Breakpoints do. See this (rather outdated) wiki page; the bottom picture shows the 'Create a Breakpoint or Watchpoint' dialog. In its Conditional Breaks field you can set any sensible expression e.g.
n>6
or
baz=="foobar"

Regards,

David
codemonster
CodeLite Enthusiast
Posts: 31
Joined: Tue Feb 26, 2019 12:50 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Breakpoint condition: variable content

Post by codemonster »

Hello,
yes, but it works strange:

Code: Select all

#include <iostream>
// Testprogram

int main()
{
    int x{ 1 };
    while (x++ < 8){
        std::cout << "x=" << x << std::endl;
        std::cout << "------" << std::endl;
    }
    return 0;
}
breakpoint in line 9 with condition: x=5

start/continue Debugger

Output (Terminal Settings = CMD):
x=2

then program stops

next command of me

Output next…... next:
-------
x=6
------
x=6
.......
DavidGH
CodeLite Plugin
Posts: 819
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

Re: Breakpoint condition: variable content

Post by DavidGH »

breakpoint in line 9 with condition: x=5
Perhaps the condition should be:
x==5
codemonster
CodeLite Enthusiast
Posts: 31
Joined: Tue Feb 26, 2019 12:50 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Breakpoint condition: variable content

Post by codemonster »

Thanks, that was the solution!
Post Reply