public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* breakpoint for avr?
@ 2003-05-14 16:02 Andrew Cagney
  2003-05-14 16:56 ` Kevin Buettner
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Andrew Cagney @ 2003-05-14 16:02 UTC (permalink / raw)
  To: troth, gdb

Theodore,

Just noticed that the AVR target doesn't provide the BREAKPOINT_FROM_PC 
method.

Up until now the architecture vector providing a default 
breakpoint_from_pc (it would internal error for the AVR case). I 
suspect, up until now, this hasn't been a problem because the AVR was 
always remote.

Anyway, I've just posted a patch to always require breakpoint-from-pc 
and this is causing the AVR grief.

So, is there a breakpoint instruction, or should GDB allow targets that 
have no breakpoint at all?

enjoy,
Andrew

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: breakpoint for avr?
  2003-05-14 16:02 breakpoint for avr? Andrew Cagney
@ 2003-05-14 16:56 ` Kevin Buettner
  2003-05-14 17:40 ` Theodore A. Roth
  2003-05-14 22:04 ` Theodore A. Roth
  2 siblings, 0 replies; 9+ messages in thread
From: Kevin Buettner @ 2003-05-14 16:56 UTC (permalink / raw)
  To: Andrew Cagney, troth, gdb

On May 14, 12:02pm, Andrew Cagney wrote:

> Just noticed that the AVR target doesn't provide the BREAKPOINT_FROM_PC 
> method.
> 
> Up until now the architecture vector providing a default 
> breakpoint_from_pc (it would internal error for the AVR case). I 
> suspect, up until now, this hasn't been a problem because the AVR was 
> always remote.
> 
> Anyway, I've just posted a patch to always require breakpoint-from-pc 
> and this is causing the AVR grief.
> 
> So, is there a breakpoint instruction, or should GDB allow targets that 
> have no breakpoint at all?

Presumably, there's some other way of setting breakpoints?  Hardware
breakpoints for example?

If so, I think GDB should permit targets that have not breakpoint
instruction.

