<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Sep 9, 2019, at 7:07 AM, Terry Guo via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Jim,<br class=""><br class="">Thanks for your help. I implemented a WASM file plugin under folder Plugins/ObjectFile/WASM. Now the LLDB can make a target for .wasm file. My .wasm file is built with clang and -g option. It does contain dwarf informations spreaded in a series of .debug_xx sections. However I failed to set breakpoint against a function name:<div class=""><br class=""><div class=""> (lldb) target create "/home/projects/zz.wasm"<br class="">Current executable set to '/home/projects/zz.wasm' (wasm32).<br class="">(lldb) b main<br class="">Breakpoint 1: no locations (pending).<br class="">WARNING: Unable to resolve breakpoint to any actual locations.</div><div class=""><br class=""></div><div class="">Is this related to Symtab? Currently I left function "Symtab *ObjectFileWASM::GetSymtab()" as empty function because the .wasm file doesn't include one. Or should I make LLDB to utilize the .debug_line information? I couldn't figure out which information should be used to enable LLDB to correctly set the breakpoint. Thanks in advance.</div></div></div></div></blockquote><div><br class=""></div>The ObjectFile subclasses are asked to create sections with the virtual:</div><div><br class=""></div><div> virtual void ObjectFile::CreateSections(SectionList &unified_section_list) = 0;</div><div><br class=""></div><div>In this function you must correctly create sections and give them appropriate lldb::<span style="background-color: rgb(255, 255, 255);" class="">SectionType enum values. For ".debug_info", this should be </span><span style="background-color: rgb(255, 255, 255);" class="">eSectionTypeDWARFDebugInfo. There are many others. Check out the other ObjectFile subclasses like </span><span style="background-color: rgb(255, 255, 255);" class="">ObjectFilePECOFF::CreateSections() to see how they do this. Many object files have different naming mechanisms and restrictions (mach-o can only have 16 character section names in ObjectFileMachO), so we leave the conversion of section types to each ObjectFile since they can use flags, section names, and more to determine what kind of sections are available from their specific object file. Code that uses DWARF will ask for a section using lldb::SectionType values. If you fix this, the DWARF should be found and parsed and you might be able to set a breakpoint. We also do this to avoid code having to ask for sections by name, and then retry all sorts of different section names (".debug_info" for most, then fall back to "__debug_info" for mach-o, and add more for different object files in the future). This keeps the code that needs to access DWARF cleaner.</span></div><div><span style="background-color: rgb(255, 255, 255);" class=""><br class=""></span></div><div><span style="background-color: rgb(255, 255, 255);" class="">Greg</span></div><div><span style="background-color: rgb(255, 255, 255);" class=""><br class=""></span><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class=""><br class=""></div><div class="">BR,</div><div class="">Terry<br class=""><br class="">On Wed, Aug 28, 2019 at 1:27 AM Jim Ingham <<a href="mailto:jingham@apple.com" class="">jingham@apple.com</a>> wrote:<br class="">><br class="">> You would need to implement an ObjectFile and SymbolFile plugin for your .wasm files for lldb to make a Target for them.<br class="">><br class="">> Jim<br class="">><br class="">><br class="">> > On Aug 26, 2019, at 6:27 PM, Terry Guo via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a>> wrote:<br class="">> ><br class="">> > Hi Raphael,<br class="">> ><br class="">> > Thanks for your recommendation. How about the very first step which<br class="">> > enables LLDB to recognize the wasm bytecode via commands like "lldb<br class="">> > my.wasm" or "file my.wasm" inside lldb? And IMHO the second step is to<br class="">> > enable LLDB to recognize the dwarf sections embedded in wasm bytecode<br class="">> > file. Do you have any suggestion where to start? I searched around and<br class="">> > couldn't find useful instructions/documentations for above two steps.<br class="">> ><br class="">> > BR,<br class="">> > Terry<br class="">> ><br class="">> ><br class="">> > On Mon, Aug 26, 2019 at 7:03 PM Raphael “Teemperor” Isemann<br class="">> > <<a href="mailto:teemperor@gmail.com" class="">teemperor@gmail.com</a>> wrote:<br class="">> >><br class="">> >> +lldb-dev<br class="">> >><br class="">> >> On 26. Aug 2019, at 12:57, Raphael “Teemperor” Isemann <<a href="mailto:teemperor@gmail.com" class="">teemperor@gmail.com</a>> wrote:<br class="">> >><br class="">> >> If I understand correctly your VM is your own custom wasm interpreter/JIT? If yes, then I don’t think it is realistic that LLDB can ever support it out of the box. But you can write a LLDB plugin that calls your own interpreter-implementations of functions such as stepping/continue/settings breakpoints, etc. Quick google search shows this example of doing the same for the Ruby interpreter that hopefully illustrates what I mean: <a href="https://christoph.luppri.ch/articles/ruby/debugging-ruby-programs-on-osx-with-lldb/" class="">https://christoph.luppri.ch/articles/ruby/debugging-ruby-programs-on-osx-with-lldb/</a><br class="">> >><br class="">> >> - Raphael<br class="">> >><br class="">> >> On 26. Aug 2019, at 12:37, Terry Guo <<a href="mailto:flameroc@gmail.com" class="">flameroc@gmail.com</a>> wrote:<br class="">> >><br class="">> >> Hi Raphael,<br class="">> >><br class="">> >> Thanks. I mean the first case, attaching to my vm and then debugging via LLDB like setting breakpoint, single step or viewing the memory of wasm application.<br class="">> >><br class="">> >> BR,<br class="">> >> Terry<br class="">> >><br class="">> >> On Mon, Aug 26, 2019 at 5:59 PM Raphael “Teemperor” Isemann <<a href="mailto:teemperor@gmail.com" class="">teemperor@gmail.com</a>> wrote:<br class="">> >>><br class="">> >>> I’m not sure I understand what the question is. Do you want that LLDB attachs to the wasm program running inside your VM and then debug the wasm program via LLDB? Or that LLDB can run the wasm module itself like an executable and then run it/step through it/inspect it/etc.?<br class="">> >>><br class="">> >>> Cheers,<br class="">> >>> - Raphael<br class="">> >>><br class="">> >>>> On 26. Aug 2019, at 11:47, Terry Guo via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a>> wrote:<br class="">> >>>><br class="">> >>>> Hi there,<br class="">> >>>><br class="">> >>>> I am working on a project which involves compiling C++ source file to Webassembly byte code file with LLVM. The LLVM works well and can generate wasm byte code file with DWARF debug sections like .debug_line. I can run the generated wasm file with my wasm virtual machine. However I find LLDB doesn't support debugging wasm file. Do we have plan to enable LLDB debugging wasm file? Thanks for any information.<br class="">> >>>><br class="">> >>>> BR,<br class="">> >>>> Terry<br class="">> >>>> _______________________________________________<br class="">> >>>> lldb-dev mailing list<br class="">> >>>> <a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a><br class="">> >>>> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br class="">> >>><br class="">> >><br class="">> >><br class="">> > _______________________________________________<br class="">> > lldb-dev mailing list<br class="">> > <a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a><br class="">> > <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br class="">></div></div></div>
_______________________________________________<br class="">lldb-dev mailing list<br class=""><a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev<br class=""></div></blockquote></div><br class=""></body></html>