I had all sorts of trouble with a test C++ program containing vectors of vectors and various other two level arrangements of Containers Library (http://en.cppreference.com/w/cpp/container) objects. I corresponded with Eran and he established that the problem exists on Windows as well as on Linux (I am mainly using Debian 8.1 64 bit), and that it was caused by gdb behaving incorrectly to at least some -var-update commands, which Codelite gives it when opening up vectors and the like.
I have since been able to recreate the faulty behavior of gdb on the command line, without using Codelite at all. I use a simpler test program which creates a vector of 5 vectors, each of which contains 2 ints.
I reported this as a gdb bug: https://sourceware.org/bugzilla/show_bug.cgi?id=18623 and am working further to provide a detailed procedure for recreating the problem behaviour in gdb, on the command line.
As far as I can tell, the problem is within gdb, and is not related to problems with printers.py (the python script gdb needs to "pretty print" Containers Libary objects in ways which humans and Codelite can use. However, since the problem is not yet resolved, I can't be sure of its cause.
As far as I can see, the problem can't be resolved in codelite, and exists in gdb from 7.7.1 which I was using, 7.8.1 which Eran is using on Windows (as part of TDM-GCC 64 bit, which is typically installed with Codelite for Windows) to the current trunk snapshots, as recent as 2015-07-02, which I compile and am now using in testing.
So far, it seems that all the trouble is related to a command Codelite gives via the MI (Machine Interface) of gdb - "-var-update". So if you have frustrations debugging code with vectors of vectors, lists of strings, vectors of maps or whatever, this may be the cause. Here is the page which I used to report Codelite's problem behavior: http://www.firstpr.com.au/temp/Codelite/01/
- Robin
gdb problems with C++ vector of vectors and other containers
-
- CodeLite Enthusiast
- Posts: 14
- Joined: Sat Mar 26, 2011 4:22 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
-
- CodeLite Veteran
- Posts: 56
- Joined: Thu Sep 22, 2011 11:29 pm
- Genuine User: Yes
- IDE Question: c++
- Contact:
Re: gdb problems with C++ vector of vectors and other contai
I tried to reproduce the problem. I use RedHat 6.6, Devtoolset 3 (devtoolset-3-gdb-7.8.2-38.el6.x86_64).
I created a simple program like this:
gdb session snippet when execution is stopped at line 23:
I don't see any gdb errors, output is correct.
I created a simple program like this:
Code: Select all
1 #include <iostream>
2 #include <vector>
3
4 int main(int argc, char **argv)
5 {
6 std::vector<int> v1;
7
8 v1.push_back(100);
9 v1.push_back(101);
10
11 std::vector< std::vector<int> > v2;
12
13 for (int i = 0; i < 5; i++)
14 {
15 v2.push_back(v1);
16
17 for (unsigned int j = 0; j < v1.size(); j++)
18 {
19 v2[i][j] += (i * 1000) ;
20 }
21 }
22
23 std::cout << "v1 size: " << v1.size() << "\n";
24 std::cout << "v2 size: " << v2.size() << "\n";
25
26 return 0;
27 }
28
Code: Select all
(gdb) p v1
$1 = std::__debug::vector of length 2, capacity 2 = {100, 101}
(gdb) p v2
$2 = std::__debug::vector of length 5, capacity 8 = {std::__debug::vector of length 2, capacity 2 = {100, 101}, std::__debug::vector of length 2, capacity 2 = {1100, 1101}, std::__debug::vector of length 2, capacity 2 = {2100, 2101},
std::__debug::vector of length 2, capacity 2 = {3100, 3101}, std::__debug::vector of length 2, capacity 2 = {4100, 4101}}
-
- CodeLite Enthusiast
- Posts: 14
- Joined: Sat Mar 26, 2011 4:22 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: gdb problems with C++ vector of vectors and other contai
As far as I can tell, recent versions of gdb have the same behavior (which I think is a bug) as I reported in July 2015:
https://sourceware.org/bugzilla/show_bug.cgi?id=18623
That behavior, in my experience, stopped Codelite from displaying the contents of, for instance, a vector of vectors. However recent versions of Codelite (9.1 and 9.1.8) drive gdb in a different way and there are no problems displaying the contents of vectors which are within another vector or, for instance, navigating a vector of structs each containing a string and a deque of ints. My comment yesterday in the above bug report detail my recent observations.
Robin
https://sourceware.org/bugzilla/show_bug.cgi?id=18623
That behavior, in my experience, stopped Codelite from displaying the contents of, for instance, a vector of vectors. However recent versions of Codelite (9.1 and 9.1.8) drive gdb in a different way and there are no problems displaying the contents of vectors which are within another vector or, for instance, navigating a vector of structs each containing a string and a deque of ints. My comment yesterday in the above bug report detail my recent observations.
Robin