Closed yli147 closed 1 year ago
Here are the steps which seem to work fine for me. Looks like gdb-multiarch
isn't reading debug info from provided executable for some reason, strange. With your instructions I have to do add-symbol-file ./bazel-bin/salus
to get it working. set directories ./src/
is not needed. Also we don't support guest debugging as of right now.
$ gdb-multiarch --symbols=bazel-bin/salus $ set architecture riscv:rv64 $ target remote localhost:1234 $ b primary_init $ c
After the breakpoint if I go to the TUI mode (Ctrl-x + a) I can see main.rs.
Hi Rajnesh, Thanks for your response, still not working even by using "gdb-multiarch --symbols=bazel-bin/salus", what's the version of your rust toolchain and gdb ? did you add some speicfic rust build option ? or anything other ?
And Yes, guest application debugging is not available right after the sret instruction
gdb-multiarch -v GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
Strange. These steps seem to work fine for me.
I'm using the below commands to build salus and debug, is there anything wrong ? By the way I can debug one riscv hello world application written by rust. so now I guess it should not the gdb issue. Are there any build options to force to build a debug version of salus ? or somthing related to rust toolchain ? Thanks
$ git clone https://github.com/rivosinc/salus.git $ cd salus/ $ git submodule update --init $ wget -c https://github.com/bazelbuild/bazelisk/releases/download/v1.16.0/bazelisk-linux-amd64 chmod a+x bazelisk-linux-amd64 $ ./bazelisk-linux-amd64 build //:salus-all $ {QEMU}/build/riscv64-softmmu/qemu-system-riscv64 \ -M virt,aia=aplic-imsic,aia-guests=4 -cpu rv64,v=on,vlen=256,elen=64,x-smaia=true,x-ssaia=true,sscofpmf=true -smp 1 -m 2048 -nographic \ -kernel bazel-bin/salus \ -device guest-loader,kernel=bazel-bin/test-workloads/tellus_guestvm,addr=0xc0200000 -s -S
Oh, it is caused by the --compilation_mode, with the below change, I can debug the salus now ! Thanks
$ vim ./.bazelrc Change the line build --compilation_mode=opt => build --compilation_mode=dbg
By the way, I can also debug the guest application by using the following steps:
$ gdb-multiarch --symbols=bazel-bin/salus $ set architecture riscv:rv64 $ target remote localhost:1234 $ b _run_guest $ b _guest_exit $ c It will stop in _run_guest, then step to the sret instruction $ b *0x80200000 $ c it will stop at 0x80200000 which is of the guest application $ remove-symbol-file -a 0x80200000 $ add-symbol-file ./bazel-bin/test-workloads/tellus $ b tellus.rs:464 $ c
Oh, it is caused by the --compilation_mode, with the below change, I can debug the salus now ! Thanks
$ vim ./.bazelrc Change the line build --compilation_mode=opt => build --compilation_mode=dbg
You can avoid all this by using make run_tellus_gdb
, it takes care of everything, including invoking qemu with -s -S
options.
ok, thanks !
I'm trying to use gdb to debug with the bazel-bin/salus, some steps are as below, but it looks like the gdb can't find the the source code for example main.rs based on symbol file bazel-bin/salus. Has anyone one worked with gdb ? Thanks
$ gdb-multiarch bazel-bin/salus $ set architecture riscv:rv64 $ target remote localhost:1234 $ set directories ./src/ $ add-symbol-file ./bazel-bin/test-workloads/guestvm $ add-symbol-file ./bazel-bin/test-workloads/tellus