【问题标题】:Where can I see the what() message from an unhandled std::exception in Visual Studio 2012?我在哪里可以看到来自 Visual Studio 2012 中未处理的 std::exception 的 what() 消息?
【发布时间】:2012-11-21 17:04:55
【问题描述】:

有没有办法从未处理的异常中查看解释性字符串?我正在使用 Visual Studio 2012 Express,但似乎找不到查看它的方法。

当我运行以下代码时:

#include <stdexcept>

int main(int argc, char* argv[])
{
    throw std::runtime_error("warp core breach");
    return 0;
}

我在输出窗口中得到的只是:

First-chance exception at 0x7652C41F in vstest.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0015F6A4.
Unhandled exception at at 0x7652C41F in vstest.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0015F6A4.

我原以为会在此处打印“曲速核心突破”消息。我将 Debugging->Output Window->General Output Settings 下的所有选项都设置为 On。

【问题讨论】:

  • @Nick 当然我可以抓住它,但我只想知道在没有被抓住的情况下如何看到消息。调试时肯定有办法这样做吗?

标签: c++ debugging exception visual-studio-2012


【解决方案1】:

当抛出异常时,您会看到一个窗口,其中包含中断/继续/忽略选项。复制并粘贴此对话框报告的十六进制地址,然后单击 break 按钮。现在在监视窗口中,在第一列的单元格中输入如下内容:(std::runtime_error*)(0x002cfbc8)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-17
    • 2015-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多