How to set breakpoint conditions in CLion












0















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

























  • Did you try reading the documentation?

    – fredrik
    Nov 19 '18 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 '18 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
    Nov 21 '18 at 1:18











  • 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
    Nov 21 '18 at 1:37











  • @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
    Nov 21 '18 at 14:27
















0















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

























  • Did you try reading the documentation?

    – fredrik
    Nov 19 '18 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 '18 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
    Nov 21 '18 at 1:18











  • 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
    Nov 21 '18 at 1:37











  • @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
    Nov 21 '18 at 14:27














0












0








0


0






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
















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















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 12:24









bcperth

2,0121614




2,0121614










asked Nov 19 '18 at 12:12









Kyriafinis BillKyriafinis Bill

299




299













  • Did you try reading the documentation?

    – fredrik
    Nov 19 '18 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 '18 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
    Nov 21 '18 at 1:18











  • 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
    Nov 21 '18 at 1:37











  • @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
    Nov 21 '18 at 14:27



















  • Did you try reading the documentation?

    – fredrik
    Nov 19 '18 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 '18 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
    Nov 21 '18 at 1:18











  • 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
    Nov 21 '18 at 1:37











  • @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
    Nov 21 '18 at 14:27

















Did you try reading the documentation?

– fredrik
Nov 19 '18 at 12:18





Did you try reading the documentation?

– fredrik
Nov 19 '18 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 '18 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 '18 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
Nov 21 '18 at 1:18





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
Nov 21 '18 at 1:18













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
Nov 21 '18 at 1:37





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
Nov 21 '18 at 1:37













@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
Nov 21 '18 at 14:27





@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
Nov 21 '18 at 14:27












1 Answer
1






active

oldest

votes


















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







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',
    autoActivateHeartbeat: false,
    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
    });


    }
    });














    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









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







    share|improve this answer




























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







      share|improve this answer


























        0












        0








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







        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 Nov 21 '18 at 1:35









        John MurrayJohn Murray

        809514




        809514






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            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

            Guess what letter conforming each word

            Port of Spain

            Run scheduled task as local user group (not BUILTIN)