Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
Qt Creator 4.10.1
-
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
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:
- Download the attached files CMakeLists.txt and testme.cpp.
- Open QtCreator and load CMakeLists.txt as a project.
- Configure the project for debug mode.
- Add a command line argument for the program (e. g. "foo")
- Set a break point in line 5 of testme.cpp
- Run and debug
- See that 's' is marked <not accessible>
Attachments
Issue Links
- duplicates
-
QTCREATORBUG-22753 GCC-9 compiler results in std::string being shown as "<not accessible>" in debugger
-
- Closed
-
- is duplicated by
-
QTCREATORBUG-22780 Unable to see value of std::string in the debugger
-
- Closed
-