-
Notifications
You must be signed in to change notification settings - Fork 575
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
Get location info from function indexes in addr2line script #3206
Get location info from function indexes in addr2line script #3206
Conversation
Tested with a few simple examples: int
c(int n)
{
__builtin_trap();
}
int
b(int n)
{
n += 3;
return c(n);
}
int
a(int n)
{
return b(n);
}
int
main(int argc, char **argv)
{
int i = 5;
a(i);
return 0;
} fn c(_: i32) -> i32 {
panic!("this is a panic!");
}
fn b(mut n: i32) -> i32 {
n += 3;
c(n)
}
fn a(n: i32) -> i32 {
b(n)
}
fn main() {
let i = 5;
a(i);
} If I want to run it in CI, should I add a new folder in |
print(line) | ||
_, offset, index = splitted | ||
if not index.startswith("$f"): | ||
print(f"{i}: {index}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wondering what kind of case it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That happens with _start
#00: 0x0159 - $f5
#01: 0x01b2 - $f6
#02: 0x0200 - $f7
#03: 0x026b - $f8
#04: 0x236b - $f15
#05: 0x011f - _start
I added a comment in the code.
location = line | ||
return (function_name, location) | ||
if "DW_AT_decl_line" in line: | ||
function_line = get_dwarf_tag_value("DW_AT_decl_line", line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated with L154 and L155 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? L154-155 are for the file, L157-158 for the line
@eloparco how about creating a new folder under samples, so it not only tests the tool but also shows the usage for the developers. |
413eb3c
to
d3d1918
Compare
That's what I had in mind as well, added it. When I use AOT, the first stack frame address seems to be incorrect: #00: 0x0000 - $f5
#01: 0x01ac - $f6
#02: 0x01fa - $f7
#03: 0x0265 - $f8
#04: 0x2365 - $f15
#05: 0x0119 - _start I'm compiling with |
cbb4d81
to
68fba3f
Compare
68fba3f
to
10927db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM |
…3211) Last bit missing from #3206: demangling of function names (useful for wasm generated from Rust for instance) using `llvm-cxxfilt`. Before this PR: ```text 0: abort at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/panic_abort/src/lib.rs:85 1: _ZN3std3sys4wasi14abort_internal17h50698daab05bf73bE at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys/wasi/mod.rs:181 2: _ZN3std7process5abort17h6bc522b6749f17cfE at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/process.rs:2278 3: _ZN3std5alloc8rust_oom17h452ad5ba6cebff96E at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/alloc.rs:364 ``` After: ```text 0: abort at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/panic_abort/src/lib.rs:85 1: std::sys::wasi::abort_internal::h50698daab05bf73b at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys/wasi/mod.rs:181 2: std::process::abort::h6bc522b6749f17cf at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/process.rs:2278 3: std::alloc::rust_oom::h452ad5ba6cebff96 at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/alloc.rs:364 ```
…alliance#3206) Update the `addr2line` script so that: - line info is printed in a more convenient format, e.g. ``` 0: c at wasm-micro-runtime/test-tools/addr2line/trap.c:5:1 1: b at wasm-micro-runtime/test-tools/addr2line/trap.c:11:12 2: a at wasm-micro-runtime/test-tools/addr2line/trap.c:17:12 ``` similar to how Rust prints stack traces when there's a panic. In an IDE, the user can conveniently click on the printed path and be redirected to the file line. - a new `--no-addr` argument can be provided to the script It can be used in fast interpreter mode (that is not supported by the script otherwise) or with older wamr versions (where the stack trace only had the function index info and not the function address). In that case, `wasm-objdump` is used to get the function name from the index and `llvm-dwarfdump` to obtain the location info (where the line refers to the start of the function).
…alliance#3206) Update the `addr2line` script so that: - line info is printed in a more convenient format, e.g. ``` 0: c at wasm-micro-runtime/test-tools/addr2line/trap.c:5:1 1: b at wasm-micro-runtime/test-tools/addr2line/trap.c:11:12 2: a at wasm-micro-runtime/test-tools/addr2line/trap.c:17:12 ``` similar to how Rust prints stack traces when there's a panic. In an IDE, the user can conveniently click on the printed path and be redirected to the file line. - a new `--no-addr` argument can be provided to the script It can be used in fast interpreter mode (that is not supported by the script otherwise) or with older wamr versions (where the stack trace only had the function index info and not the function address). In that case, `wasm-objdump` is used to get the function name from the index and `llvm-dwarfdump` to obtain the location info (where the line refers to the start of the function). Signed-off-by: victoryang00 <victoryang00@ucsc.edu>
…alliance#3206) Update the `addr2line` script so that: - line info is printed in a more convenient format, e.g. ``` 0: c at wasm-micro-runtime/test-tools/addr2line/trap.c:5:1 1: b at wasm-micro-runtime/test-tools/addr2line/trap.c:11:12 2: a at wasm-micro-runtime/test-tools/addr2line/trap.c:17:12 ``` similar to how Rust prints stack traces when there's a panic. In an IDE, the user can conveniently click on the printed path and be redirected to the file line. - a new `--no-addr` argument can be provided to the script It can be used in fast interpreter mode (that is not supported by the script otherwise) or with older wamr versions (where the stack trace only had the function index info and not the function address). In that case, `wasm-objdump` is used to get the function name from the index and `llvm-dwarfdump` to obtain the location info (where the line refers to the start of the function).
…ytecodealliance#3211) Last bit missing from bytecodealliance#3206: demangling of function names (useful for wasm generated from Rust for instance) using `llvm-cxxfilt`. Before this PR: ```text 0: abort at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/panic_abort/src/lib.rs:85 1: _ZN3std3sys4wasi14abort_internal17h50698daab05bf73bE at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys/wasi/mod.rs:181 2: _ZN3std7process5abort17h6bc522b6749f17cfE at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/process.rs:2278 3: _ZN3std5alloc8rust_oom17h452ad5ba6cebff96E at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/alloc.rs:364 ``` After: ```text 0: abort at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/panic_abort/src/lib.rs:85 1: std::sys::wasi::abort_internal::h50698daab05bf73b at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys/wasi/mod.rs:181 2: std::process::abort::h6bc522b6749f17cf at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/process.rs:2278 3: std::alloc::rust_oom::h452ad5ba6cebff96 at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/alloc.rs:364 ```
…alliance#3206) Update the `addr2line` script so that: - line info is printed in a more convenient format, e.g. ``` 0: c at wasm-micro-runtime/test-tools/addr2line/trap.c:5:1 1: b at wasm-micro-runtime/test-tools/addr2line/trap.c:11:12 2: a at wasm-micro-runtime/test-tools/addr2line/trap.c:17:12 ``` similar to how Rust prints stack traces when there's a panic. In an IDE, the user can conveniently click on the printed path and be redirected to the file line. - a new `--no-addr` argument can be provided to the script It can be used in fast interpreter mode (that is not supported by the script otherwise) or with older wamr versions (where the stack trace only had the function index info and not the function address). In that case, `wasm-objdump` is used to get the function name from the index and `llvm-dwarfdump` to obtain the location info (where the line refers to the start of the function). Signed-off-by: victoryang00 <victoryang00@ucsc.edu>
…alliance#3206) Update the `addr2line` script so that: - line info is printed in a more convenient format, e.g. ``` 0: c at wasm-micro-runtime/test-tools/addr2line/trap.c:5:1 1: b at wasm-micro-runtime/test-tools/addr2line/trap.c:11:12 2: a at wasm-micro-runtime/test-tools/addr2line/trap.c:17:12 ``` similar to how Rust prints stack traces when there's a panic. In an IDE, the user can conveniently click on the printed path and be redirected to the file line. - a new `--no-addr` argument can be provided to the script It can be used in fast interpreter mode (that is not supported by the script otherwise) or with older wamr versions (where the stack trace only had the function index info and not the function address). In that case, `wasm-objdump` is used to get the function name from the index and `llvm-dwarfdump` to obtain the location info (where the line refers to the start of the function). Signed-off-by: victoryang00 <victoryang00@ucsc.edu>
…alliance#3206) Update the `addr2line` script so that: - line info is printed in a more convenient format, e.g. ``` 0: c at wasm-micro-runtime/test-tools/addr2line/trap.c:5:1 1: b at wasm-micro-runtime/test-tools/addr2line/trap.c:11:12 2: a at wasm-micro-runtime/test-tools/addr2line/trap.c:17:12 ``` similar to how Rust prints stack traces when there's a panic. In an IDE, the user can conveniently click on the printed path and be redirected to the file line. - a new `--no-addr` argument can be provided to the script It can be used in fast interpreter mode (that is not supported by the script otherwise) or with older wamr versions (where the stack trace only had the function index info and not the function address). In that case, `wasm-objdump` is used to get the function name from the index and `llvm-dwarfdump` to obtain the location info (where the line refers to the start of the function). Signed-off-by: victoryang00 <victoryang00@ucsc.edu>
Updating the
addr2line
script so that:similar to how Rust prints stack traces when there's a panic. In an IDE, the user can conveniently click on the printed path and be redirected to the file line.
--no-addr
argument can be provided to the scriptIt can be used in fast interpreter mode (that is not supported by the script otherwise) or with older wamr versions (where the stack trace only had the function index info and not the function address). In that case,
wasm-objdump
is used to get the function name from the index andllvm-dwarfdump
to obtain the location info (where the line refers to the start of the function).