Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug with hvt debug #548

Closed
a74731248 opened this issue Feb 18, 2023 · 6 comments
Closed

bug with hvt debug #548

a74731248 opened this issue Feb 18, 2023 · 6 comments
Assignees

Comments

@a74731248
Copy link

When I try to use live debugging of hvt unikernels, I meet some trouble. When I use command gdb --ex="target remote localhost:1234" test_hello.hvt connect to gdb, the another terminal exit with info as fellows:

root@9fbe6a174ca1:~/solo5/tests/test_hello# ../../tenders/hvt/solo5-hvt-debug --gdb test_hello.hvt
solo5-hvt-debug: Waiting for a debugger. Connect to it like this:
solo5-hvt-debug:        gdb --ex="target remote localhost:1234" KERNEL
solo5-hvt-debug: Connection from debugger at 127.0.0.1
solo5-hvt-debug: GDB: Exiting as we could not receive the next command from the debugger.
@dinosaure dinosaure self-assigned this Feb 18, 2023
@greydot
Copy link
Contributor

greydot commented Feb 27, 2023

Can confirm. GDB 12.1.

@reynir
Copy link
Contributor

reynir commented Feb 28, 2023

With gdb 10.1 it works for me FWIW

$ solo5-hvt-debug --gdb hello.hvt
solo5-hvt-debug: Waiting for a debugger. Connect to it like this:
solo5-hvt-debug: 	gdb --ex="target remote localhost:1234" KERNEL
solo5-hvt-debug: Connection from debugger at 127.0.0.1
            |      ___|
  __|  _ \  |  _ \ __ \
\__ \ (   | | (   |  ) |
____/\___/ _|\___/____/
Solo5: Bindings version v0.7.3
Solo5: Memory map: 512 MB addressable:
Solo5:   reserved @ (0x0 - 0xfffff)
Solo5:       text @ (0x100000 - 0x1dffff)
Solo5:     rodata @ (0x1e0000 - 0x215fff)
Solo5:       data @ (0x216000 - 0x2c0fff)
Solo5:       heap >= 0x2c1000 < stack < 0x20000000
2023-02-28 06:58:18 -00:00: INF [application] hello
2023-02-28 06:58:19 -00:00: INF [application] hello
2023-02-28 06:58:20 -00:00: INF [application] hello
2023-02-28 06:58:21 -00:00: INF [application] hello
Solo5: solo5_exit(0) called

What does GDB say?

@a74731248
Copy link
Author

With gdb 10.1 it works for me FWIW

$ solo5-hvt-debug --gdb hello.hvt
solo5-hvt-debug: Waiting for a debugger. Connect to it like this:
solo5-hvt-debug: 	gdb --ex="target remote localhost:1234" KERNEL
solo5-hvt-debug: Connection from debugger at 127.0.0.1
            |      ___|
  __|  _ \  |  _ \ __ \
\__ \ (   | | (   |  ) |
____/\___/ _|\___/____/
Solo5: Bindings version v0.7.3
Solo5: Memory map: 512 MB addressable:
Solo5:   reserved @ (0x0 - 0xfffff)
Solo5:       text @ (0x100000 - 0x1dffff)
Solo5:     rodata @ (0x1e0000 - 0x215fff)
Solo5:       data @ (0x216000 - 0x2c0fff)
Solo5:       heap >= 0x2c1000 < stack < 0x20000000
2023-02-28 06:58:18 -00:00: INF [application] hello
2023-02-28 06:58:19 -00:00: INF [application] hello
2023-02-28 06:58:20 -00:00: INF [application] hello
2023-02-28 06:58:21 -00:00: INF [application] hello
Solo5: solo5_exit(0) called

What does GDB say?

There is another terminal output:

root@9fbe6a174ca1:~/solo5/tests/test_hello# gdb --ex="target remote localhost:1234" test_hello.hvt
GNU gdb (GDB) 10.2
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from test_hello.hvt...
Remote debugging using localhost:1234
Truncated register 24 in remote 'g' packet
(gdb) r
Starting program: /root/solo5/tests/test_hello/test_hello.hvt
/bin/sh: 1: exec: /root/solo5/tests/test_hello/test_hello.hvt: not found
During startup program exited with code 127.
(gdb)

GDB 9.2 and GDB 10.2 are both not working properly.

@reynir
Copy link
Contributor

reynir commented Mar 3, 2023

I am able to reproduce on GDB 10.1 if I pass the KERNEL argument.

Searching for the error Truncated register 24 in remote 'g' packet I saw results suggesting that the remote doesn't support qSupported command and thus gdb guesses the registers (apparently incorrectly?!). And with the following command I can confirm that qSupported is not supported in solo5:

$ gdb --ex="set debug remote 1" --ex="target remote localhost:1234" dist/hello.hvt
GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from dist/hello.hvt...
Remote debugging using localhost:1234
Sending packet: $qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;xmlRegisters=i386#6a...Packet instead of Ack, ignoring it
Ack
Packet received: 
Packet qSupported (supported-packets) is NOT supported
Sending packet: $vMustReplyEmpty#3a...Ack
Packet received: 
Sending packet: $Hg0#df...Ack
Packet received: 
Sending packet: $qTStatus#49...Ack
Packet received: 
Packet qTStatus (trace-status) is NOT supported
Sending packet: $?#3f...Ack
Packet received: S00
Sending packet: $qfThreadInfo#bb...Ack
Packet received: 
Sending packet: $qL1200000000000000000#50...Ack
Packet received: 
Sending packet: $Hc-1#09...Ack
Packet received: 
Sending packet: $qC#b4...Ack
Packet received: 
Sending packet: $qAttached#8f...Ack
Packet received: 
Packet qAttached (query-attached) is NOT supported
Sending packet: $qOffsets#4b...Ack
Packet received: 
Sending packet: $g#67...Ack
Packet received: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000f8ffff1f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020001000000000000200000000000000080000001000000010000000100000001000000010000000
Truncated register 24 in remote 'g' packet
(gdb)

@reynir
Copy link
Contributor

reynir commented Mar 3, 2023

After diving into this I have discovered that it is due to gdb expecting more registers when it queries solo5-hvt-gdb's gdb server. In this commit I blank in the remaining registers which is definitely not the right thing to do, but it got me to a point where I could set breakpoints and run hello world: reynir@5396361

It is very unclear to me what registers are missing and in what order they are expected, and how we can keep up with this. I found gdb has a target xml format, but when I tried to use a custom target xml file I got an error that the architecture disagreed 🤷

@reynir
Copy link
Contributor

reynir commented Mar 4, 2023

Likely we want to use KVM_GET_FPU at least.

greydot added a commit to greydot/solo5 that referenced this issue Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants