Updated: October 28, 2024 |
You can use GDB to better understand and debug a guest OS's activities inside its hypervisor VM (qvm process instance).
For either method, when the GDB toolchain attaches to the qvm process instance, the VM is paused, allowing you to see symbol information for the VM context and hence, view OS variables and source code. Note that this is distinct from application-level debugging on the guest, although the guest applications will still be paused.
For more information about using GDB in a QNX environment, see the gdb entry in the QNX Neutrino Utilities Reference. For general information about GDB, see https://www.gnu.org/software/gdb/documentation/.
To use GDB, you must enable it in the qvm process instance (VM) hosting the guest you want to examine. To do this, specify the gdb option in the VM's *.qvmconf configuration file (see gdb in the VM Configuration Reference chapter). For example:
gdb 1234
For the hypervisor host, the guest is a blob. Since the GDB monitor runs on the hypervisor host, it pauses the guest indirectly by pausing the guest's vCPU threads in its qvm process instance.
The gdb paused configuration option is used to configure guest OS behavior at guest startup.
If the option is not specified, the qvm process allows the VM to run so the guest OS can start and run until GDB connects to the TCP/IP port specified in the configuration. When GDB connects to its port, the qvm process causes the guest OS to pause.
If the option is specified (e.g., gdb paused 1234), the qvm process pauses the VM prior to the first instruction executing on each vCPU. When the GDB server in the qvm process receives a single-stepping or continue command, it allows the guest OS to execute, according to the command.
The QNX OS includes GDB clients for all supported hardware architectures. QNX hypervisors run on 64-bit hardware, so you need either ntoaarch64-gdb (AArch64) or ntox86_64-gdb (x86-64).
Boot the hypervisor (see Booting the QNX hypervisor host).
You can configure your hypervisor to start your guests immediately, or start them later.
Use ifconfig to find out your hypervisor host domain's IP address (see ifconfig in the Utilities Reference).
If you are using TCP, you must have io-pkt-* running in your hypervisor host (see io-pkt-* in the Utilities Reference).
On your host computer terminal command line, start the GDB client version for your target board, either ntoaarch64-gdb or ntox86_64-gdb.
When prompted by the GDB client, specify that you want to connect to a remote target and provide your hypervisor host's IP address and the port number you specified for the gdb option. For example:
gdb> target remote 10.122.30.1:1234
where 10.122.30.1 is the IP address of the hypervisor host, and 1234 is the port number specified in the qvm configuration.
You should now be able to use any of the basic GDB commands to examine your guest's behavior.