Summary: | Inspecting nested STL containers | ||
---|---|---|---|
Product: | [Applications] kdevelop | Reporter: | Oleksandr Senkovych <bjsenya> |
Component: | CPP Debugger | Assignee: | kdevelop-bugs-null |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | kfunk, niko.sams |
Priority: | NOR | ||
Version: | git master | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | http://commits.kde.org/kdevelop/8da1e659bb2fe2a14781d51949bec0942e5d3abe | Version Fixed In: | |
Sentry Crash Report: | |||
Attachments: |
How nested ontainers are displayed
Test case Fix Patch to fix the bug |
Description
Oleksandr Senkovych
2014-02-04 08:00:30 UTC
Created attachment 84981 [details]
How nested ontainers are displayed
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"}} 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). Created attachment 84986 [details]
Test case
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.
Created attachment 84991 [details]
Patch to fix the bug
Oops, wrong second patch chunk :( Here is fixed one.
Great, if that works I'll happily commit this for you. What's your full name so I can acknowledge you properly? Oleksandr Senkovych 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 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 |