-
Notifications
You must be signed in to change notification settings - Fork 628
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
Access to call stack when calling native functions #3779
Comments
NOTE: Calling |
Not sure if that helps, but native function has access to the exec_env structure, so in order to obtain the call stack, you could do something like (haven't tested, so there might be some syntax issues):
|
Not sure how to get the relevant info from the frame - there is an I have a solution now where I dump a stack trace to a string, through std::array<char, 1024> buf;
wasm_interp_create_call_stack(env);
wasm_interp_dump_call_stack(env, false, buf.data(), buf.size()); Then I parse the string to get the addresses and use it agains a lookup table I have created from a |
Actually this works; auto* inst = wasm_runtime_get_module_inst(env);
auto* module = wasm_runtime_get_module(inst);
auto ip = (uint32)(cur_frame->prev_frame->ip - ((WASMModule*)module)->load_addr); |
Yes, similarly, the function index can be calculated by doing the following: auto* inst = wasm_runtime_get_module_inst(env);
(uint32)(frame->function - inst->e->functions); see implementation of the
|
Feature
When a native function is called, I would like to be able to get the call stack
from the WASM side to see how the call originated.
Benefit
If anything goes wrong in the native code, it is often very helpful to see which file and line caused the issue in the web assembly code. For instance if I implement a
load_file()
function, and the file could not be found I can show an exception with information where this call was performed so it can be fixed.Implementation
Since call stack dumps can already be performed, this information should already be available?
Also it is fine if only addresses are provided, the native side can use separate debug info file to look up actual file name and line.
Alternatives
...
The text was updated successfully, but these errors were encountered: