How do I setup debugging environment for xv6 kernel on a remote server?

97 Views Asked by At

I am working on the xv6 OS on a remote server (Ubuntu 20) through ssh-session supported by VScode. While I'm able to debug from the gdb command line, I would like to setup an interactive debug session. I installed the Native Debug extension available on VScode, after reading about how to do the above in the following blog https://shawnzhong.com/2019/03/25/co-debug-xv6-on-windows-using-vscode/

The following is what I see while running gdb from the terminal

baadalvm@baadalvm:~/personal_xv6/col331$ gdb kernel
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
Copyright (C) 2020 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:
<http://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 kernel...
+ target remote localhost:26000
The target architecture is assumed to be i8086
[f000:fff0]    0xffff0: ljmp   $0x3630,$0xf000e05b
0x0000fff0 in ?? ()
+ symbol-file kernel
(gdb) 

And the following is what I see when I start the run debug in VScode

Reading symbols from /home/baadalvm/personal_xv6/col331/kernel...
+ target remote localhost:26000
The target architecture is assumed to be i8086
[f000:fff0] 
   0xffff0: ljmp   $0x3630,$0xf000e05b
0x0000fff0 in ?? ()
+ symbol-file kernel
WARNING: Error executing command 'gdb-set target-async on'
warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration
of GDB.  Attempting to continue with the default 
i8086 settings.

The above appears in the debug console and I get the following error message when I try to start the debug session, before which I start the qemu-gdb target :- Failed to attach: Remote communication error. Target disconnected.:: Connection reset by peer.(from target-select remote:26000)

I think that the this problem couldn't have been caused by an unconfigured .gdbinit, as I did add my path to it and when I try to attach to the gdbserver via the command line it works.

Here is my launch.json

{
    "version": "0.2.0",
    "configurations": [
            {
                    "type": "gdb",
                    "request": "attach",
                    "name": "debug xv6",
                    "executable": "kernel",
                    "target": ":26000",
                    "remote": true,
                    "cwd": "${workspaceRoot}",
            }
    ]
}

Here is my tasks.json, to build the project for debugging

{
    "version": "2.0.0",
    "tasks": [
            {
                    "label": "compile xv6 and run in debug mode",
                    "command": "bash",
                    "args": [
                            "-c",
                            "make && make qemu-gdb"
                    ],
                    "presentation": {
                            "echo": true,
                            "reveal": "always",
                            "focus": true,
                            "panel": "new",
                            "showReuseMessage": true,
                            "clear": true
                    },
                    "group": {
                            "kind": "build",
                            "isDefault": true
                    }
            }
    ]
}
0

There are 0 best solutions below