* GDB --> Parallel Port --> Target??
@ 2003-10-07 10:00 Andrew Batchelor
2003-10-07 16:28 ` Jim Blandy
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Batchelor @ 2003-10-07 10:00 UTC (permalink / raw)
To: gdb
Hello,
I was wondering how straightforward it would be to write an extension
for GDB to use the parallel port to connect to a target instead of the
serial port? (Changing only a few files? Many files? Which ones?,
etc.)
Now I'm not really very familiar with GDB and before I jump in at the
deep end, I was wondering if any of you guys could give me any pointers?
At the moment I'm just having a read through the User Manual and the
Internals Manual and looking at some of the C files that look like they
might be of some help - can any of you guys point me in the right
direction?
Any help or advice you could offer would be much appreciated.
Andy
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: GDB --> Parallel Port --> Target??
2003-10-07 10:00 GDB --> Parallel Port --> Target?? Andrew Batchelor
@ 2003-10-07 16:28 ` Jim Blandy
2003-10-08 13:44 ` Andrew Batchelor
2003-10-08 19:37 ` Andrew Cagney
0 siblings, 2 replies; 8+ messages in thread
From: Jim Blandy @ 2003-10-07 16:28 UTC (permalink / raw)
To: Andrew Batchelor; +Cc: gdb
Andrew Batchelor <A.C.Batchelor-99@student.lboro.ac.uk> writes:
> Hello,
>
> I was wondering how straightforward it would be to write an extension
> for GDB to use the parallel port to connect to a target instead of the
> serial port? (Changing only a few files? Many files? Which ones?,
> etc.)
>
> Now I'm not really very familiar with GDB and before I jump in at the
> deep end, I was wondering if any of you guys could give me any pointers?
> At the moment I'm just having a read through the User Manual and the
> Internals Manual and looking at some of the C files that look like they
> might be of some help - can any of you guys point me in the right
> direction?
>
> Any help or advice you could offer would be much appreciated.
Have you tried simply doing "target remote /dev/lpt"? It's worth a
shot.
If it turns out that doesn't work because the parallel device needs
special handling, that can be done pretty easily.
Someone asked about this regarding USB recently:
http://sources.redhat.com/ml/insight/2003-q4/msg00016.html
Oddly enough, it seems like someone was thinking about this at some
point. In serial.c:
struct serial *
serial_open (const char *name)
{
struct serial *scb;
struct serial_ops *ops;
const char *open_name = name;
for (scb = scb_base; scb; scb = scb->next)
if (scb->name && strcmp (scb->name, name) == 0)
{
scb->refcnt++;
return scb;
}
if (strcmp (name, "pc") == 0)
ops = serial_interface_lookup ("pc");
else if (strchr (name, ':'))
ops = serial_interface_lookup ("tcp");
else if (strncmp (name, "lpt", 3) == 0)
ops = serial_interface_lookup ("parallel");
else if (strncmp (name, "|", 1) == 0)
{
ops = serial_interface_lookup ("pipe");
open_name = name + 1; /* discard ``|'' */
}
else
ops = serial_interface_lookup ("hardwire");
But this is just parsing what comes after "target remote". So "target
remote lpt" would try to find a serial interface named "parallel".
But there is no code I could find that registered an interface by that
name, so the open would fail.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: GDB --> Parallel Port --> Target??
2003-10-07 16:28 ` Jim Blandy
@ 2003-10-08 13:44 ` Andrew Batchelor
2003-10-08 17:55 ` Jim Blandy
2003-10-08 19:37 ` Andrew Cagney
1 sibling, 1 reply; 8+ messages in thread
From: Andrew Batchelor @ 2003-10-08 13:44 UTC (permalink / raw)
To: Jim Blandy; +Cc: GDB Newsgroup
On Tue, 2003-10-07 at 17:27, Jim Blandy wrote:
> Andrew Batchelor <A.C.Batchelor-99@student.lboro.ac.uk> writes:
>
> > Hello,
> >
> > I was wondering how straightforward it would be to write an extension
> > for GDB to use the parallel port to connect to a target instead of the
> > serial port? (Changing only a few files? Many files? Which ones?,
> > etc.)
> >
> > Now I'm not really very familiar with GDB and before I jump in at the
> > deep end, I was wondering if any of you guys could give me any pointers?
> > At the moment I'm just having a read through the User Manual and the
> > Internals Manual and looking at some of the C files that look like they
> > might be of some help - can any of you guys point me in the right
> > direction?
> >
> > Any help or advice you could offer would be much appreciated.
Hi Jim,
Thanks for your reply.
> If it turns out that doesn't work because the parallel device needs
> special handling, that can be done pretty easily.
> Someone asked about this regarding USB recently:
>
> http://sources.redhat.com/ml/insight/2003-q4/msg00016.html
Ah, that all looks more like what I'm after.
> Oddly enough, it seems like someone was thinking about this at some
> point. In serial.c:
[.....]
> But this is just parsing what comes after "target remote". So "target
> remote lpt" would try to find a serial interface named "parallel".
> But there is no code I could find that registered an interface by that
> name, so the open would fail.
Yeah, I couldn't find anything either.
Looks like I need to have a stab at writing something myself:
Can I check the flow of things?
1) Create new serial_ops structure pointing to initialise functions,
etc.
2) Then call this serial_add_interface to register the new structure.
3) Add a new case to serial_open in serial.c for argument parsing to
'target remote'.
I may need to do some protocol conversion from the Remote Serial
Protocol to something else.
Could you offer any advice on this?
Andy
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: GDB --> Parallel Port --> Target??
2003-10-08 13:44 ` Andrew Batchelor
@ 2003-10-08 17:55 ` Jim Blandy
2003-10-10 16:49 ` Andrew Batchelor
0 siblings, 1 reply; 8+ messages in thread
From: Jim Blandy @ 2003-10-08 17:55 UTC (permalink / raw)
To: Andrew Batchelor; +Cc: GDB Newsgroup
Andrew Batchelor <A.C.Batchelor-99@student.lboro.ac.uk> writes:
> Can I check the flow of things?
>
> 1) Create new serial_ops structure pointing to initialise functions,
> etc.
> 2) Then call this serial_add_interface to register the new structure.
>
> 3) Add a new case to serial_open in serial.c for argument parsing to
> 'target remote'.
Yep, that's right.
> I may need to do some protocol conversion from the Remote Serial
> Protocol to something else.
What kind of agent do you have running on the system being debugged
that will be speaking the protocol with GDB?
GDB's protocol looks really hairy, but there are actually only five or
six operations you must implement --- the rest are optional. Those
are:
- read registers
- write registers
- read memory
- write memory
- continue, and tell me why you stopped
- single-step (if GDB doesn't do software single-stepping for your
architecture, but I'm not completely clear on this)
You can add more and get better behavior, more features, etc. But the
above are all you need for almost everything --- breakpoints,
backtraces, expression evaluation, and so on.
It's been implemented many times over, and some implementations are
quite small and simple. See the files called *-stub.c in the GDB
source tree. Some of them are out-of-date, and none of them are
really tested or supported, but they'll give you the right idea.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: GDB --> Parallel Port --> Target??
2003-10-08 17:55 ` Jim Blandy
@ 2003-10-10 16:49 ` Andrew Batchelor
2003-10-10 19:32 ` Jim Blandy
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Batchelor @ 2003-10-10 16:49 UTC (permalink / raw)
To: Jim Blandy; +Cc: GDB Newsgroup
On Wed, 2003-10-08 at 18:53, Jim Blandy wrote:
> > I may need to do some protocol conversion from the Remote Serial
> > Protocol to something else.
>
> What kind of agent do you have running on the system being debugged
> that will be speaking the protocol with GDB?
Er, I'm not wholly sure yet but I think the target is going to be an ARM
evaluator board with an RV-ICE. This has its own protocol (RV-MSG) so
I'll need to write some sort of protocol converter for GDB.
> GDB's protocol looks really hairy, but there are actually only five or
> six operations you must implement --- the rest are optional. Those
> are:
[.....]
> You can add more and get better behavior, more features, etc. But the
> above are all you need for almost everything --- breakpoints,
> backtraces, expression evaluation, and so on.
Great - thanks for that.
> It's been implemented many times over, and some implementations are
> quite small and simple. See the files called *-stub.c in the GDB
> source tree. Some of them are out-of-date, and none of them are
> really tested or supported, but they'll give you the right idea.
Have I understood this correctly? These stub files are mini-protocol
converters? For the target or can they be adapted for my RV-ICE?
Thanks for your help.
Andy
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: GDB --> Parallel Port --> Target??
2003-10-10 16:49 ` Andrew Batchelor
@ 2003-10-10 19:32 ` Jim Blandy
0 siblings, 0 replies; 8+ messages in thread
From: Jim Blandy @ 2003-10-10 19:32 UTC (permalink / raw)
To: Andrew Batchelor; +Cc: GDB Newsgroup
Andrew Batchelor <A.C.Batchelor-99@student.lboro.ac.uk> writes:
> > It's been implemented many times over, and some implementations are
> > quite small and simple. See the files called *-stub.c in the GDB
> > source tree. Some of them are out-of-date, and none of them are
> > really tested or supported, but they'll give you the right idea.
>
> Have I understood this correctly? These stub files are mini-protocol
> converters? For the target or can they be adapted for my RV-ICE?
Well, they're not protocol converters. They're code that runs on the
target, along with your other code. They patch into the trap vectors
so that they get control when your program hits a breakpoint, gets a
segfault, executes an illegal instruction, etc. When GDB says
"continue", they just return from the trap, having frobbed registers
and memory however GDB asked.
I've never used an RV-ICE before, so I don't really know what sort of
interfaces they usually have. Not very helpful, I'm afraid.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: GDB --> Parallel Port --> Target??
2003-10-07 16:28 ` Jim Blandy
2003-10-08 13:44 ` Andrew Batchelor
@ 2003-10-08 19:37 ` Andrew Cagney
2003-10-10 16:53 ` Andrew Batchelor
1 sibling, 1 reply; 8+ messages in thread
From: Andrew Cagney @ 2003-10-08 19:37 UTC (permalink / raw)
To: Jim Blandy, Andrew Batchelor; +Cc: gdb, Sachin Bharadwaj
[adding Sachin]
> Andrew Batchelor <A.C.Batchelor-99@student.lboro.ac.uk> writes:
>
>
>> Hello,
>>
>> I was wondering how straightforward it would be to write an extension
>> for GDB to use the parallel port to connect to a target instead of the
>> serial port? (Changing only a few files? Many files? Which ones?,
>> etc.)
>>
>> Now I'm not really very familiar with GDB and before I jump in at the
>> deep end, I was wondering if any of you guys could give me any pointers?
>> At the moment I'm just having a read through the User Manual and the
>> Internals Manual and looking at some of the C files that look like they
>> might be of some help - can any of you guys point me in the right
>> direction?
>>
>> Any help or advice you could offer would be much appreciated.
>
>
> Have you tried simply doing "target remote /dev/lpt"? It's worth a
> shot.
FYI, it should just work. For GDB, there should really be no difference
between a serial and parallel character interface.
> If it turns out that doesn't work because the parallel device needs
> special handling, that can be done pretty easily.
> Someone asked about this regarding USB recently:
>
> http://sources.redhat.com/ml/insight/2003-q4/msg00016.html
The correct kernel driver will let GDB talk though to the USB connected
device as if it was a normal serial device.
Of course, if it's the actual USB chip that your trying to communicate
with, things can get a bit messy. While having the USB chip include a
pseudo-serial interface that talked remote-protocol would work, I've
seen implementations that ended up having a debug agent translate remote
protocol into USB primatives.
Andrew
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: GDB --> Parallel Port --> Target??
2003-10-08 19:37 ` Andrew Cagney
@ 2003-10-10 16:53 ` Andrew Batchelor
0 siblings, 0 replies; 8+ messages in thread
From: Andrew Batchelor @ 2003-10-10 16:53 UTC (permalink / raw)
To: Andrew Cagney; +Cc: GDB Newsgroup
On Wed, 2003-10-08 at 20:37, Andrew Cagney wrote:
> FYI, it should just work. For GDB, there should really be no difference
> between a serial and parallel character interface.
[.....]
> The correct kernel driver will let GDB talk though to the USB connected
> device as if it was a normal serial device.
[.....]
> Of course, if it's the actual USB chip that your trying to communicate
> with, things can get a bit messy. While having the USB chip include a
> pseudo-serial interface that talked remote-protocol would work, I've
> seen implementations that ended up having a debug agent translate remote
> protocol into USB primatives.
Thanks for your reply.
Oh, right - I guess that saves me a bit of coding then. Have you read
the other emails? I'll probably be needing to alter the way GDB sends
the characters to the parallel port when I code this protocol
converter. Any idea what files I'll be looking at?
I've scanned a bit through serial.c and remote.c and found most things I
think.
Andy
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2003-10-10 19:32 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-07 10:00 GDB --> Parallel Port --> Target?? Andrew Batchelor
2003-10-07 16:28 ` Jim Blandy
2003-10-08 13:44 ` Andrew Batchelor
2003-10-08 17:55 ` Jim Blandy
2003-10-10 16:49 ` Andrew Batchelor
2003-10-10 19:32 ` Jim Blandy
2003-10-08 19:37 ` Andrew Cagney
2003-10-10 16:53 ` Andrew Batchelor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox