gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use a gdb-stub?


From: Charles Manning
Subject: Re: How to use a gdb-stub?
Date: Mon, 18 Aug 2008 12:48:45 +1200
User-agent: KMail/1.9.6

On Saturday 16 August 2008 20:38:31 TriKri wrote:
> In my case, I use a JTAG to communicate with the target system's CPU (a
> MIPS), so I don't think gdb-server will do the thing. I will need to have
> some software running on the local machine, or at least a machine connected
> to the debugging host via ethernet (since I guess gdb itself can't talk
> over a JTAG); the target system is not connected via ethernet, since a JTAG
> is in between. I already have software to communicate with the target
> system through the JTAG, I just can't figure out (reading the gdb manual)
> how to integrate it with gdb, that's what I'm trying to find out.

yes you do run gdbserver. The actual server itself runs on the host that is 
attached to the JTAG unit. THis will also likely be host that is running gdb 
but does not have to be.

The gdbserver gets commands from gdb and converts them into the JTAG comands.

A specification for the gdb remote protocol is provided by:
http://sourceware.org/gdb/current/onlinedocs/gdb_33.html

The server is just a program which waits for a connection on the desired tcpip 
port and then waits for commands (or target events) and sends back responses.

You can also run gdbserver on regular hosts (eg. so that you can execute 
programs on a different computer from what you're running gdb on). That is a 
great way to get a better understanding for the gdb remote protocol. By 
setting 
(gdb) set debug remote 1

that will show debug on the gdb remote protocol which will help your 
understanding.

Here's a way to do this:

In terminal A
Write a simple hello.c
compile: 
$ gcc -o hello hello.c -g
start gdbserver:  
$ gdbserver localhost:1111 hello

the server is now in terminal A

In terminal B do the following

$ gdb hello
(gdb) target remote localhost:1111
(gdb) set debug remote 1
(gdb) b main
(gdb) continue
(gdb) n

all the commands are sent through to the server.

Does that help?


>
> I read in a forum that the OpenOCD (open on chip debug) program uses TCP/IP
> port 3333 (by default) to communicate with gdb. It was stated that the
> common case is to run gdb on the same machine and connect to the localhost.
> I would probably have to do the same thing, since I use a JTAG (that's what
> OpenOCD expects too).

This basic model is commonly used by "dumb" JTAG devices and can also be used 
by anything else that can provide this capability (eg. a simulator or a 
remote system as per above).


>
> peter choi wrote:
> > by gdb-stub, do you mean the gdb-server??? gdb-server should run on the
> > target machine.
> > gdb-server communicate with gdb thru' either serial port or ethernet.
> >
> > TriKri wrote:
> >> I'm making a new try. I have understood that the gdb-stub is supposed to
> >> be linked to my debug daemon, which shall handel communication with the
> >> embedded system CPU. Is the daemon supposed to be running on the local
> >> machine (the one with gdb running) or on the target? Another thing, how
> >> do gdb and the daemon communicate? If they are running on the same
> >> machine, do they communicate through files? If they are running on
> >> different machines (gdb on the local machine and the daemon on the
> >> target), how do they communicate then?
> >>
> >> /Kristofer






reply via email to

[Prev in Thread] Current Thread [Next in Thread]