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

Notes on triggering stack traces in different languages, externally #8

Open
rrnewton opened this issue Nov 14, 2022 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@rrnewton
Copy link
Contributor

rrnewton commented Nov 14, 2022

From the perspective of a native-code debugger, interpreting runtime states to extract a stack trace for arbitrary languages (interpreted, JIT-compiled, AOT-compiled...) is a hard problem. There are some attempts to teach debuggers how to access this runtime state, like py-bt via GDB Python extensions. But ultimately a language's interpreter/compiler/runtime is the source of truth for how to read that language's stack frames.

Fortunately, many languages an external trigger, typically a signal (e.g. SIGTRAP) can trigger the runtime to print its stacktrace from a signal handler. Therefore, especially if you are willing to throw away the current process (or have a fork/backup it), you can get out a language-specific stack trace. This issue is a place to accumulate notes on doing that, per-language.

Python

Setting the PYTHONFAULTHANDLER environment variable to 1 will put the runtime in a state where certain signals, including SIGABRT, will cause it to dump a traceback.

Java

The jcmd / jstack utilities provide a way to signal the JVM runtime to dump the current stacktraces to wherever its logging stdout is currently going.

.NET (CLR, mono)

Rust, C, C++

In these native languages, gdb or lldb can read the backtrace, or libunwind can be used to do it.

@rrnewton rrnewton added the enhancement New feature or request label Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant