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

Optional fall back to LLVM symbolizer markup #96

Closed
mysterymath opened this issue Oct 4, 2022 · 6 comments
Closed

Optional fall back to LLVM symbolizer markup #96

mysterymath opened this issue Oct 4, 2022 · 6 comments

Comments

@mysterymath
Copy link

Now that Symbolizer Markup has landed in LLVM 15.0.2, it would be possible to add an option to emit this markup whenever symbol information is unavailable (fully-stripped binaries, etc.).

Producing symbolizer markup would allow llvm-symbolizer to produce human-readable backtraces from it after the fact, looking up the necessary artifacts using debuginfod. This complements #79; since it would be nice to have debuginfod lookups handled transparently, but that's not always possible (e.g., for embedded or sandboxed environments).

This should be relatively straightforward to implement, since the format is just a simple textual representation of the memory layout of the process and the return addresses of the backtrace.

@ianlancetaylor
Copy link
Owner

This seems like something to be done by the code that uses libbacktrace, not by libbacktrace itself. libbacktrace just returns file and funcition names, it doesn't print them. Well, except for backtrace_print, but changing the format of backtrace_print seems likely to break existing programs.

@mysterymath
Copy link
Author

Unfortunately, getting this to work requires the detailed memory layout of the process to be emitted as markup. I don't think it's likely that you'd get N utility authors to dliterate_phdr, and to spit out the right markup from the results.

I was hoping from a systems integrator perspective that there'd be an environment variable that could be used to turn this on for disparate utilities that depend on libbacktrace library. Then, you could run over backtrace logs produced by stripped binaries and symbolize them after the fact. That's how things work for Fuchsia today, and it's great, but there's nothing Fuchsia-specific about it, and it'd be nice to be able to bring this to the embedded Linux space as well.

@ianlancetaylor
Copy link
Owner

But, again, libbacktrace doesn't print anything. I don't understand how you think that libbacktrace should change.

@mysterymath
Copy link
Author

mysterymath commented Oct 4, 2022

Sorry, I had meant to imply (and should have stated) that I'd like to see a change to backtrace_print for this. Is the format output by that function part of the backwards-compatibility guarantees of the library? Is it being parsed such that utilities might break if such an environment variable were flipped on?

I've also been operating under the assumption that the most common mode of use for the library is to backtrace_print in a signal handler, which I've not verified.

@ianlancetaylor
Copy link
Owner

Those are good questions about backtrace_print. I kind of assume that very few people use it. Searching GitHub at https://github.com/search?q=backtrace_print&ref=simplesearch doesn't find very many uses, but I don't know how meaningful that is.

@ianlancetaylor
Copy link
Owner

libbacktrace relies on _Unwind_Backtrace, and it should already be possible to use _Unwind_Backtrace to get the information needed to print LLVM symbolizer markup format. I don't see a useful role for libbacktrace here. Please comment if you disagree.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Jul 18, 2024
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

2 participants