Skip to content

Can't debug executables that throw c++ exceptions #339

@ssbssa

Description

@ssbssa

If you try to debug any executable that throws a c++ exception, you get this result (here with lldb):

* thread #​1, stop reason = Exception 0xc00000ff encountered at address 0x7fff44a181b0
  frame #​0: 0x00007fff44a181b0 ntdll.dll`RtlRaiseStatus + 32

I even tried cdb, and got a similar result.

After lots of searching I found this post detailing a deep analysis plus solution of the problem.

So I adapted this for gcc like this:

diff --git a/libgcc/unwind-seh.c b/libgcc/unwind-seh.c
index e13e3b2ef..43f038475 100644
--- a/libgcc/unwind-seh.c
+++ b/libgcc/unwind-seh.c
@@ -227,7 +227,7 @@ _GCC_specific_handler (PEXCEPTION_RECORD ms_exc, void *this_frame,
       if (ms_exc->ExceptionInformation[1] == (_Unwind_Ptr) this_frame)
        {
          RtlUnwindEx (this_frame, (PVOID) ms_exc->ExceptionInformation[2],
-                      ms_exc, gcc_exc, ms_orig_context,
+                      ms_exc, gcc_exc, ms_disp->ContextRecord,
                       ms_disp->HistoryTable);
          abort ();
        }
@@ -323,7 +323,7 @@ _GCC_specific_handler (PEXCEPTION_RECORD ms_exc, void *this_frame,
 
          /* Begin phase 2.  Perform the unwinding.  */
          RtlUnwindEx (this_frame, (PVOID)gcc_context.ra, ms_exc,
-                      (PVOID)gcc_context.reg[0], ms_orig_context,
+                      (PVOID)gcc_context.reg[0], ms_disp->ContextRecord,
                       ms_disp->HistoryTable);
        }
 

And now I can debug successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions