Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-4019

gdb action "Watch expression" fails on 'this' and members

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Not Evaluated Not Evaluated
    • Qt Creator 2.3.0
    • Qt Creator 2.1.0
    • Debugger
    • None

      Consider the following code:

      #include <iostream>
      
      using namespace std;
      
      class A
      {
      public:
          A() : test(7) {}
          int test;
          void doSomething() const;
      };
      
      void A::doSomething() const
      {
          cout << test << endl;
      }
      
      int main()
      {
          A a;
          a.doSomething();
          return 0;
      }
      

      Put a breakpoint in doSomething(), and right-click on 'this' or 'test'. The first action in the menu is Watch Expression "(A)0xaddr" (or ((A)0xaddr).test).

      For some reason, this doesn't work for gdb. If I replace A with ::A it works.

      Why is it done with the address anyway? Why not just used the name (this, this->test)?

        1. address.log
          16 kB
        2. address.png
          address.png
          82 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            hjk hjk
            orgads Orgad Shaneh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes