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?










share|improve this question









New contributor




Kyriafinis Bill is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • 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 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















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?










share|improve this question









New contributor




Kyriafinis Bill is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • 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 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













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?










share|improve this question









New contributor




Kyriafinis Bill is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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






share|improve this question









New contributor




Kyriafinis Bill is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Kyriafinis Bill is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 19 at 12:24









bcperth

2,0021514




2,0021514






New contributor




Kyriafinis Bill is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 19 at 12:12









Kyriafinis Bill

34




34




New contributor




Kyriafinis Bill is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Kyriafinis Bill is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Kyriafinis Bill is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • 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 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


















  • 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 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
















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












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;
}







share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Kyriafinis Bill is a new contributor. Be nice, and check out our Code of Conduct.










     

    draft saved


    draft discarded


















    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

























    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;
    }







    share|improve this answer

























      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;
      }







      share|improve this answer























        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;
        }







        share|improve this answer












        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;
        }








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        John Murray

        697514




        697514






















            Kyriafinis Bill is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            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.















             


            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

            Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

            A Topological Invariant for $pi_3(U(n))$