Can't get information in main()
So, this is strange. I'm using boost::stacktrace with libbacktrace, but I've reproduced it on a smaller scale with libbacktrace directly. Everything but information on my main() is showing up correctly (in my limited testing)
For instance, these are my stacktraces at two different points
0# foo::throw_fds_exception<foo::FOOException>::throw_exception() at /home/dev/BAR/build/vcpkg_installed/bar/include/foo-exception/foo_exception.h:109
1# main in build/Debug/bin/broker
2# __libc_start_call_main at ../sysdeps/nptl/libc_start_call_main.h:58
3# __libc_start_main at ../csu/libc-start.c:379
4# _start in build/Debug/bin/broker
and
0# foo::throw_fds_exception<foo::FOOException>::throw_exception() at /home/dev/BAR/build/vcpkg_installed/bar/include/foo-exception/foo_exception.h:109
1# InitializeLogger(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) at /home/dev/FOO/foo/logging_helper.h:25
2# main in build/Debug/bin/broker
3# __libc_start_call_main at ../sysdeps/nptl/libc_start_call_main.h:58
4# __libc_start_main at ../csu/libc-start.c:379
5# _start in build/Debug/bin/broker
I'm using gcc 13.1 and these are in a debug build. I'm running Ubuntu 22.04 in a docker container. My options are below.
add_compile_options(
"-Wno-unknown-pragmas" "-fexceptions" "-ggdb" "-DFDS_EXPORT= " "-DFDS_EXPORT_CLASS=class " "-DBOOST_ALLOW_DEPRECATED_HEADERS " "-fPIC" "-rdynamic"
"-Wno-attributes" "-DBOOST_BIND_GLOBAL_PLACEHOLDERS " "-Wno-unused-result" "-Wno-deprecated-declarations" "-fdata-sections" "-ffunction-sections" "-g3" "-pthread"
"-DXXH_INLINE_ALL " "-fno-omit-frame-pointer"
"$<$<CONFIG:DEBUG>:-O0>"
"$<$<CONFIG:DEBUG>:-D_DEBUG>"
"$<$<CONFIG:RELEASE>:-Ofast>"
"$<$<CONFIG:RELEASE>:-DRAPIDJSON_SSE42 >"
"$<$<CONFIG:RELEASE>:-march=skylake>"
"$<$<CONFIG:RELEASE>:-DNDEBUG>"
)
I'm pretty sure the "main in build/Debug/bin/broker" is a nicety added by boost. In my reproducer I'm seeing 0x561dd7eb9cf5. (null):0: function -
Any help would be appreciated here
looking a little closer, I can use libbacktrace to get the function name and offset if I use backtrace_syminfo() using the same backtrace_state, so it knows that main() exists
it is giving the correct stacktrace in Release
Sorry, I don't know what is happening. This kind of problem is essentially impossible for me to debug unless I can reproduce it myself. The most likely cause is that the file containing the main function was compiled without -g.
The fact that backtrace_syminfo succeeds doesn't tell us much, as backtrace_syminfo does not require the debug info produced by -g. In particular, backtrace_syminfo doesn't report the file and line number.
Without more information there is nothing I can do. Please comment if there is some way to make progress.