Diving in to figure out if fixed trunk or comprehend problem if still an issue.
Here's how to build lldb for Windows from llvm trunk.
pastebin.com/ZR6Z7PPB
Builds for me.
lldb developer has got back to us on discord.
https://discord.com/channels/636084430946959380/636732809708306432
"On Windows you build native COFF objects or ELF with MinGW? Debugging ELF via GDB JIT Interface works again with LLDB since release 12"
More details --> https://weliveindetail.github.io/blog/post/2021/04/19/lldb-12-jit-interface.html
Can anyone answer his question, plz. I don't understand what's going on here at all yet.
Debugging ELF via GDB JIT Interface works again with LLDB since release 12
wasmtime generates COFF or ELF debug object please.
here's apparently what's going on : https://alexene.dev/2020/09/04/webassembly-without-the-browser-part-2.html
issue presented as suspected lldb (windows) bug, here : https://discord.com/channels/636084430946959380/636732809708306432
https://bugs.llvm.org/show_bug.cgi?id=51832
got lldb running under visual studio debugger. issue appears to be inability to resolve __jit_debug_register_code function.
on windows, to expose functions for external access, function must be declared
where defined : extern "C" __declspec(dllexport)
where accessed (statically) : extern "C" __declspec(dllimport)
suspect wasmtime runtime and/or lldb not doing this.
trying to locate where wasmtime accesses or defines this function.
search thru entire wasmtime repo didn't find jit_debug_register_code
unclear how the gdb jit interface binds. clues welcome.
I think that can be added here: https://github.com/bytecodealliance/wasmtime/blob/4376cf2609df7abe48174aade0907b90f3f2b58a/crates/runtime/src/helpers.c#L46
thanks bjorn3 :) so ... that's not declared __declspec(dllexport) so lldb can't find it ... so appears the bug. or at least one of them.
also the asm isn't defined so function might be optimized out. so bug at this point looks to be wasmtime, not lldb.
a little further :)
weird. have that marked export too.
why isn't that found ?
ADV_SW_PATCH in above to locate 2 tiny changes.
never tried exporting data before, only functions so maybe have the syntax wrong.
next issue appears to be lldb insisting on binding debug descriptor as data & windows perhaps not giving it that much info. so a tweak on lldb side.
https://lldb.llvm.org/cpp_reference/JITLoaderGDB_8cpp_source.html
line 201 - going to change that to Any & see if it binds.
& that's it :) tiny fix in wasmtime, tiny one in lldb :)
LLDB fix : llvm-project\lldb\source\Plugins\JITLoader\GDB\JITLoaderGDB.cpp
module_list, ConstString("__jit_debug_descriptor"), eSymbolTypeAny); //eSymbolTypeData);
needs tidying so it can ensure qualified search where platform allows it, but that's essentially it.
if anyone knows how to query whether a symbol is data or function on windows, happy to take it all the way.
so ... 2 tiny changes that affect windows only build in 1 file required to resolve. both in here marked ADV_SW_PATCH
file: wasmtime/crates/runtime/src/helpers.c
https://pastebin.com/dknDqn9z
how should I submit the patch - via git ?
lldb change so you can verify & access early if you'd like, as follows :
file: llvm-project\lldb\source\Plugins\JITLoader\GDB\JITLoaderGDB.cpp
m_jit_descriptor_addr = GetSymbolAddress(
module_list, ConstString("__jit_debug_descriptor"),
#ifdef _MSC_VER
// Windows implementation not indicating symbol is Data so we use Any as workaround for the time being.
eSymbolTypeAny);
#else
eSymbolTypeData);
#endif
if anyone with rights wants to just drop that in, please just do it. chances of it breaking anything that was working previously is very remote.
or happy to submit formally when I can figure out how.
sorry, I'm stupid - how do I submit a patch please. tried git push but insufficient access.
ahhh - we're doing this as git issues ?
wasmtime_windows_export_jit.diff
On github the normal way to submit a patch would be to push the commit to your fork of the target repo and then open a pull request.
thanks, bjorn3 :) lets see if I can fail my way through that :)
lldb issue in process here if that interests anybody : https://reviews.llvm.org/D110066
forked this & took it forward. might interest you guys too.
https://github.com/adv-sw/lldbg
That looks nice. It uses DWARF?
ELF afaik - whatever wasmtime emits via GDB/JIT interface, but aside from a few custom tweaks, its basically lldb front end, so anything lldb can debug.
still early, stlll bits that need fixing up, but its basically sound now. thanks.
just fixed breakpoint toggle.
Last updated: Dec 23 2024 at 12:05 UTC