Add wasm_runtime_get_func_name_from_index() api#4117
Add wasm_runtime_get_func_name_from_index() api#4117Jiax-cn wants to merge 1 commit intobytecodealliance:mainfrom
Conversation
|
If the goal is to enhance the readability of the performance map, perhaps we should consider enhancing the functionality of process_folded_data.py. WASM_RUNTIME_API_EXTERN const uint8_t *
wasm_runtime_get_custom_section(const wasm_module_t module_comm,
const char *name, uint32_t *len);can retrieve the content of the name section. With this information, the host can complete the mapping between function indices and their names. Personally, I think using an index to retrieve a name is an infrequent operation. |
I’ve read this script. IIUC, it uses WABT to extract function names and add them to perf.folded. It might be more straightforward to add them when writing perf.map. Moreover, I think the second scenario—using function names when adding functions in LLVM—is necessary, which process_folded_data.py cannot address.
It’s fine to remove this API from wasm_export.h. We can make this PR a unification of the distributed functions. aot_runtime.c static const char *
get_func_name_from_index(const AOTModuleInstance *module_inst,
uint32 func_index)wasm_runtime.c static char *
get_func_name_from_index(const WASMModuleInstance *inst, uint32 func_index) |
Originally posted by @lum1n0us in #4113 (comment) This PR has been reviewed and discussed. I am closing it but will keep my branch for future reference. |
WAMR already implements this function, but its scope is limited to the source file and only applies to the module instance. I reimplemented this because it is clearer to obtain function names in the following scenarios, where the (WASM/AOT) module has not yet been instantiated:
aot_create_perf_map()This creates /tmp/perf-.map for linux-perf.aot_add_llvm_func1()By doing so, LLVM can include function names in the IR and machine code, allowing us to see them in the call stack when debugging AOT with LLDB/GDB.If this is useful, I would be happy to submit PRs for these two scenarios.