Kevin

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: breakpoint for avr?
  2003-05-14 16:02 breakpoint for avr? Andrew Cagney
  2003-05-14 16:56 ` Kevin Buettner
@ 2003-05-14 17:40 ` Theodore A. Roth
  2003-05-14 22:04 ` Theodore A. Roth
  2 siblings, 0 replies; 9+ messages in thread
From: Theodore A. Roth @ 2003-05-14 17:40 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb



On Wed, 14 May 2003, Andrew Cagney wrote:

:) Theodore,
:)
:) Just noticed that the AVR target doesn't provide the BREAKPOINT_FROM_PC
:) method.
:)
:) Up until now the architecture vector providing a default
:) breakpoint_from_pc (it would internal error for the AVR case). I
:) suspect, up until now, this hasn't been a problem because the AVR was
:) always remote.
:)
:) Anyway, I've just posted a patch to always require breakpoint-from-pc
:) and this is causing the AVR grief.

Can you give me a reference to that patch so I can try it?

:)
:) So, is there a breakpoint instruction, or should GDB allow targets that
:) have no breakpoint at all?

There is a BREAK instruction for some avr devices (acts as a NOP for
devices that don't have it). Since the avr is always remote, I use the
'Z' packets for setting breakpoints. I'm not sure how useful the BREAK
insn would be for gdb though. I guess the remote monitor could
intercept it some how.

How does the BREAKPOINT_FROM_PC method relate to 'Z' packets from the
remote protocol?

Ted Roth

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: breakpoint for avr?
  2003-05-14 16:02 breakpoint for avr? Andrew Cagney
  2003-05-14 16:56 ` Kevin Buettner
  2003-05-14 17:40 ` Theodore A. Roth
@ 2003-05-14 22:04 ` Theodore A. Roth
  2003-05-15 16:19   ` Andrew Cagney
  2 siblings, 1 reply; 9+ messages in thread
From: Theodore A. Roth @ 2003-05-14 22:04 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1506 bytes --]


On Wed, 14 May 2003, Andrew Cagney wrote:

:) Theodore,
:)
:) Just noticed that the AVR target doesn't provide the BREAKPOINT_FROM_PC
:) method.
:)
:) Up until now the architecture vector providing a default
:) breakpoint_from_pc (it would internal error for the AVR case). I
:) suspect, up until now, this hasn't been a problem because the AVR was
:) always remote.
:)
:) Anyway, I've just posted a patch to always require breakpoint-from-pc
:) and this is causing the AVR grief.
:)
:) So, is there a breakpoint instruction, or should GDB allow targets that
:) have no breakpoint at all?

Ok, I added the BREAKPOINT_FROM_PC method for the avr and as I
suspected it doesn't interfere with remote targets (unless I am over
looking something):

(gdb) b main
Breakpoint 1 at 0x104: file tst.c, line 34.
(gdb) c
Continuing.
Sending packet: $Z0,104,2#a9...Ack
Packet received: OK
Packet Z0 (software-breakpoint) is supported
Sending packet: $Hc0#db...Ack
Packet received:
Sending packet: $c#63...Ack
Packet received: T0520:02;21:ff10;22:04010000;
Sending packet: $g#67...Ack
Packet received: 00000000000000000000000000000000000100000000000000000001ff100a0102ff1004010000
Sending packet: $mfc,8#9a...Ack
Packet received: cfefd0e1debfcdbf
Sending packet: $z0,104,2#c9...Ack
Packet received: OK

Breakpoint 1, main () at tst.c:34
(gdb)


Andrew, does the attached patch help things with your patch? If so,
I'll go ahead and commit it.

Ted Roth

(Wondering if I should have posted this to gdb-patches instead. ;-)

[-- Attachment #2: Type: TEXT/PLAIN, Size: 1429 bytes --]

2003-05-14  Theodore A. Roth  <troth@openavr.org>

	* avr-tdep.c (avr_breakpoint_from_pc): New function.
	(avr_gdbarch_init): Set breakpoint_from_pc method.

Index: avr-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/avr-tdep.c,v
retrieving revision 1.47
diff -u -p -r1.47 avr-tdep.c
--- avr-tdep.c	14 May 2003 20:09:14 -0000	1.47
+++ avr-tdep.c	14 May 2003 21:47:19 -0000
@@ -1091,6 +1091,18 @@ avr_push_arguments (int nargs, struct va
   return sp;
 }
 
+/* Not all avr devices support the BREAK insn. Those that don't should treat
+   it as a NOP. Thus, it should be ok. Since the avr is currently a remote
+   only target, this shouldn't be a problem (I hope). TRoth/2003-05-14  */
+
+const unsigned char *
+avr_breakpoint_from_pc (CORE_ADDR * pcptr, int *lenptr)
+{
+    static unsigned char avr_break_insn [] = { 0x95, 0x98 };
+    *lenptr = sizeof (avr_break_insn);
+    return avr_break_insn;
+}
+
 /* Initialize the gdbarch structure for the AVR's. */
 
 static struct gdbarch *
@@ -1189,6 +1201,7 @@ avr_gdbarch_init (struct gdbarch_info in
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
 
   set_gdbarch_decr_pc_after_break (gdbarch, 0);
+  set_gdbarch_breakpoint_from_pc (gdbarch, avr_breakpoint_from_pc);
 
   set_gdbarch_function_start_offset (gdbarch, 0);
   set_gdbarch_remote_translate_xfer_address (gdbarch,

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: breakpoint for avr?
  2003-05-14 22:04 ` Theodore A. Roth
@ 2003-05-15 16:19   ` Andrew Cagney
  2003-05-15 16:45     ` Theodore A. Roth
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Cagney @ 2003-05-15 16:19 UTC (permalink / raw)
  To: Theodore A. Roth; +Cc: gdb


> Ok, I added the BREAKPOINT_FROM_PC method for the avr and as I
> suspected it doesn't interfere with remote targets (unless I am over
> looking something):

Right.  If the remote target doesn't support the Z packet, GDB will use 
BREAKPOINT_FROM_PC and then insert breakpoints in memory.  Try
> (gdb) b main
> Breakpoint 1 at 0x104: file tst.c, line 34.

Do a:

(gdb) set remote Z-packet off

here.  You'll then see GDB doing memory writes.

