Hi there,
I believe that this is a problem a few people have run into and maybe there has been some discussion about this already. If yes, please point me to the appropriate thread...
In my (and my students) programs STL classes are extensively used, mostly std::string, std::vector, std::list and std::map. Debugging source code with CodeBlocks works so far only satisfactorily for std::string, and that only for simply showing the content. From the perspective of a user (e.g. imagine a student learning C++), it would be nice to have some more features, as outlined below.
As G++ doesn't compile inlined template functions unless they are used, I created a header file for my students, that includes a class like this:
class _STLDebugHelper {
public:
_STLDebugHelper() {
std::vector<double> d;
d.size(); d.front(); d.back();
d.push_back(10); d[0] = 2; d.at(0) = 2;
d.begin(); d.end();
std::vector<double>::iterator it;
++it; it++; --it; it--;*it;
// ... same for other STL classes
}
} __STLDebugHelper;
By including the header (in only one of the implementation files) at least the typical STL container functions are available through the debugger.
However, when it comes to displaying and evaluating variables using the debugger and the UI, there are still some features that would be quite helpful:
- local watches of STL container types should be collapsed when first shown in the debugger (try debugging a program with 10 locally declared STL classes or a class with 20 stl type member variables... you need a few minutes just to get an overview of what you are actually looking at)
- locally watched std::string types should show the content like it is done when manually adding a watch for a variable of type std::string
- watching ranges of elements in std::vector in the style of vector[15] - 10 elements = [0, 1, 2, 3, 4, 5, 6, 7, 2,3] should be possible
I believe that these features are rather UI features than something to be directly implemented into GDB. Now, does somebody actively work on enhancing debugging features/display in CodeBlocks? If nobody has the time to look into that, I could maybe help enhancing the debugging capabilities of CodeBlocks, but I would appreciate some help for where to get started (basically some info on which class does the GDB parsing, and how and where the debugging treeview is updated). Also watched variables may need additional properties, such as the number of elements to display (in the case of the std::vector).
Thanks a lot in advance for any improvements regarding the debugger, since I believe it is a very important tool for students and active programmers alike.
Andreas Nicolai