<bdo id='lrUHX'></bdo><ul id='lrUHX'></ul>
  • <small id='lrUHX'></small><noframes id='lrUHX'>

    <legend id='lrUHX'><style id='lrUHX'><dir id='lrUHX'><q id='lrUHX'></q></dir></style></legend>

        <tfoot id='lrUHX'></tfoot>
        <i id='lrUHX'><tr id='lrUHX'><dt id='lrUHX'><q id='lrUHX'><span id='lrUHX'><b id='lrUHX'><form id='lrUHX'><ins id='lrUHX'></ins><ul id='lrUHX'></ul><sub id='lrUHX'></sub></form><legend id='lrUHX'></legend><bdo id='lrUHX'><pre id='lrUHX'><center id='lrUHX'></center></pre></bdo></b><th id='lrUHX'></th></span></q></dt></tr></i><div id='lrUHX'><tfoot id='lrUHX'></tfoot><dl id='lrUHX'><fieldset id='lrUHX'></fieldset></dl></div>
      1. 获取有关在 catch 块内抛出 C++ 异常的位置的信息?

        时间:2023-07-01
      2. <small id='FIuPM'></small><noframes id='FIuPM'>

          <tbody id='FIuPM'></tbody>
          <bdo id='FIuPM'></bdo><ul id='FIuPM'></ul>
            <i id='FIuPM'><tr id='FIuPM'><dt id='FIuPM'><q id='FIuPM'><span id='FIuPM'><b id='FIuPM'><form id='FIuPM'><ins id='FIuPM'></ins><ul id='FIuPM'></ul><sub id='FIuPM'></sub></form><legend id='FIuPM'></legend><bdo id='FIuPM'><pre id='FIuPM'><center id='FIuPM'></center></pre></bdo></b><th id='FIuPM'></th></span></q></dt></tr></i><div id='FIuPM'><tfoot id='FIuPM'></tfoot><dl id='FIuPM'><fieldset id='FIuPM'></fieldset></dl></div>
            <legend id='FIuPM'><style id='FIuPM'><dir id='FIuPM'><q id='FIuPM'></q></dir></style></legend>

                • <tfoot id='FIuPM'></tfoot>

                  本文介绍了获取有关在 catch 块内抛出 C++ 异常的位置的信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 C++ 应用程序,它在 try 块中包装了大部分代码.当我捕获异常时,我可以将用户返回到稳定状态,这很好.但我不再收到崩溃转储.我真的很想弄清楚异常发生在代码中的哪个位置,以便我可以记录并修复它.

                  I've got a c++ app that wraps large parts of code in try blocks. When I catch exceptions I can return the user to a stable state, which is nice. But I'm not longer receiving crash dumps. I'd really like to figure out where in the code the exception is taking place, so I can log it and fix it.

                  能够在不停止应用程序的情况下获得转储是理想的,但我不确定这是否可能.

                  Being able to get a dump without halting the application would be ideal, but I'm not sure that's possible.

                  有什么方法可以找出从 catch 块中抛出异常的位置吗?如果有用,我将在 windows xp 及更高版本上使用本机 msvc++.我的计划是简单地将崩溃记录到不同用户机器上的文件中,然后在崩溃日志达到一定大小后上传.

                  Is there some way I can figure out where the exception was thrown from within the catch block? If it's useful, I'm using native msvc++ on windows xp and higher. My plan is to simply log the crashes to a file on the various users' machines, and then upload the crashlogs once they get to a certain size.

                  推荐答案

                  这可以通过使用 SEH(结构化异常处理)来实现.关键是 MSVC 通过 SEH 实现了 C++ 异常.另一方面,纯 SEH 更强大、更灵活.

                  This is possible with using SEH (structured exception handling). The point is that MSVC implements C++ exceptions via SEH. On the other hand the pure SEH is much more powerful and flexible.

                  这是你应该做的.而不是像这样使用纯 C++ try/catch 块:

                  That's what you should do. Instead of using pure C++ try/catch blocks like this:

                  try
                  {
                      DoSomething();
                  } catch(MyExc& exc)
                  {
                      // process the exception
                  }
                  

                  你应该用 SEH 块包裹内部代码块 DoSomething:

                  You should wrap the inner code block DoSomething with the SEH block:

                  void DoSomething()
                  {
                      __try {
                          DoSomethingInner();
                      }
                      __except (DumpExc(GetExceptionInformation()), EXCEPTION_CONTINUE_SEARCH) {
                          // never get there
                      }
                  }
                  
                  void DumpEx(EXCEPTION_POINTERS* pExc)
                  {
                      // Call MiniDumpWriteDump to produce the needed dump file
                  }
                  

                  也就是说,在 C++ try/catch 块中,我们放置了另一个原始 SEH 块,它只转储所有异常而不捕获它们.

                  That is, inside the C++ try/catch block we place another raw SEH block, which only dumps all the exceptions without catching them.

                  参见 此处 使用 MiniDumpWriteDump 的示例.

                  See here for an example of using MiniDumpWriteDump.

                  这篇关于获取有关在 catch 块内抛出 C++ 异常的位置的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:“二进制文件不是用调试信息构建的"mfc 应用程序中的警告含义? 下一篇:使用/不使用 Visual Leak Detector 在 C++ 中检测内存泄漏

                  相关文章

                  1. <small id='fr1SR'></small><noframes id='fr1SR'>

                  2. <tfoot id='fr1SR'></tfoot>

                    <legend id='fr1SR'><style id='fr1SR'><dir id='fr1SR'><q id='fr1SR'></q></dir></style></legend>
                      <bdo id='fr1SR'></bdo><ul id='fr1SR'></ul>
                      <i id='fr1SR'><tr id='fr1SR'><dt id='fr1SR'><q id='fr1SR'><span id='fr1SR'><b id='fr1SR'><form id='fr1SR'><ins id='fr1SR'></ins><ul id='fr1SR'></ul><sub id='fr1SR'></sub></form><legend id='fr1SR'></legend><bdo id='fr1SR'><pre id='fr1SR'><center id='fr1SR'></center></pre></bdo></b><th id='fr1SR'></th></span></q></dt></tr></i><div id='fr1SR'><tfoot id='fr1SR'></tfoot><dl id='fr1SR'><fieldset id='fr1SR'></fieldset></dl></div>