How to setup GDB stub server under DBGC/

This is for discussing general topics about how to use VirtualBox.
Post Reply
xoblautriv1
Posts: 1
Joined: 15. Jun 2022, 16:33

How to setup GDB stub server under DBGC/

Post by xoblautriv1 »

A while ago, a GDB stub server was implemented in changeset 86327.

How do I setup such a server? I tried settings the keys (Provider, StubType, Address and Port) with 'vboxmanage setextradata myvm DBGC/...' but this doesnt seem to work.

A dump of the CFGM tree shows the default entries only:

Code: Select all

[/DBGC/] (level 1)
  GlobalInitScript <string>  = "/home/user/.config/VirtualBox/dbgc-init" (cb=42)
  HistoryFile      <string>  = "/home/user/.config/VirtualBox/dbgc-history" (cb=45)
  LocalInitScript  <string>  = "/home/user/VirtualBox VMs/myvm/dbgc-init" (cb=42)
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How to setup GDB stub server under DBGC/

Post by scottgus1 »

There is only one mention of the characters "gdb" in the 6.1.34 manual, and it's part of a debug log setting for "VBoxManage debugvm". There doesn't appear to be any mention of a GDB server.

This might be the link to the changeset?
https://www.virtualbox.org/changeset/86327/vbox

This part:
Debugger: Allow for different I/O providers instead of only TCP
So far TCP was the only option to communicate remotely with the internal debugger, the other option
was to use the console from the GUI directly. This commit reworks basic I/O to allow for different
providers where TCP is just one option
. The second one being introduced is an IPC provider using a local
socket or named pipe
depending on the platform. This allows for Windows kernel debugging over a pipe
using the KD stub in VirtualBox and WinDbg running on the host (not tested yet).
To my uneducated reading (never heard of a GDB anything before) this sounds like different channels for an existing server, not a new server. I'm probably wrong, though, or maybe you meant "server" to refer to these new channels.

You can check to see if the 'vboxmanage extradata' commands worked by looking in the VM's .vbox file, especially after all Virtualbox process and windows are closed. If they're present as entered, then you'll need a forum source code guru to see why they're not being picked up.
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: How to setup GDB stub server under DBGC/

Post by fth0 »

xoblautriv1 wrote:A while ago, a GDB stub server was implemented in changeset 86327.
AFAICS, the GDB stub server is only available in the VirtualBox 6.1.97 development snapshots and in the public VirtualBox source code repository. Note that the currently available VirtualBox 6.1.97r150532 is several weeks older than the currently available VirtualBox source code.
scottgus1 wrote:To my uneducated reading (never heard of a GDB anything before)
We cannot leave you like that. ;)

The GNU Debugger (GDB) is a well-known debugger on Linux and Unix systems, just like WinDBG on Windows. When doing remote debugging, the debugger (e.g. GDB) runs on the local system, while a debugger stub (e.g. GDB server) runs on the target system. Hypervisors on Linux (e.g. QEMU/KVM) usually contain a small GDB server stub, so that you can debug the early stages of the guest OS with GDB from within the host OS.
klaus
Oracle Corporation
Posts: 1110
Joined: 10. May 2007, 14:57

Re: How to setup GDB stub server under DBGC/

Post by klaus »

fth0 is right that this was added after 6.1.x was branched off. It is present in the source code repo, and in the "development snapshots" on the test build page only.

Other than that, you made a mistake with the extradata key to CFGM key mapping. To end up in CFGM, the extradata key must be prefixed with VBoxInternal/, so to enable the GDB stub you'd need to set VBoxInternal/DBGC/GdbStub to 1.

That said - there is a reason why this isn't documented. It is just partly finished (hard to tell how much is working and what needs improving).
Post Reply