[vbox-dev] Question about debugging VirtualBox

Klaus Espenlaub klaus.espenlaub at oracle.com
Tue Jun 6 18:16:26 GMT 2017


Hi,

On 06.06.2017 10:29, liqsub wrote:
> Hello all,
>
> I have a question about debuging VirtualBox in Linux environment.
>
> It seems the breakpoint doesn't got been hit.
>
> First I compile a debug version of VirtualBox.
> 1. start a vm: sudo gdb --args ./VirtualBox --comment ubuntu --startvm
> a3af2e12-957b-48a8-8b0c-1afe93fe2d2c --no-startvm-errormsgbox

Hope that you know what you're doing... running VMs as root should only 
be done for a really, really good reason. Has no impact on your debug 
problem, however.

> 2. set break point. For example:
>
> b vpciIOPortOut
>
> 3. in the guest, we trigger an IO access.
> outw(1,0xd020+0xe)

Did you register your IO callbacks successfully? Did the PCI mapping 
function get called?

> 4. In my mind, I think this will break at vpciIOPortOut function. But it
> doesn't, the vm just run without break.

If you do things correctly (and I assume that you're not playing with R0 
device emulation) then it will break.

Since you're talking about a PCI device, it'd be useful to get the 
output of (add sudo if you really must work as root)
$ VBoxManage debugvm "vmname" info pci
$ VBoxManage debugvm "vmname" info ioport

> 5. But as I change the outw to outl/outb.(This will make the 'cb' to be
> 1 or 4. The VM will crash.
> This crash is caused by following Assert in vpciIOPortOut function.
>
>         case VPCI_QUEUE_SEL:
>            Assert(cb == 2);
>             u32 &= 0xFFFF;
>             if (u32 < pState->nQueues)
>                 pState->uQueueSelector = u32;
>             else
>                 Log3(("%s vpciIOPortOut: Invalid queue selector %08x\n",
> INSTANCE(pState), u32));
>             break;
> So here I think outb/w/l in  guest does TRIGGER the call of
> vpciIOPortOut  function. But why does the vm not pause and goto gdb? Is
> there something I missed?

Really strange - assertions should be caught by gdb, too.

There's nothing fundamentally wrong with your debugging approach. It 
really should work, especially as you manage to run into assertions.

Klaus

>
> Thanks.
>
>
> --
>
> Li Qiang /the Gear Team, Qihoo 360 Inc



More information about the vbox-dev mailing list