Bug 330734 - Inspecting nested STL containers
Summary: Inspecting nested STL containers
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: CPP Debugger (show other bugs)
Version: git master
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-04 08:00 UTC by Oleksandr Senkovych
Modified: 2014-02-06 09:44 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
How nested ontainers are displayed (75.20 KB, image/png)
2014-02-04 08:01 UTC, Oleksandr Senkovych
Details
Test case (340 bytes, text/x-c++src)
2014-02-04 10:22 UTC, Oleksandr Senkovych
Details
Fix (1.42 KB, patch)
2014-02-04 14:36 UTC, Oleksandr Senkovych
Details
Patch to fix the bug (1.37 KB, patch)
2014-02-04 14:40 UTC, Oleksandr Senkovych
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oleksandr Senkovych 2014-02-04 08:00:30 UTC
KDevelop cannot properly display nested STL containers with gdb pretty printers enabled, like vector<vector<>>, map<int, set<>> etc. 




Reproducible: Always
Comment 1 Oleksandr Senkovych 2014-02-04 08:01:06 UTC
Created attachment 84981 [details]
How nested ontainers are displayed
Comment 2 Oleksandr Senkovych 2014-02-04 08:02:18 UTC
Output of "info locals" command:

info locals
a = {b = {c = {x = 42}}}
x = std::vector of length 4, capacity 4 = {"1", "2", "3", "4"}
map = std::map with 1 elements = {[1] = std::vector of length 4, capacity 4 = {"1", "2", "3", "4"}}
Comment 3 Kevin Funk 2014-02-04 09:35:39 UTC
Please attach the source code in copy-able form for reference. 

But yes, I've also seen this. Looks like a limitation of GDB's MI mode (what we use in KDevelop to communicate with GDB).
Comment 4 Oleksandr Senkovych 2014-02-04 10:22:24 UTC
Created attachment 84986 [details]
Test case
Comment 5 Oleksandr Senkovych 2014-02-04 14:36:41 UTC
Created attachment 84990 [details]
Fix

Ok, the problem is that GDB MI shows no children for dynamic STL objects, it just add "dynamic" attribute to it.
Here is -var-list-children output for std::map< int, std::vector<std::string> > object:

SEND: "-var-list-children --thread 1 --frame 0 --all-values "var1" 0 5
kdevelop(20230)/kdevelop (gdb debugger) GDBDebugger::GDB::processLine: GDB output:  "^done,numchild="2",displayhint="map",children=[child={name="var1.[0]",exp="[0]",numchild="0",value="0",type="const int",thread-id="1"},child={name="var1.[1]",exp="[1]",numchild="0",value="{...}",type="std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >",thread-id="1",displayhint="array",dynamic="1"}],has_more="0""

As you see, the second variable, std::vector<std::string> has numchild="0", but dynamic="1". Proposed patch adds extra check for "dynamic" attribute in variables.
Comment 6 Oleksandr Senkovych 2014-02-04 14:40:53 UTC
Created attachment 84991 [details]
Patch to fix the bug

Oops, wrong second patch chunk :( Here is fixed one.
Comment 7 Milian Wolff 2014-02-04 14:54:56 UTC
Great, if that works I'll happily commit this for you. What's your full name so I can acknowledge you properly?
Comment 8 Oleksandr Senkovych 2014-02-04 16:07:07 UTC
Oleksandr Senkovych
Comment 9 Milian Wolff 2014-02-04 17:06:08 UTC
Git commit 751488d07f898545c7d43af0ef1906183a4d55c3 by Milian Wolff, on behalf of Oleksandr Senkovych.
Committed on 04/02/2014 at 17:04.
Pushed by mwolff into branch 'master'.

Fix inspecting of nested STL containers.

The problem is that GDB MI shows no children for dynamic STL objects,
it just add "dynamic" attribute to it. Here is -var-list-children
output for std::map< int, std::vector<std::string> > object:

SEND: "-var-list-children --thread 1 --frame 0 --all-values "var1" 0 5
kdevelop(20230)/kdevelop (gdb debugger) GDBDebugger::GDB::processLine:
GDB output:
"^done,numchild="2",displayhint="map",children=[child={name="var1.[0]",
exp="[0]",numchild="0",value="0",type="const int",thread-id="1"},
child={name="var1.[1]",exp="[1]",numchild="0",value="{...}",
type="std::vector<std::basic_string<char, std::char_traits<char>,
 std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >
> >",thread-id="1",displayhint="array",dynamic="1"}],has_more="0""

As you see, the second variable, std::vector<std::string> has
numchild="0", but dynamic="1". This patch adds extra check for
"dynamic" attribute in variables.

M  +4    -2    debuggers/gdb/gdbvariable.cpp

http://commits.kde.org/kdevelop/751488d07f898545c7d43af0ef1906183a4d55c3
Comment 10 Kevin Funk 2014-02-06 09:44:00 UTC
Git commit 8da1e659bb2fe2a14781d51949bec0942e5d3abe by Kevin Funk, on behalf of Oleksandr Senkovych.
Committed on 04/02/2014 at 17:04.
Pushed by kfunk into branch '4.6'.

Fix inspecting of nested STL containers.

The problem is that GDB MI shows no children for dynamic STL objects,
it just add "dynamic" attribute to it. Here is -var-list-children
output for std::map< int, std::vector<std::string> > object:

SEND: "-var-list-children --thread 1 --frame 0 --all-values "var1" 0 5
kdevelop(20230)/kdevelop (gdb debugger) GDBDebugger::GDB::processLine:
GDB output:
"^done,numchild="2",displayhint="map",children=[child={name="var1.[0]",
exp="[0]",numchild="0",value="0",type="const int",thread-id="1"},
child={name="var1.[1]",exp="[1]",numchild="0",value="{...}",
type="std::vector<std::basic_string<char, std::char_traits<char>,
 std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >
> >",thread-id="1",displayhint="array",dynamic="1"}],has_more="0""

As you see, the second variable, std::vector<std::string> has
numchild="0", but dynamic="1". This patch adds extra check for
"dynamic" attribute in variables.
(cherry picked from commit 751488d07f898545c7d43af0ef1906183a4d55c3)

M  +4    -2    debuggers/gdb/gdbvariable.cpp

http://commits.kde.org/kdevelop/8da1e659bb2fe2a14781d51949bec0942e5d3abe