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

Pretty-printing of std::string and other types broken

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • Qt Creator 4.10.1
    • Debugger
    • None
    • Arch Linux
      kernel: 5.3.7-arch1-1-ARCH
      g++ --version: g++ (GCC) 9.2.0
      gdb --version: GNU gdb (GDB) 8.3.1
      ldd --version: ldd (GNU libc) 2.30
      boost: 1.71.0-2
    • Linux/X11

    Description

      Since quite a while I noticed that I often cannot see data in the locals view. Such values are marked as "not accessible". Examples are std::string and boost::shared_ptr. Yesterday, I had a weird situation where I had a std::vector of boost::shared_ptr<SomeType> having entries in the vector which I could read and entries that were not accessible.

      Today, I exemplarily tried to investigate the problem for std::string (C++11). I have found that in /usr/share/qtcreator/debugger/stdtypes.py there is a function qdumpHelper_std__string which has some kind of assertion:

       

      d.check(0 <= size and size <= alloc and alloc <= 100*1000*1000)

      This raises an exception due to this condition

      alloc <= 100*1000*1000

       

      Removing this condition makes the string visible in QtCreator - however, with some garbage at the end.

      Some lines above this assertion there is this code:

       

      # We can't lookup the std::string::_Rep type without crashing LLDB,
      # so hard-code assumption on member position
      # struct { size_type _M_length, size_type _M_capacity, int _M_refcount; }
      (size, alloc, refcount) = d.split("ppp", data - 3 * d.ptrSize())

       

      Now, when I debug the very same program using raw GDB I get the following structure ('s' is a std::string) which does not seem to match the above assumption:

       

      (gdb) p/r s
      $2 = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, 
       _M_p = 0x7fffffffe2b0 "bla"}, _M_string_length = 3, {_M_local_buf = "bla\000\377\177\000\000dSUUUU\000", _M_allocated_capacity = 140733199772770}}

       

      Pretty-printing with GDB works:

       

      (gdb) p s
      $3 = "bla"

       

       

      What's also strange is that _M_allocated_capacity (see GDB output above) has such a large value. Hence, I am not entirely sure whether this is a QtCreator problem at all.

      Steps to reproduce:

      1. Download the attached files CMakeLists.txt and testme.cpp.
      2. Open QtCreator and load CMakeLists.txt as a project.
      3. Configure the project for debug mode.
      4. Add a command line argument for the program (e. g. "foo")
      5. Set a break point in line 5 of testme.cpp
      6. Run and debug
      7. See that 's' is marked <not accessible>

       

      Attachments

        1. CMakeLists.txt
          0.3 kB
        2. testme.cpp
          0.2 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              hjk hjk
              sedenion Dominik Neudert-Schulz
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes