Compiling the following with MinGW 4.6.2 (with g++ -g -std=c++0x), gdb doesn’t seem to want catch the std::out_of_range if I try catch throw. if I throw it manually it catches fine, am I doing something wrong?
#include <stdexcept>
#include <vector>
int main()
{
std::vector<char> vec(10);
try {
vec.at(10); // this won't be caught by gdb
// throw std::out_of_range(""); // this will
}
catch (std::out_of_range const& e) {
}
}
As you’ve seeen, the exception from
std::vector::at()is thrown by__throw_out_of_rangewhich is a function insidelibstdc++.so, so I suspect there’s some problem on Mingw that prevents GDB from setting a catchpoint in a shared library. Or maybe yourlibstdc++wasn’t built with-g.If your GCC was configured with
--enable-libstdcxx-debugyou would have a second set of libs built with-O0 -gthat might work better when debugging, but that option isn’t used often.