Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Conditional breakpoints on QString value with GDB in Qt Creator.
QtWS25 Last Chance

Conditional breakpoints on QString value with GDB in Qt Creator.

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
bug-21133qtcreatorbug
10 Posts 3 Posters 8.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LScott
    wrote on last edited by koahnig
    #1

    Re: Breakpoint with QString Condition in QtCreator

    The problem referred to in the linked post still seems to exist.
    GDB/Creator gives no error about the condition, but for example:

    QString test = "Test Value";
    
    /*Breakpoint here*/ qDebug() << test;
    
    test = "Bananas";
    
    /*Breakpoint here*/ qDebug() << test;
    
    

    with both breakpoints having the following condition:

    test == "Bananas"
    

    In theory, the debugger should only break at the second breakpoint, however the condition seems to be ignored, and the debugger breaks at both breakpoints.

    Conditional breakpoints seem to work just fine with primitive types. Am I missing something? This seems like a fairly essential debugging feature.

    K JonBJ 2 Replies Last reply
    0
    • L LScott

      Re: Breakpoint with QString Condition in QtCreator

      The problem referred to in the linked post still seems to exist.
      GDB/Creator gives no error about the condition, but for example:

      QString test = "Test Value";
      
      /*Breakpoint here*/ qDebug() << test;
      
      test = "Bananas";
      
      /*Breakpoint here*/ qDebug() << test;
      
      

      with both breakpoints having the following condition:

      test == "Bananas"
      

      In theory, the debugger should only break at the second breakpoint, however the condition seems to be ignored, and the debugger breaks at both breakpoints.

      Conditional breakpoints seem to work just fine with primitive types. Am I missing something? This seems like a fairly essential debugging feature.

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @LScott

      You might be right that the problem is a bug and still exists. However, the other post does not relate to an entry to the bug reporting tool JIRA which is the only valid place for bug reporting. The forums are not monitored for possible bug reports.

      Did you check already on JIRA ?

      You find an entry there, please check status and provide a comment there. Otherwise file a bug report.

      Please also report the link to the bug report here.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      1
      • L LScott

        Re: Breakpoint with QString Condition in QtCreator

        The problem referred to in the linked post still seems to exist.
        GDB/Creator gives no error about the condition, but for example:

        QString test = "Test Value";
        
        /*Breakpoint here*/ qDebug() << test;
        
        test = "Bananas";
        
        /*Breakpoint here*/ qDebug() << test;
        
        

        with both breakpoints having the following condition:

        test == "Bananas"
        

        In theory, the debugger should only break at the second breakpoint, however the condition seems to be ignored, and the debugger breaks at both breakpoints.

        Conditional breakpoints seem to work just fine with primitive types. Am I missing something? This seems like a fairly essential debugging feature.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @LScott
        As a workaround, does the (GDB) condition accept a function call, say, strcmp() or similar, or a cast, you could put up with? I'm not sure Qt Creator debugger is claiming to offer much over whatever GDB will accept?

        L 1 Reply Last reply
        0
        • JonBJ JonB

          @LScott
          As a workaround, does the (GDB) condition accept a function call, say, strcmp() or similar, or a cast, you could put up with? I'm not sure Qt Creator debugger is claiming to offer much over whatever GDB will accept?

          L Offline
          L Offline
          LScott
          wrote on last edited by
          #4

          @JonB

          strcmp("Bananas", test.toLatin1().data()) == 0
          

          as the break condition works, with the exception that it will always break the first time the expression is evaluated, regardless of the result...

          After further investigation, the original expression:

          test == "Bananas"
          

          Does in fact work, but exhibits the same behaviour, where the breakpoint will always be hit the first time, regardless of the result of the expression... Adding to the 'ignore' count doesn't seem to affect this...

          Can anybody else replicate this behaviour? I feel like I must just be missing something obvious, otherwise this must indeed be a bug.

          K 1 Reply Last reply
          0
          • L LScott

            @JonB

            strcmp("Bananas", test.toLatin1().data()) == 0
            

            as the break condition works, with the exception that it will always break the first time the expression is evaluated, regardless of the result...

            After further investigation, the original expression:

            test == "Bananas"
            

            Does in fact work, but exhibits the same behaviour, where the breakpoint will always be hit the first time, regardless of the result of the expression... Adding to the 'ignore' count doesn't seem to affect this...

            Can anybody else replicate this behaviour? I feel like I must just be missing something obvious, otherwise this must indeed be a bug.

            K Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            @LScott

            I have played a bit around with MinGW pre-build Qt 5.4.2 and recent Qt creator.

            0_1537432952073_422991bf-87c4-4c80-9653-27a80e9efaf5-image.png

            and the breakpoint pane

            0_1537432992732_2fa049dd-dcb0-4906-9bb1-318824630cb2-image.png

            It stops always in all locations, but not in line 24 at all.

            Please advise, if I am doing something completely different.

            The breakpoints have been set with F9 and edited with this dialog
            0_1537433188441_16efb913-610b-49cc-83e2-625e41624f84-image.png

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • L Offline
              L Offline
              LScott
              wrote on last edited by
              #6

              When I run the same code with the same breakpoints, it breaks every time any breakpoint is hit, regardless of the value of 'tst'.

              0_1537466964392_65141903-a305-472a-98e6-f17e7c162a6a-image.png

              0_1537466985318_db8b6584-e657-4b72-9846-362a9f9d6390-image.png

              0_1537467005033_00d0a27b-68d5-4625-8eb2-e38f4961616a-image.png

              The behaviour seems inconsistent - I got it to kind of work as described further up, but now it doesn't seem to work again...

              For reference, I'm using g++ Qt 5.9.2 built from source on Debian 9.5 x32 i386, Qt Creator 4.4.82, also built from source (git).

              K 1 Reply Last reply
              0
              • L LScott

                When I run the same code with the same breakpoints, it breaks every time any breakpoint is hit, regardless of the value of 'tst'.

                0_1537466964392_65141903-a305-472a-98e6-f17e7c162a6a-image.png

                0_1537466985318_db8b6584-e657-4b72-9846-362a9f9d6390-image.png

                0_1537467005033_00d0a27b-68d5-4625-8eb2-e38f4961616a-image.png

                The behaviour seems inconsistent - I got it to kind of work as described further up, but now it doesn't seem to work again...

                For reference, I'm using g++ Qt 5.9.2 built from source on Debian 9.5 x32 i386, Qt Creator 4.4.82, also built from source (git).

                K Offline
                K Offline
                koahnig
                wrote on last edited by
                #7

                @LScott

                For reference in my case it is Windows 10 64 bit. Creator is 4.7.0

                I think you may want to check on JIRA as already suggested before. If nobody reports it, it will not be fixed. You reference this thread in the bug report and vice versa.

                Vote the answer(s) that helped you to solve your issue(s)

                L 1 Reply Last reply
                1
                • K koahnig

                  @LScott

                  For reference in my case it is Windows 10 64 bit. Creator is 4.7.0

                  I think you may want to check on JIRA as already suggested before. If nobody reports it, it will not be fixed. You reference this thread in the bug report and vice versa.

                  L Offline
                  L Offline
                  LScott
                  wrote on last edited by LScott
                  #8

                  @koahnig Okay, I've submitted a bug report, as suggested.

                  K 1 Reply Last reply
                  0
                  • L LScott

                    @koahnig Okay, I've submitted a bug report, as suggested.

                    K Offline
                    K Offline
                    koahnig
                    wrote on last edited by
                    #9

                    @LScott

                    OK, thanks. I have added a reference tothis thread. Let's see what happens.

                    Vote the answer(s) that helped you to solve your issue(s)

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      koahnig
                      wrote on last edited by
                      #10

                      The bug report has been closed already. Here the comment of the assignee:
                      1. QChar c; for(; c <= 'z'; ++c) does not compile.

                      2. What can be used in breakpoint conditioned is defined by what the underlying debugger (GDB here) is able to handle. It is not possible to have arbitrary C++ code there, specifically you cannot call functions that are not present in the binary, e.g. because they are inlined by the compiler or have not been used in the application code, so the linker had no reason to include it.

                      3. You can fiddle around with something along the lines of creating a breakpoint using gdb's python interface and a condition based on some translation of set $s = QString::toLatin1_helper(test) / set $p = $s.d.offset + (char)$s.d / strcmp($p, "d"), but that's not worth it as long as you can modify the code and put the condition in the code.*

                      Vote the answer(s) that helped you to solve your issue(s)

                      1 Reply Last reply
                      2

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved