-
-
Notifications
You must be signed in to change notification settings - Fork 490
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
Is it possible to have debug symbols/stack unwinding for debugging? #313
Comments
We use the jit-reader support in gdb to do stack unwinding and symbol resolution. It works well enough and we found it easier to work with than elf and dwarf. |
I will look into that also. Thanks. (BTW the link you added @garazdawi is broken) My problem though is that I have external functions being called from JIT code that calls backtrace(). So I need support for that also (support for gloc backtrace()/libunwind is unfortunately going to be different from gdb support). So wondering how to work around with that? |
Seems like you need something more complex than what we needed. We use this as the jit-reader code: https://github.com/erlang/otp/blob/master/erts/etc/unix/jit-reader.c And the data is generated here: https://github.com/erlang/otp/blob/master/erts/emulator/beam/jit/beam_asm.cpp#L575 |
It would be cool if asmjit can add support for CFI directives (http://web.archive.org/web/20130111101034/http://blog.mozilla.org/respindola/2011/05/12/cfi-directives) like LLVM did. I am assuming ASMJIT doesn't have support for CFI directives currently, right? I guess I will have to generate .eh_header section manually outside ASMJIT then. |
No it doesn't, but I would definitely review a PR that adds CFI directives - I see a need for some support for defining unwind info. |
Leaving some notes/hints here in case anyone wants to implement this.
You need to write Dwarf information. Although the basic structure of For debugging/inspiration, the After having the
Windows exception handling works slightly different. The two main differences:
You register/deregister your unwind info using |
What about having directives that would help with these in AsmJit, would that help? |
Not sure what exactly you mean by "directives in AsmJit". For me, something like the following interface would be pretty helpful:
I am using the |
Something like that, but I think this would be possible to emit into an additional section instead of having a separate write process for that - that way it would work with Builder/Compiler as well. |
yes, I would also have "emit into separate section" in mind here. Conceptually, it would do something like
but afaik switching the section frequently is relatively expensive... |
So I am mostly interested in using the assembler to JIT compile machine code and then execute it. I was wondering is it possible to make the JIT code debuggable with GDB at runtime? Or with backtrack()? If not, does this mean there is no support for stack unwinding when I use the assembler?
(I have some external function which the JIT code will call that uses
int backtrace(void **buffer, int size);
(man 3 backtrace
) to get stack trace)For what I have read, stack unwinding (e.g. backtrack()) would require the JIT code to have a .eh_header ELF section and register it. Though, GDB requires different methodology for registering JIT code with itself (GDB requires registering debug symbols with itself and I .assuming that the assembler doesn't output any debug symbols section currently)
(source: http://www.corsix.org/content/libunwind-dynamic-code-x86-64)
The text was updated successfully, but these errors were encountered: