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

Debugger does not show text representation for variables of type 'const gchar*' (or other char typedefs)

    XMLWordPrintable

Details

    • Linux/X11
    • 70c4889ac9a0d75c93809dd5bb321fcb2272a202 (qt-creator/qt-creator/master)

    Description

      Qt Creator nicely shows a text representation for variable values of type const char* (and similar) in its locals and expressions view. However, this is not the case for variables of type const gchar* (where gchar is a typedef for char in GLib) or other typedefs for various character types.

      Sample program:

      // compile:
      // g++ -g -O0 $(pkg-config --cflags glib-2.0) gchar_sample.cxx
      #include <iostream>
      #include <glib-2.0/glib.h>
      
      typedef char mychar;
      
      int main() {
      
      const char *str = "hello";
      const gchar *gstr = str;
      const mychar *mystr = str;
      
      std::cout << str << ", " << gstr << ", " << mystr << std::endl;
      
      return 0;
      
      };
      

       

      Steps to reproduce:

      1. set up a project in Qt Creator using above sample program
      2. set breakpoint at the line "return 0"
      3. start debugging
      4. check value displayed for the local variables

      Result:

      • str is shown as "hello" (OK)
      • For gstr, it only shows
        • the pointer's address if option "Dereference pointers automatically" is disabled)
        • type gchar and value "h" if option "Dereference pointers automatically" is enabled
      • same for mystr

      Expected result:

      The text representation "hello" should be used for all three local variables, just like e.g. command line GDB also does it:

      Breakpoint 1, main () at gchar_sample.cxx:19
      19
      (gdb) p str
      $1 = 0x555555556005 "hello"
      (gdb) p gstr
      $2 = (const gchar *) 0x555555556005 "hello"
      (gdb) p mystr
      $3 = (const mychar *) 0x555555556005 "hello"
       

       Notes:

      I plan to submit a patch to Gerrit that improves this.

      Attachments

        Activity

          People

            hjk hjk
            michaelweghorn Michael Weghorn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: