Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libbacktrace does not include the origin library in its description. #108

Open
Febbe opened this issue Jun 10, 2023 · 0 comments
Open

libbacktrace does not include the origin library in its description. #108

Febbe opened this issue Jun 10, 2023 · 0 comments

Comments

@Febbe
Copy link

Febbe commented Jun 10, 2023

Would it be possible, to add afunction to get the origin library in case of a function in a dynamic library?
Taking the gcc implementation for example, which uses libbacktrace internally, it currently prints something like:

0# crashHandler at /mnt/c/Users/Febbe/workspace/xournalpp/src/core/control/CrashHandler.cpp:76
   1#      at :0
   2# pthread_kill at :0
   3# raise at :0
   4# MainWindow::MainWindow(GladeSearchpath*, Control*, _GtkApplication*) at /mnt/c/Users/Febbe/workspace/xournalpp/src/core/gui/MainWindow.cpp:54
   5# std::_MakeUniq<MainWindow>::__single_object std::make_unique<MainWindow, GladeSearchpath*, Control*, _GtkApplication*>(GladeSearchpath*&&, Control*&&, _GtkApplication*&&) at :0
   6# on_startup at /mnt/c/Users/Febbe/workspace/xournalpp/src/core/control/XournalMain.cpp:485
   7# g_closure_invoke at :0
   8#      at :0
   9# g_signal_emit_valist at :0
  10# g_signal_emit at :0
  11# g_application_register at :0
  12#      at :0
  13# g_application_run at :0
  14# XournalMain::run(int, char**) at /mnt/c/Users/Febbe/workspace/xournalpp/src/core/control/XournalMain.cpp:690

Note the at :0 in case of missing debug symbols.
That results from a call to backtrace_pcinfo which only return the function name, line number and filename.

In any case I would expect to have the originating library path or at least the name in that line instead of nothing.

Since alternating, the API is not a feasible solution, a function to retrieve the so information from the pc would be useful.
Like

typedef int (*backtrace_so_callback) (void *data, uintptr_t pc,
					const char *sofilename);

extern int backtrace_pcsoinfo (struct backtrace_state *state, uintptr_t pc,
			     backtrace_so_callback callback,
			     backtrace_error_callback error_callback,
			     void *data);`

or

typedef int (*backtrace_pc_verbose_callback) (void *data, uintptr_t pc,
					const char *sofilename, const char *filename, int lineno,
					const char *function);

extern int backtrace_pc_verbose (struct backtrace_state *state, uintptr_t pc,
			     backtrace_pc_verbose_callback callback,
			     backtrace_error_callback error_callback,
			     void *data);`

My current solution is to call dladdr1 to retrieve the so information. But this is not platform independent, I suppose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant