-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Debug support for non-x86 architectures #2856
Comments
Hi @cfallin, this is the topic we talked about recently. I just wanted to open this issue to document all the places I've found where there is currently X86-specific code in the debug crate. |
I took a brief look at this for the purposes of avoiding unexpected behaviour on AArch64. So I focused more on the references to x86 registers and not at all on the questions around endianess. The only two locations that appear to reference X86 registers in transform/expression.rs are:
in both cases, the code is only run when a wasmtime/crates/cranelift/src/debug/transform/expression.rs Lines 1159 to 1200 in 9c43749
Based on that, I don't think the two pieces of code that reference the x86 stack pointer register will ever execute outside of tests. Perhaps the tests and the setup for them can be rewritten such that they no longer use the |
It looks to me like wasmtime/cranelift/codegen/src/machinst/vcode.rs Lines 1095 to 1108 in ca36ce5
If this is a common thing across different platforms using DWARF, should |
The way this normally works in DWARF is that the location of local variables and spillslots is specified via the These days, it is often easiest to specify that frame base in terms of DWARF CFI unwind information (note that DWARF debug info and DWARF unwind info are separate entities - but if you have both, it makes sense to avoid duplication). This works by defining The compiler is free to choose where exactly to place the "frame base", so we have some options here. We could define the frame base at either the top or the bottom of the fixed frame area - that makes variable locations trivial to define, but then we'd need to provide the information from the compiler to the debug crate what the (per-function) offset from the CFA to that frame base is. Or else, we could define the frame base to be always identical to the CFA, which would make the implementation in the debug crate trivial and avoid this new interface, but would make the definition of variable locations a little bit more complex (but that's all in the compiler backend which knows everything about the frame layout anyway). In either case, to describe variable locations we would not use an SP offset, but rather a frame base offset, so we should eliminate @cfallin any thoughts on this? |
Yes, I agree that making everything relative to FP would be substantially simpler here: it would let us translate spillslot addresses without regard to emission state (nominal-SP offset) in the code linked above. In general we really need someone to do an overhaul of our DWARF translation code and this is one concrete example -- unfortunately just no one has the time at the moment :-/ |
Feature
Support debugging JITted WebAssembly code on non-x86 platforms.
Benefit
Currently, the debug crate only supports x86. All other platforms should be supported as well.
Implementation
There are a number of places that currently prevent the debug crate from supporting non-x86 platforms:
(This should just go away, I think.)
(This is only used for old-style back-ends and can probably go away soon.)
(This should probably use the register mapper that unwinder code also uses.)
Various little-endian assumptions accessing ELF files and WebAssembly memory
(See debug: Support big-endian architectures #2854 for details.)
Additional endian issues (not solved by the PR above) in creating DWARF expressions
Current code in transform/expression.rs simply copies portions of the incoming WebAssembly DWARF expressions directly into the native DWARF output. This is not correct in case the native architecture is big-endian. Fortunately, the byte code for many DWARF expressions is not endian-sensitive, so I can actually debug simple applications even so. But to be fully correct, those portions of DWARF bytecode that are endian-sensitive will need to be handled here somehow.
The text was updated successfully, but these errors were encountered: