How to set breakpoint conditions in CLion
up vote
0
down vote
favorite
I am having some problems with a C application. I am writing in CLion
(windows) and I have a for
loop from 1 to 1000
but at some point around i = 600
the code inside the loop returns something wrong.
At this point, I am not interested in why there is this problem but in how to find it so I tried to debug the application but it is impossible to hit F7
600 times.
So is there any way that I can start debugging when I get to let's say 590?
c debugging clion
New contributor
add a comment |
up vote
0
down vote
favorite
I am having some problems with a C application. I am writing in CLion
(windows) and I have a for
loop from 1 to 1000
but at some point around i = 600
the code inside the loop returns something wrong.
At this point, I am not interested in why there is this problem but in how to find it so I tried to debug the application but it is impossible to hit F7
600 times.
So is there any way that I can start debugging when I get to let's say 590?
c debugging clion
New contributor
Did you try reading the documentation?
– fredrik
Nov 19 at 12:18
@fredrik Yes I did but it is unclear to me the way the condition has to be syntaxed. I tried i=590 but it did not work.
– Kyriafinis Bill
Nov 19 at 12:31
Thank you for posting a question. Please include a main() function and provide a Compilable, Minimal, Complete, and Verifiable Example. This helps us help you. If you can make your problem as simple as possible while still creating the failure, it will help us isolate the issues that will make your code work correctly. It is easier to respond to questions with code.
– John Murray
yesterday
The conditional would have to bei == 590
. Because thei=590
would make an assignment rather than a comparison and no break would happen.
– John Murray
yesterday
@JohnMurray The actual code is too complicated (the code in separated in different files etc) so it is a bit difficult to simplify it. Although makingi == 590
worked so my problem is solved.
– Kyriafinis Bill
yesterday
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am having some problems with a C application. I am writing in CLion
(windows) and I have a for
loop from 1 to 1000
but at some point around i = 600
the code inside the loop returns something wrong.
At this point, I am not interested in why there is this problem but in how to find it so I tried to debug the application but it is impossible to hit F7
600 times.
So is there any way that I can start debugging when I get to let's say 590?
c debugging clion
New contributor
I am having some problems with a C application. I am writing in CLion
(windows) and I have a for
loop from 1 to 1000
but at some point around i = 600
the code inside the loop returns something wrong.
At this point, I am not interested in why there is this problem but in how to find it so I tried to debug the application but it is impossible to hit F7
600 times.
So is there any way that I can start debugging when I get to let's say 590?
c debugging clion
c debugging clion
New contributor
New contributor
edited Nov 19 at 12:24
bcperth
2,0021514
2,0021514
New contributor
asked Nov 19 at 12:12
Kyriafinis Bill
34
34
New contributor
New contributor
Did you try reading the documentation?
– fredrik
Nov 19 at 12:18
@fredrik Yes I did but it is unclear to me the way the condition has to be syntaxed. I tried i=590 but it did not work.
– Kyriafinis Bill
Nov 19 at 12:31
Thank you for posting a question. Please include a main() function and provide a Compilable, Minimal, Complete, and Verifiable Example. This helps us help you. If you can make your problem as simple as possible while still creating the failure, it will help us isolate the issues that will make your code work correctly. It is easier to respond to questions with code.
– John Murray
yesterday
The conditional would have to bei == 590
. Because thei=590
would make an assignment rather than a comparison and no break would happen.
– John Murray
yesterday
@JohnMurray The actual code is too complicated (the code in separated in different files etc) so it is a bit difficult to simplify it. Although makingi == 590
worked so my problem is solved.
– Kyriafinis Bill
yesterday
add a comment |
Did you try reading the documentation?
– fredrik
Nov 19 at 12:18
@fredrik Yes I did but it is unclear to me the way the condition has to be syntaxed. I tried i=590 but it did not work.
– Kyriafinis Bill
Nov 19 at 12:31
Thank you for posting a question. Please include a main() function and provide a Compilable, Minimal, Complete, and Verifiable Example. This helps us help you. If you can make your problem as simple as possible while still creating the failure, it will help us isolate the issues that will make your code work correctly. It is easier to respond to questions with code.
– John Murray
yesterday
The conditional would have to bei == 590
. Because thei=590
would make an assignment rather than a comparison and no break would happen.
– John Murray
yesterday
@JohnMurray The actual code is too complicated (the code in separated in different files etc) so it is a bit difficult to simplify it. Although makingi == 590
worked so my problem is solved.
– Kyriafinis Bill
yesterday
Did you try reading the documentation?
– fredrik
Nov 19 at 12:18
Did you try reading the documentation?
– fredrik
Nov 19 at 12:18
@fredrik Yes I did but it is unclear to me the way the condition has to be syntaxed. I tried i=590 but it did not work.
– Kyriafinis Bill
Nov 19 at 12:31
@fredrik Yes I did but it is unclear to me the way the condition has to be syntaxed. I tried i=590 but it did not work.
– Kyriafinis Bill
Nov 19 at 12:31
Thank you for posting a question. Please include a main() function and provide a Compilable, Minimal, Complete, and Verifiable Example. This helps us help you. If you can make your problem as simple as possible while still creating the failure, it will help us isolate the issues that will make your code work correctly. It is easier to respond to questions with code.
– John Murray
yesterday
Thank you for posting a question. Please include a main() function and provide a Compilable, Minimal, Complete, and Verifiable Example. This helps us help you. If you can make your problem as simple as possible while still creating the failure, it will help us isolate the issues that will make your code work correctly. It is easier to respond to questions with code.
– John Murray
yesterday
The conditional would have to be
i == 590
. Because the i=590
would make an assignment rather than a comparison and no break would happen.– John Murray
yesterday
The conditional would have to be
i == 590
. Because the i=590
would make an assignment rather than a comparison and no break would happen.– John Murray
yesterday
@JohnMurray The actual code is too complicated (the code in separated in different files etc) so it is a bit difficult to simplify it. Although making
i == 590
worked so my problem is solved.– Kyriafinis Bill
yesterday
@JohnMurray The actual code is too complicated (the code in separated in different files etc) so it is a bit difficult to simplify it. Although making
i == 590
worked so my problem is solved.– Kyriafinis Bill
yesterday
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
CLion allows you to set a conditional breakpoint. Consider the code below which will exhibit bad behavior on loop 601 as it runs off the end of the array.
To catch this, set a breakpoint on the line where the assignment is being made.
Then, right click on the breakpoint and add the following to the conditional box in the dialog:
i == 599
Then, run the code, and the debugger will stop at the breakpoint only when i == 599. It's magical!
#include <stdio.h>
int main()
{
char array[600];
for (int i = 0; i < 1000; i++) {
// code that does something
array[i] = 0xff; // set breakpoint here!
//, then right click and add conditional: i == 590
}
printf("Hello, World!n");
return 0;
}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
CLion allows you to set a conditional breakpoint. Consider the code below which will exhibit bad behavior on loop 601 as it runs off the end of the array.
To catch this, set a breakpoint on the line where the assignment is being made.
Then, right click on the breakpoint and add the following to the conditional box in the dialog:
i == 599
Then, run the code, and the debugger will stop at the breakpoint only when i == 599. It's magical!
#include <stdio.h>
int main()
{
char array[600];
for (int i = 0; i < 1000; i++) {
// code that does something
array[i] = 0xff; // set breakpoint here!
//, then right click and add conditional: i == 590
}
printf("Hello, World!n");
return 0;
}
add a comment |
up vote
0
down vote
accepted
CLion allows you to set a conditional breakpoint. Consider the code below which will exhibit bad behavior on loop 601 as it runs off the end of the array.
To catch this, set a breakpoint on the line where the assignment is being made.
Then, right click on the breakpoint and add the following to the conditional box in the dialog:
i == 599
Then, run the code, and the debugger will stop at the breakpoint only when i == 599. It's magical!
#include <stdio.h>
int main()
{
char array[600];
for (int i = 0; i < 1000; i++) {
// code that does something
array[i] = 0xff; // set breakpoint here!
//, then right click and add conditional: i == 590
}
printf("Hello, World!n");
return 0;
}
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
CLion allows you to set a conditional breakpoint. Consider the code below which will exhibit bad behavior on loop 601 as it runs off the end of the array.
To catch this, set a breakpoint on the line where the assignment is being made.
Then, right click on the breakpoint and add the following to the conditional box in the dialog:
i == 599
Then, run the code, and the debugger will stop at the breakpoint only when i == 599. It's magical!
#include <stdio.h>
int main()
{
char array[600];
for (int i = 0; i < 1000; i++) {
// code that does something
array[i] = 0xff; // set breakpoint here!
//, then right click and add conditional: i == 590
}
printf("Hello, World!n");
return 0;
}
CLion allows you to set a conditional breakpoint. Consider the code below which will exhibit bad behavior on loop 601 as it runs off the end of the array.
To catch this, set a breakpoint on the line where the assignment is being made.
Then, right click on the breakpoint and add the following to the conditional box in the dialog:
i == 599
Then, run the code, and the debugger will stop at the breakpoint only when i == 599. It's magical!
#include <stdio.h>
int main()
{
char array[600];
for (int i = 0; i < 1000; i++) {
// code that does something
array[i] = 0xff; // set breakpoint here!
//, then right click and add conditional: i == 590
}
printf("Hello, World!n");
return 0;
}
answered yesterday
John Murray
697514
697514
add a comment |
add a comment |
Kyriafinis Bill is a new contributor. Be nice, and check out our Code of Conduct.
Kyriafinis Bill is a new contributor. Be nice, and check out our Code of Conduct.
Kyriafinis Bill is a new contributor. Be nice, and check out our Code of Conduct.
Kyriafinis Bill is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374394%2fhow-to-set-breakpoint-conditions-in-clion%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you try reading the documentation?
– fredrik
Nov 19 at 12:18
@fredrik Yes I did but it is unclear to me the way the condition has to be syntaxed. I tried i=590 but it did not work.
– Kyriafinis Bill
Nov 19 at 12:31
Thank you for posting a question. Please include a main() function and provide a Compilable, Minimal, Complete, and Verifiable Example. This helps us help you. If you can make your problem as simple as possible while still creating the failure, it will help us isolate the issues that will make your code work correctly. It is easier to respond to questions with code.
– John Murray
yesterday
The conditional would have to be
i == 590
. Because thei=590
would make an assignment rather than a comparison and no break would happen.– John Murray
yesterday
@JohnMurray The actual code is too complicated (the code in separated in different files etc) so it is a bit difficult to simplify it. Although making
i == 590
worked so my problem is solved.– Kyriafinis Bill
yesterday