Bug 470761 - Cannot inspect vector elements - GDB MI shows Duplicate variable object name error.
Summary: Cannot inspect vector elements - GDB MI shows Duplicate variable object name ...
Status: CLOSED NOT_ECLIPSE
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug (show other bugs)
Version: 8.6.0   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: cdt-debug-inbox@eclipse.org CLA
QA Contact: Doug Schaefer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-23 02:26 EDT by Jan Pohanka CLA
Modified: 2016-09-13 11:33 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Pohanka CLA 2015-06-23 02:26:23 EDT
I'm not sure whether it is problem of CDT or GDB, but following code causes problems to debugger. Using CDT 8.6 and gdb 7.9.1 on Archlinux I cannot inspect elemets of both vectors v and v2.

#include <vector>

using namespace std;

struct Test {
    int x;
    int y;
};

int main() {
	vector<shared_ptr<Test>> v;

	v.push_back(make_shared<Test>());
	v.push_back(make_shared<Test>());

	auto v2 = v;

	for (size_t i = 0; i < v.size(); i++)
	    v[i]->x = i;

	return 0;
}

I was not able to isolate single line or declaration that causes problems, it appear in many variants of such code.
Gdb traces follows...


223,700 73-stack-list-locals --thread 1 --frame 0 1
223,703 73^done,locals=[{name="i",value="4196992"},{name="v",value="std::vector of length 2, capacit\
y 2 = {std::shared_ptr (count 2, weak 0) 0x616c30, std::shared_ptr (count 2, weak 0) 0x616c70}"},{na\
me="v2",value="std::vector of length 2, capacity 2 = {std::shared_ptr (count 2, weak 0) 0x616c30, st\
d::shared_ptr (count 2, weak 0) 0x616c70}"}]
223,703 (gdb) 
223,706 74-stack-info-depth --thread 1 11
223,706 74^done,depth="1"
223,707 (gdb) 
223,756 75-stack-info-depth --thread 1
223,757 75^done,depth="1"
223,757 (gdb) 
223,757 76-var-create --thread 1 --frame 0 - * i
223,758 77-var-update 1 var1
223,758 78-var-update 1 var2
223,758 76^done,name="var3",numchild="0",value="4196992",type="size_t",thread-id="1",has_more="0"
223,758 (gdb) 
223,768 77^error,msg="Duplicate variable object name"
223,768 (gdb) 
223,772 79-thread-info 1
223,772 80-list-thread-groups
223,778 78^error,msg="Duplicate variable object name"
223,778 (gdb) 
223,778 79^done,threads=[{id="1",target-id="process 28990",name="test",frame={level="0",addr="0x0000\
000000400d0c",func="main",args=[],file="../src/test.cpp",fullname="/home/work/dev/work_test/test/src\
/test.cpp",line="20"},state="stopped",core="2"}]
223,778 (gdb) 
223,778 80^done,groups=[{id="i1",type="process",pid="28990",executable="/home/work/dev/work_test/tes\
t/Debug/test",cores=["2"]}]
223,779 (gdb) 
223,779 81-var-list-children var2 0 1
223,779 81^error,msg="Duplicate variable object name"
223,779 (gdb)
Comment 1 Marc Khouzam CLA 2015-06-23 13:28:48 EDT
(In reply to Jan Pohanka from comment #0)
 
> 223,779 81-var-list-children var2 0 1
> 223,779 81^error,msg="Duplicate variable object name"

CDT does not assign the name of variable objects but requests GDB to do so.  It looks here like GDB is re-using a name that has already been assigned.

I've opened a GDB bug about this:
https://sourceware.org/bugzilla/show_bug.cgi?id=18584