Debugging STL code with Xcode

Viro

Registered
Here's a question for anyone who uses the STL and Xcode. Due to the nature of the STL headers that are shipped with GCC, which I believe come from SGI's implementation of the STL, it is nearly impossible to correctly debug C++ code that makes use of the STL. The reason is simple: in the interest of efficiency, the STL headers provided by GCC only contain inline methods. As inline methods are expanded at compile time, it makes it impossible to call STL methods when the program is being debugged.

Consider the following example:
Code:
vector<int> a;
for(int i = 0; i < 10; i++)
  a.push_back(i);

//insert a breakpoint here

When the following code is run through the debugger, at the breakpoint it is impossible to inspect the values contained in a. The reason is because the necessary code to inspect the values of a (i.e. the operator [] and the method at()) are inline, and as they are not used they are not compiled.

Other C++ compilers, like MS Visual C++ contain two sets of STL headers, Debug and Release. The Debug version does not contain inline methods, allowing you to easily debug the code, while the Release version is similar to the SGI STL headers, where everything is inlined for performance.

My question is, seeing as I want to debug code that uses the STL, what are my options? Anyone know the solution to this?
 
Back
Top