Re: gdb internal functionality

Michael Snyder
2008-11-07T18:22:34Z

raja.saleru@iap-online.com wrote:
> Hi,
>
> I would like to know more of GDB internals especially the control flow and
> functionality for the following gdb commands. For ex. the development
> environment include gdb on cygwin environment, which is connected to
> OpenOCD, which inturn connects to ARM target. Any information on this
> would be very helpful.
>
> 1. target remote host:port

Set a breakpoint at remote_open_1, then look at
your call stack.

> 2. stepi

break at stepi_command.

> 3. contrinue

break at continue_command.

> 4. break linenum

This is complex. You'll need to look around within
breakpoint.c and, if you want to get down and dirty,
in linespec.c.

> 5. delete bpnum

break at delete_command.

> 6. watch expression

watch_command

> 7. set/read register value

There is no "set register" command. You can just
use the regular "set" command to assign a value to
a register, eg. "set $pc = 0xfeedface".

The internal code for manipulating and storing
register values is quite complex -- start by looking
at regcache.c.

> 8. read/write memory

Also quite complex. There is a function pointer
called "to_xfer_partial" (I know, probably seems
non-intuitive). It lives in a struct called a "target_ops",
which is defined in target.c.

Since you're using "target remote", this pointer will
point to "remote_xfer_partial". You can start looking
there.

> 9. quit

break at quit_command.

> 10. monitor reset

"monitor" is a prefix command that means "send the
following to my target, without interpreting it".

So "reset" is a command that will be passed to your target.

You can find "monitor_command" in target.c, and for
the remote target, it will be implemented by function
"remote_rcmd" in remote.c