Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Call get_remote_state after gdbarch_breakpoint_from_pc is  called
@ 2008-05-07 12:43 Jie Zhang
  2008-05-07 12:56 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Jie Zhang @ 2008-05-07 12:43 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 533 bytes --]

Hi,

I'm working on Blackfin port of GDB. Since Blackfin requires that 16-bit 
breakpoint for 16-bit instruction and 32-bit breakpoint for 32-bit 
instruction, Blackfin port GDB tries to read memory, decode instruction, 
and find the instruction length in gdbarch_breakpoint_from_pc. Reading 
memory calls putpkt and getpkt when debugging remotely, which might 
change rs->buf. So we have to call get_remote_state after 
gdbarch_breakpoint_from_pc in remote_insert_breakpoint. Same for 
remote_insert_hw_breakpoint.

Is it OK?


Jie

[-- Attachment #2: gdb-remote-state.diff --]
[-- Type: text/x-diff, Size: 2186 bytes --]


	* remote.c (remote_insert_breakpoint): Call get_remote_state
	after gdbarch_breakpoint_from_pc is called.
	(remote_insert_hw_breakpoint): Likewise.

Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.286
diff -u -p -r1.286 remote.c
--- remote.c	21 Mar 2008 17:09:35 -0000	1.286
+++ remote.c	7 May 2008 09:24:01 -0000
@@ -5496,9 +5496,6 @@ extended_remote_async_create_inferior (c
 static int
 remote_insert_breakpoint (struct bp_target_info *bp_tgt)
 {
-  CORE_ADDR addr = bp_tgt->placed_address;
-  struct remote_state *rs = get_remote_state ();
-
   /* Try the "Z" s/w breakpoint packet if it is not already disabled.
      If it succeeds, then set the support to PACKET_ENABLE.  If it
      fails, and the user has explicitly requested the Z support then
@@ -5506,13 +5503,19 @@ remote_insert_breakpoint (struct bp_targ
 
   if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE)
     {
-      char *p = rs->buf;
+      CORE_ADDR addr;
+      struct remote_state *rs;
+      char *p;
+
+      gdbarch_breakpoint_from_pc
+	(current_gdbarch, &bp_tgt->placed_address, &bp_tgt->placed_size);
+
+      rs = get_remote_state ();
+      p = rs->buf;
 
       *(p++) = 'Z';
       *(p++) = '0';
       *(p++) = ',';
-      gdbarch_breakpoint_from_pc
-	(current_gdbarch, &bp_tgt->placed_address, &bp_tgt->placed_size);
       addr = (ULONGEST) remote_address_masked (bp_tgt->placed_address);
       p += hexnumstr (p, addr);
       sprintf (p, ",%d", bp_tgt->placed_size);
@@ -5698,8 +5701,8 @@ static int
 remote_insert_hw_breakpoint (struct bp_target_info *bp_tgt)
 {
   CORE_ADDR addr;
-  struct remote_state *rs = get_remote_state ();
-  char *p = rs->buf;
+  struct remote_state *rs;
+  char *p;
 
   /* The length field should be set to the size of a breakpoint
      instruction, even though we aren't inserting one ourselves.  */
@@ -5710,6 +5713,9 @@ remote_insert_hw_breakpoint (struct bp_t
   if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
     return -1;
 
+  rs = get_remote_state ();
+  p = rs->buf;
+
   *(p++) = 'Z';
   *(p++) = '1';
   *(p++) = ',';

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

* Re: [PATCH] Call get_remote_state after gdbarch_breakpoint_from_pc  is  called
  2008-05-07 12:43 [PATCH] Call get_remote_state after gdbarch_breakpoint_from_pc is called Jie Zhang
@ 2008-05-07 12:56 ` Daniel Jacobowitz
  2008-05-07 20:56   ` Jie Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2008-05-07 12:56 UTC (permalink / raw)
  To: Jie Zhang; +Cc: gdb-patches

On Wed, May 07, 2008 at 06:12:46PM +0800, Jie Zhang wrote:
> Hi,
>
> I'm working on Blackfin port of GDB. Since Blackfin requires that 16-bit  
> breakpoint for 16-bit instruction and 32-bit breakpoint for 32-bit  
> instruction, Blackfin port GDB tries to read memory, decode instruction,  
> and find the instruction length in gdbarch_breakpoint_from_pc. Reading  
> memory calls putpkt and getpkt when debugging remotely, which might  
> change rs->buf. So we have to call get_remote_state after  
> gdbarch_breakpoint_from_pc in remote_insert_breakpoint. Same for  
> remote_insert_hw_breakpoint.

You don't need to move the call to get_remote_state, just the read
from rs->buf (or replace p with rs->buf).  But this is fine too.

> 
> 	* remote.c (remote_insert_breakpoint): Call get_remote_state
> 	after gdbarch_breakpoint_from_pc is called.
> 	(remote_insert_hw_breakpoint): Likewise.

OK.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [PATCH] Call get_remote_state after gdbarch_breakpoint_from_pc  is  called
  2008-05-07 12:56 ` Daniel Jacobowitz
@ 2008-05-07 20:56   ` Jie Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Jie Zhang @ 2008-05-07 20:56 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel Jacobowitz wrote:
> On Wed, May 07, 2008 at 06:12:46PM +0800, Jie Zhang wrote:
>> Hi,
>>
>> I'm working on Blackfin port of GDB. Since Blackfin requires that 16-bit  
>> breakpoint for 16-bit instruction and 32-bit breakpoint for 32-bit  
>> instruction, Blackfin port GDB tries to read memory, decode instruction,  
>> and find the instruction length in gdbarch_breakpoint_from_pc. Reading  
>> memory calls putpkt and getpkt when debugging remotely, which might  
>> change rs->buf. So we have to call get_remote_state after  
>> gdbarch_breakpoint_from_pc in remote_insert_breakpoint. Same for  
>> remote_insert_hw_breakpoint.
> 
> You don't need to move the call to get_remote_state, just the read
> from rs->buf (or replace p with rs->buf).  But this is fine too.
> 
>> 	* remote.c (remote_insert_breakpoint): Call get_remote_state
>> 	after gdbarch_breakpoint_from_pc is called.
>> 	(remote_insert_hw_breakpoint): Likewise.
> 
> OK.
> 
Committed. Thanks.


Jie


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

end of thread, other threads:[~2008-05-07 11:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-07 12:43 [PATCH] Call get_remote_state after gdbarch_breakpoint_from_pc is called Jie Zhang
2008-05-07 12:56 ` Daniel Jacobowitz
2008-05-07 20:56   ` Jie Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox