Re: Virtual Machine and GDB

Daniel Jacobowitz
2006-08-21T12:48:12Z

On Mon, Aug 21, 2006 at 01:22:34PM +0100, Cai Qian wrote:
> Hi,
>
> On 8/21/06, teawater <teawater@gmail.com> wrote:
> >Does GDB support the ARCH of you VM?
> >
>
> Sorry, what do you mean by GDB support the ARCH of VM? Do you mean
> port GDB? Does it really necessary to port GDB to the VM? At the
> moment, GDB can't run natively on my VM, nor gdbserver. I am wondering
> if I can still do remote debugging. According to the document [1], it
> seems I can create a remote stub for the target, and then link it to
> the program I am going to run on the target, ie, to implement at least
> the following functions,
>
> getDebugChar, putDebugChar, flush_i_cache, memset, exceptionHandler
>
> Although there are lots of things unclear,

No no no. This is almost certainly not what you want to do. This bit
of the documentation is not actually relevant.

You want to debug the bare code running inside the virtual machine,
right? Then what you probably want to do is a stub integrated directly
with the source code of the virtual machine. Then that stub can
respond to a single step packet by requesting the virtual machine
execute one instruction, and so forth. The stub runs outside the VM.

> 2) Can't find information on what kind of debug features I can have
> when after implementing the remote stub. Breakpoint, watchpoint,
> single step?

See the remote protocol appendix in the GDB manual. All of those are
supported.

> 3) Not sure how to write a download program to download executable
> from target to host in a debug session.
>
> [1] http://sources.redhat.com/gdb/current/onlinedocs/gdb_18.html#SEC160

You don't need one; you can either use "load", or you can load directly
from the virtual machine and just have GDB connect.

--
Daniel Jacobowitz
CodeSourcery