> (gdb) c
> Continuing.
> Sending packet: $Z0,104,2#a9...Ack
> Packet received: OK
> Packet Z0 (software-breakpoint) is supported
> Sending packet: $Hc0#db...Ack
> Packet received:
> Sending packet: $c#63...Ack
> Packet received: T0520:02;21:ff10;22:04010000;
> Sending packet: $g#67...Ack
> Packet received: 00000000000000000000000000000000000100000000000000000001ff100a0102ff1004010000
> Sending packet: $mfc,8#9a...Ack
> Packet received: cfefd0e1debfcdbf
> Sending packet: $z0,104,2#c9...Ack
> Packet received: OK
> 
> Breakpoint 1, main () at tst.c:34
> (gdb)
> 
> 
> Andrew, does the attached patch help things with your patch? If so,
> I'll go ahead and commit it.

Yes, it will avoid the problem.  My patch is at:
http://sources.redhat.com/ml/gdb-patches/2003-05/msg00211.html

Andrew


> 2003-05-14  Theodore A. Roth  <troth@openavr.org>
> 
> 	* avr-tdep.c (avr_breakpoint_from_pc): New function.
> 	(avr_gdbarch_init): Set breakpoint_from_pc method.
> 
> Index: avr-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/avr-tdep.c,v
> retrieving revision 1.47
> diff -u -p -r1.47 avr-tdep.c
> --- avr-tdep.c	14 May 2003 20:09:14 -0000	1.47
> +++ avr-tdep.c	14 May 2003 21:47:19 -0000
> @@ -1091,6 +1091,18 @@ avr_push_arguments (int nargs, struct va
>    return sp;
>  }
>  
> +/* Not all avr devices support the BREAK insn. Those that don't should treat
> +   it as a NOP. Thus, it should be ok. Since the avr is currently a remote
> +   only target, this shouldn't be a problem (I hope). TRoth/2003-05-14  */
> +
> +const unsigned char *
> +avr_breakpoint_from_pc (CORE_ADDR * pcptr, int *lenptr)
> +{
> +    static unsigned char avr_break_insn [] = { 0x95, 0x98 };
> +    *lenptr = sizeof (avr_break_insn);
> +    return avr_break_insn;
> +}
> +
>  /* Initialize the gdbarch structure for the AVR's. */
>  
>  static struct gdbarch *
> @@ -1189,6 +1201,7 @@ avr_gdbarch_init (struct gdbarch_info in
>    set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
>  
>    set_gdbarch_decr_pc_after_break (gdbarch, 0);
> +  set_gdbarch_breakpoint_from_pc (gdbarch, avr_breakpoint_from_pc);
>  
>    set_gdbarch_function_start_offset (gdbarch, 0);
>    set_gdbarch_remote_translate_xfer_address (gdbarch,


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: breakpoint for avr?
  2003-05-15 16:19   ` Andrew Cagney
@ 2003-05-15 16:45     ` Theodore A. Roth
  2003-05-15 17:29       ` Andrew Cagney
  0 siblings, 1 reply; 9+ messages in thread
From: Theodore A. Roth @ 2003-05-15 16:45 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb



On Thu, 15 May 2003, Andrew Cagney wrote:

:)
:) > Ok, I added the BREAKPOINT_FROM_PC method for the avr and as I
:) > suspected it doesn't interfere with remote targets (unless I am over
:) > looking something):
:)
:) Right.  If the remote target doesn't support the Z packet, GDB will use
:) BREAKPOINT_FROM_PC and then insert breakpoints in memory.  Try
:) > (gdb) b main
:) > Breakpoint 1 at 0x104: file tst.c, line 34.
:)
:) Do a:
:)
:) (gdb) set remote Z-packet off
:)
:) here.  You'll then see GDB doing memory writes.

Ok. Thanks for the explanation. I assume that "remote Z-packet" is on
by default.

I tried setting it off and found that I had the bytes swapped on the
break insn. After fixing that, my simulator worked fine:

(gdb) set remote Z-packet off
(gdb) b main
Breakpoint 1 at 0x104: file tst.c, line 34.
(gdb) c
Continuing.
Sending packet: $m104,2#60...Ack
Packet received: 0e94
Sending packet: $M104,2:9895#59...Ack
Packet received: OK
Sending packet: $Hc0#db...Ack
Packet received:
Sending packet: $c#63...Ack
Packet received: T0520:02;21:ff10;22:04010000;
Sending packet: $g#67...Ack
Packet received: 00000000000000000000000000000000000100000000000000000001ff100a0102ff1004010000
Sending packet: $mfc,8#9a...Ack
Packet received: cfefd0e1debfcdbf
Sending packet: $M104,2:0e94#7c...Ack
Packet received: OK

Breakpoint 1, main () at tst.c:34
(gdb)

:) > Andrew, does the attached patch help things with your patch? If so,
:) > I'll go ahead and commit it.
:)
:) Yes, it will avoid the problem.  My patch is at:
:) http://sources.redhat.com/ml/gdb-patches/2003-05/msg00211.html

Ok. I'll verify that and then commit my patch.

Thanks.

Ted Roth

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: breakpoint for avr?
  2003-05-15 16:45     ` Theodore A. Roth
@ 2003-05-15 17:29       ` Andrew Cagney
  2003-05-15 18:03         ` Theodore A. Roth
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Cagney @ 2003-05-15 17:29 UTC (permalink / raw)
  To: Theodore A. Roth; +Cc: gdb

> On Thu, 15 May 2003, Andrew Cagney wrote:
> 
> :)
> :) > Ok, I added the BREAKPOINT_FROM_PC method for the avr and as I
> :) > suspected it doesn't interfere with remote targets (unless I am over
> :) > looking something):
> :)
> :) Right.  If the remote target doesn't support the Z packet, GDB will use
> :) BREAKPOINT_FROM_PC and then insert breakpoints in memory.  Try
> :) > (gdb) b main
> :) > Breakpoint 1 at 0x104: file tst.c, line 34.
> :)
> :) Do a:
> :)
> :) (gdb) set remote Z-packet off
> :)
> :) here.  You'll then see GDB doing memory writes.
> 
> Ok. Thanks for the explanation. I assume that "remote Z-packet" is on
> by default.

