Enable debugger for guest environments
This branch contains an attempt to use the gdb-stub library. It's best to hold off on this until parts of preflight and/or continuations are implemented
Since GDB adds support to Microsoft's debug adapter protocol, maybe an alternative path is to integrate with this. https://www.phoronix.com/news/GDB-Debug-Adapter-Protocol
I can see that it has been held off. I would try on my side a bit to see if a minimal remote debugger can be implemented for https://github.com/weikengchen/zkctf-r0.
Ok I am back to the team of gdb-stub. The key is to avoid reinventing the wheels for RISC-V GDB support.
Hello guys, how is this issue progressing? I am really looking forward to the debugger feature, as it can save lives(without print! or gdb! and re-compile). I can assist with this work.
@dyxushuai check this https://github.com/l2iterative/gdb0
@dyxushuai check this l2iterative/gdb0
Great job!
What about lldb support for Rust? It could be more convenient for llvm based langauges. We can integrate with wasm origin guest rust code in a wasm-vm briefly using the vscode extension vscode-lldb without any modification.
But additionally, we need to use dwarf instead of fp. However, rust has good support for dwarf.
@dyxushuai check this l2iterative/gdb0
Great job!
What about
lldbsupport for Rust? It could be more convenient for llvm based langauges. We can integrate withwasmorigin guest rust code in a wasm-vm briefly using the vscode extension vscode-lldb without any modification.But additionally, we need to use `dwarf` instead of `fp`. However, rust has good support for `dwarf`.
And, I think we only need very little work to achieve such results in risc0-vm. I am verifying this POC with some simple code locally.
current lldb version appears to not support RISC-V
current lldb version appears to not support RISC-V
Yeah, riscv ABI was fully supported only recently in llvm^1, I have noticed that some projects have already worked with riscv-32. Like: https://github.com/compnerd/ds2. Therefore, I believe we can support lldb in risc0. However, you must use a very new version of lldb to be able to use it.
That would be something that I need to revisit.
Nevertheless, there is yet another challenge. LLDB remote debugger has some different behaviors from GDB. The Rust crate, gdb-stub, only supports GDB, and appears to be struggling with LLDB. It is uncertain if the issue has been fixed.
So if you encounter weird behaviors like LLDB is single-stepping in a non-stoppable way, it is known and has been a few years.
@weikengchen thanks for your work! I tried implementing this a few months ago and encountered an error in gdbstub saying that it got an error from the version of gdb that I was using so I really appreciate the notes you wrote down (note, i'm using arm macos).
But additionally, we need to use `dwarf` instead of `fp`. However, rust has good support for `dwarf`.