I'm a CS student that just learned basic mips for class (Patterson & Hennessy + spim), and I'm attempting to find a mips debugging solution that allows arbitrary instruction execution during the debugging process.
Attempt with gdb (so you know why not to suggest this)
The recommended mips cross compilation tool chain is qemu and gdb, see mips.com docs and related Q/A.
gdb's compile code command does not support mips-linux-gnu-gcc as far as I can tell, see gdb docs ("Relocating the object file") and related Q/A. I get errors for malloc, mmap, and invalid memory errors (something appears to be going wrong with the ad-hoc linking gdb performs) when attempting to use compile code with mips-linux-gnu-gcc, even after filtering the hard coded compilation arguments that mips-linux-gnu-gcc doesn't recognize.
Actual question
lldb has a similar command called expression, see lldb docs, and I'm interested in using lldb in conjunction with qemu. The expression command also relies on clang as opposed to gcc, but cross compilation in clang is relatively simple (clang -target mips-linux-gnu "just works"). The only issue is that qemu-mips -g launches gdbserver, and I can find no option for launching lldb-server.
I have read lldb docs on remote debugging, and there is an option to select remote-gdb-server as the platform. I can't find much in the way of documentation for remote-gdb-server, but the name seems to imply that lldb can be compatible with gdbserver.
Here is my attempt to make this work:
qemu-mips -g 1234 test
lldb test
(lldb) platform select remote-gdb-server
Platform: remote-gdb-server
Connected: no
(lldb) platform connect connect://localhost:1234
Platform: remote-gdb-server
Hostname: (null)
Connected: yes
(lldb) b main
Breakpoint 1: where = test`main + 16 at test.c:4, address = 0x00400530
(lldb) c
error: invalid process
Is there a way to either
- use
lldbwithgdbserver, or to - launch
lldb-serverfromqemu-mipsas opposed togdbserver
so that I can execute instructions while debugging mips code?
Note: I understand that I could instead use qemu system emulation to be able to just run lldb-server on the remote. I have tried to virtualize debian mips, using this guide, but the netinstaller won't detect my network card. Based on numerous SO Q/A and online forums, it looks like solving this problem is hard. So for now I am trying to avoid whole system emulation.