I have an exception thrown from native code in Visual Studio 10. I've enabled breaking on throw for all exceptions in the debug->exceptions menu. It's a regular C++ std::runtime_error, no SEH or managed exceptions involved here. But the runtime won't break on throw. It also won't catch them- even though I explicitly caught runtime_errors, since I throw some. They're finally caught by the managed calling code. I put a breakpoint before the throw statement and I know which one is throwing and why- but still mystified as to why I can't break on it or catch it.
try {
//...
std::for_each(...) {
if (condition) {
std::stringstream str;
str << "Error: Unexpected end of file in file " << arg.first << "\n";
str << "Unused tokens: \n";
for(int i = 0; i < token_stack.size(); i++) {
auto ref = token_stack.top();
str << " " << ref->contents << " at line " << ref->line << "\n";
token_stack.pop();
开发者_如何学C }
throw std::runtime_error(str.str());
}
});
//...
}
catch(const std::runtime_error& exception) {
std::cout << exception.what() << std::endl;
return;
}
The function is eventually called from managed code. I know that this throw statement is the one throwing.
If this is a managed appliaction as you seem to imply, then I think you need to enable "mixed mode debugging". Have you checked if you can set a breakpoint in this function?
精彩评论