Win32 API stack walk with MinGW/MSYS?

后端 未结 3 899
猫巷女王i
猫巷女王i 2020-12-09 12:46

i\'ve to develop a stack trace walk to our win32 API plattform support to catch any exception with a behaviour of a JAVA stacktrace. Actually we got a full functional implem

3条回答
  •  青春惊慌失措
    2020-12-09 13:25

    I got stack traces working in MingGW with Edd's dbg library, which is a successor to his minimal stack_trace library:

    With msys2, this should get you a stack trace:

    $ pacman -S mingw-w64-x86_64-edd-dbg
    
    // main.cpp
    #include 
    #include 
    #include 
    
    int main()
    {
      dbg::symdb db;
      dbg::call_stack<64> traceback;
      traceback.collect(0);
      traceback.log(db, std::cout);
      return 0;
    }
    
    $ g++ -ggdb main.cpp -ldbg
    $ ./a.exe
    0x0000000000402ee9: dbg::call_stack<64u>::collect(unsigned int) in C:\msys64\home\phil\stacktrace-example\a.exe
    0x00000000004015f2: main in C:\msys64\home\phil\stacktrace-example\a.exe
    0x00000000004013f8: __tmainCRTStartup in C:\msys64\home\phil\stacktrace-example\a.exe
    0x000000000040151b: mainCRTStartup in C:\msys64\home\phil\stacktrace-example\a.exe
    0x00007ffbb0838102: BaseThreadInitThunk in C:\WINDOWS\system32\KERNEL32.DLL
    0x00007ffbb27cc5b4: RtlUserThreadStart in C:\WINDOWS\SYSTEM32\ntdll.dll
    

    More about dbg can be found in the Wiki. The code is available here: https://bitbucket.org/edd/dbg/src

提交回复
热议问题