Find object throwing std::out_of_range

Put a breakpoint on std::out_of_range::out_of_range. An exception object, like all C++ objects, starts its life after its constructor exits.

[EDIT] Comment made it clear: the problem the string produced by std::out_of_range::what(). That's implementation-defined. Obviously in your case it's composed from __FUNCTION__, a GCC macro which names the current (i.e. throwing) function. But such a function only knows this, i.e. the pointer to the current object and not its name. In the other case, the objects name is retrieved via some other method, not std::out_of_range::what().


After hitting the breakpoint enter bt (backtrace) command in the gdb shell. This will print the stack trace (a sequence of function calls leading to the error).

To get the variable name you can now use up command to navigate upwards in the stack and see what variables where used in each of those functions.