Open
Description
Working on binaryen support for DWARF, I realized I don't know how to read the line info data. The main issues are:
- The code addresses doc says offsets are
the offset of an instruction relative within the Code section of the WebAssembly file
. Does "the Code section" include the entire code section, with the0xa0
byte to declare the code section and the LEB for the length? Or just the body, without those? - Can debug lines refer to code section offsets that are not code? (Like the function declarations.)
- Can debug lines refer to inner parts of an instruction, and not the start?
In more detail here is what I am trying: I started with @yurydelendik 's fib2 sample,
__attribute__((used))
int fib(int n) {
int i, t, a = 0, b = 1;
for (i = 0; i < n; i++) {
t = a;
a = b;
b += t;
}
return b;
}
and I build it with
clang fib2.c -O3 -g -o fib2.clang.wasm -target wasm32-unknown-emscripten -nostdlib -Wl,--no-entry
LLVM's dwarfdump says this:
Address Line Column File ISA Discriminator Flags
------------------ ------ ------ ------ --- ------------- -------------
0x0000000000000002 2 0 1 0 0 is_stmt
0x000000000000000b 4 17 1 0 0 is_stmt prologue_end
0x0000000000000010 4 3 1 0 0
0x0000000000000012 0 3 1 0 0
0x000000000000001e 7 7 1 0 0 is_stmt
0x0000000000000025 0 7 1 0 0
0x0000000000000029 4 17 1 0 0 is_stmt
0x000000000000002e 4 3 1 0 0
0x0000000000000034 9 3 1 0 0 is_stmt
0x0000000000000037 9 3 1 0 0 is_stmt end_sequence
The first line there says address 2. If the offset is in the code section body, then that's in the middle of the function declaration, and not executable code. Is that expected?
The fifth line has address 0x1e
. Looking in the binary, though, the code section's body starts at 0x2d
, and adding the offset we get 0x4b
. That is the second out of 2 bytes of an i32.const -1
, which seems odd?
Metadata
Metadata
Assignees
Labels
No labels