Strictly speaking it should start out with ``auto-detect'' mode.  It 
probes the target to see if Z works.  The above is an override.

> Ok. I'll verify that and then commit my patch.

Thanks!

Andrew


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: breakpoint for avr?
  2003-05-15 17:29       ` Andrew Cagney
@ 2003-05-15 18:03         ` Theodore A. Roth
  2003-05-15 18:11           ` Andrew Cagney
  0 siblings, 1 reply; 9+ messages in thread
From: Theodore A. Roth @ 2003-05-15 18:03 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb



On Thu, 15 May 2003, Andrew Cagney wrote:

:) > Ok. I'll verify that and then commit my patch.
:)
:) Thanks!
:)
:) Andrew

Your patch (after I figured out that I needed to run gdbarch.sh ;-)
with my patch works fine with avr. I'll commit mine now.

Ted Roth

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: breakpoint for avr?
  2003-05-15 18:03         ` Theodore A. Roth
@ 2003-05-15 18:11           ` Andrew Cagney
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Cagney @ 2003-05-15 18:11 UTC (permalink / raw)
  To: Theodore A. Roth; +Cc: gdb

> On Thu, 15 May 2003, Andrew Cagney wrote:
> 
> :) > Ok. I'll verify that and then commit my patch.
> :)
> :) Thanks!
> :)
> :) Andrew
> 
> Your patch (after I figured out that I needed to run gdbarch.sh ;-)
> with my patch works fine with avr. I'll commit mine now.

Ya!


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2003-05-15 18:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-14 16:02 breakpoint for avr? Andrew Cagney
2003-05-14 16:56 ` Kevin Buettner
2003-05-14 17:40 ` Theodore A. Roth
2003-05-14 22:04 ` Theodore A. Roth
2003-05-15 16:19   ` Andrew Cagney
2003-05-15 16:45     ` Theodore A. Roth
2003-05-15 17:29       ` Andrew Cagney
2003-05-15 18:03         ` Theodore A. Roth
2003-05-15 18:11           ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).