QT MinGW32 : bootstrap stacktrace (header only) not showing function names and lines numbers shows only address

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

QT MinGW32 : bootstrap stacktrace (header only) not showing function names and lines numbers shows only address

Boost - Users mailing list
Hi Everyone,

I am trying to print stack-trace using boost HEADER-ONLY. I am using descriptions under Configuration and Build to compile a simple code using QT MinGW32 I also use the below macros to tune boost:

-DBOOST_STACKTRACE_USE_WINDBG -DBOOST_STACKTRACE_USE_ADDR2LINE -DBOOST_STACKTRACE_ADDR2LINE_LOCATION

I have no clue why the function names and line numbers are not showing up.

Any comment is appreciated.
Mike

Below are compile and build instructions:

g++  -g3 -DBOOST_STACKTRACE_USE_WINDBG -DBOOST_STACKTRACE_USE_ADDR2LINE -DBOOST_STACKTRACE_ADDR2LINE_LOCATION=C:\Qt_5_12\Tools\mingw730_32\bin\addr2line.exe -I../../../boost_1_73_0 -c main.cpp -omain.o

g++ main.o -o stack_traces.exe -L"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x86" -L"C:\temp\libbacktrace" -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -luuid -lodbc32 -lodbccp32 -lDbgEng

And here is the output ... 

 0# 0x00402C75 in stack_traces
 1# 0x00401602 in stack_traces
 2# 0x004016CE in stack_traces
 3# 0x0040138B in stack_traces
 4# _BaseThreadInitThunk in KERNEL32
 5# _RtlGetAppContainerNamedObjectPath in ntdll
 6# _RtlGetAppContainerNamedObjectPath in ntdll
1 + 2 = 3

The code (main.cpp)

Is fairly simple as below:

#include <iostream>
#include <boost/stacktrace.hpp>

double add(double a, double b){
      std::cout << boost::stacktrace::stacktrace();
      std::cout << a << " + " << b << " = " << (a+b) << std::endl;
      return a+b;
}

int main(){
     add(1,2);
     return 0;
}


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: QT MinGW32 : bootstrap stacktrace (header only) not showing function names and lines numbers shows only address

Boost - Users mailing list
On 05/12/2020 11:57, Mehdi Est via Boost-users wrote:
Hi Everyone,

I am trying to print stack-trace using boost HEADER-ONLY. I am using descriptions under Configuration and Build to compile a simple code using QT MinGW32 I also use the below macros to tune boost:

-DBOOST_STACKTRACE_USE_WINDBG -DBOOST_STACKTRACE_USE_ADDR2LINE -DBOOST_STACKTRACE_ADDR2LINE_LOCATION

I have no clue why the function names and line numbers are not showing up.

Any comment is appreciated.
Mike

Hi Mike,

this page: https://www.boost.org/doc/libs/develop/doc/html/stacktrace/configuration_and_build.html says that the dbgeng library can only extract symbolic information from 64-bit MinGW executables. It looks like you need to use the 3rd-party libbacktrace library with 32-bit MinGW executables to capture that information.

Regards
Bill Somerville.


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: QT MinGW32 : bootstrap stacktrace (header only) not showing function names and lines numbers shows only address

Boost - Users mailing list
Hi Bill,

Thanks to your comment, I got it working for QT MinGW32 (C:\Qt_5_12\Tools\mingw730_32\bin\g++.exe) ! Interestingly enough, I didn't need libdl and I wasn't able to find it under QT-MinGW32 folder either. Though, I was able to see full stack trace even when linking many C and C++ objects in one build. Below is the minimum setup I needed to get things working for the same code discussed earlier. 

The other interesting experience I had, is that I could see stack trace using -g and -O0 but any higher optimization did not work (at least for me, it only printed the most top function in the call stack) which is more or less acceptable because debug info is only available in debug-enabled compilations.

I am just  curious, in case I need to create a stack dump / crash report in production (built with optimization level >= 1), 

how would I be able to achieve that?

Many thanks,
Mike

c:\Users\Mike-laptop\workspace_v9_2_1\cxxlab\tmp\mixccpp>make clean all && stack_traces.exe
g++  -O0 -DBOOST_STACKTRACE_USE_BACKTRACE -I../../../boost_1_73_0 -Ic:\temp\libbacktrace  -c main.cpp -omain.o
g++ main.o -o stack_traces.exe -L"C:\temp\libbacktrace" -lbacktrace
 0# boost::stacktrace::basic_stacktrace<std::allocator<boost::stacktrace::frame> >::init(unsigned int, unsigned int) in c:\Users\ Mike -laptop\workspace_v9_2_1\cxxlab\tmp\mixccpp\stack_traces.exe
 1# add(double, double) in c:\Users\Mike-laptop\workspace_v9_2_1\cxxlab\tmp\mixccpp\stack_traces.exe
 2# main in c:\Users\ Mike -laptop\workspace_v9_2_1\cxxlab\tmp\mixccpp\stack_traces.exe
 3# __tmainCRTStartup in c:\Users\Mike-laptop\workspace_v9_2_1\cxxlab\tmp\mixccpp\stack_traces.exe
 4# register_frame_ctor in C:\Windows\System32\KERNEL32.DLL
 5# register_frame_ctor in C:\Windows\SYSTEM32\ntdll.dll
 6# register_frame_ctor in C:\Windows\SYSTEM32\ntdll.dll
1 + 2 = 3



On Sat, Dec 5, 2020 at 10:36 AM Bill Somerville via Boost-users <[hidden email]> wrote:
On 05/12/2020 11:57, Mehdi Est via Boost-users wrote:
Hi Everyone,

I am trying to print stack-trace using boost HEADER-ONLY. I am using descriptions under Configuration and Build to compile a simple code using QT MinGW32 I also use the below macros to tune boost:

-DBOOST_STACKTRACE_USE_WINDBG -DBOOST_STACKTRACE_USE_ADDR2LINE -DBOOST_STACKTRACE_ADDR2LINE_LOCATION

I have no clue why the function names and line numbers are not showing up.

Any comment is appreciated.
Mike

Hi Mike,

this page: https://www.boost.org/doc/libs/develop/doc/html/stacktrace/configuration_and_build.html says that the dbgeng library can only extract symbolic information from 64-bit MinGW executables. It looks like you need to use the 3rd-party libbacktrace library with 32-bit MinGW executables to capture that information.

Regards
Bill Somerville.

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users