https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112263

--- Comment #5 from vincenzo Innocente <vincenzo.innocente at cern dot ch> ---
so if I add to
    std::cout << std::stacktrace::current() << '\n';
I get what needed
   Dl_info dlinfo;
   for (auto & entry : std::stacktrace::current() ) {
     dladdr((const void*)(entry.native_handle()),&dlinfo);
     std::cout << dlinfo.dli_sname << ' ' << dlinfo.dli_fname <<'\n';
   }

 c++ -std=c++23 testStacktrace.cpp -lstdc++exp -g -DINLIB -fpic -shared -o
liba.so -ldl ; c++ -std=c++23 testStacktrace.cpp -lstdc++exp -g -DINMAIN -L.
-la -Wl,-rpath=. ; ./a.out
   0#      at :0
   1#      at :0
   2# func(int) at
/data/user/innocent/MallocProfiler/tests/testStacktrace.cpp:44
   3# main at /data/user/innocent/MallocProfiler/tests/testStacktrace.cpp:49
   4#      at :0
   5# _start at :0
   6#

_Z12nested_func2i ./liba.so
_Z11nested_funci ./liba.so

of course not de-mangled....

so is it a feature or a defect?

I'm not sure how the implementation works (did not look to the code)
dladdr can be slow and may "hang" in some situations.
so it would be useful to have an option that the "name" is not immediately
resolved
and have a function that returns the name from the native_handle
"asynchronously"

Reply via email to