diff options
Diffstat (limited to 'gdb/remote.c')
-rw-r--r-- | gdb/remote.c | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/gdb/remote.c b/gdb/remote.c index 65ceac2cedb..88346b4a953 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -135,10 +135,6 @@ static void get_offsets (void); static long read_frame (char *buf, long sizeof_buf); -static int remote_insert_breakpoint (CORE_ADDR, bfd_byte *); - -static int remote_remove_breakpoint (CORE_ADDR, bfd_byte *); - static int hexnumlen (ULONGEST num); static void init_remote_ops (void); @@ -4539,19 +4535,17 @@ static unsigned char little_break_insn[] = DEPRECATED_LITTLE_REMOTE_BREAKPOINT; /* Insert a breakpoint on targets that don't have any better breakpoint support. We read the contents of the target location and stash it, then overwrite it with a breakpoint instruction. - ADDR is the target location in the target machine. CONTENTS_CACHE - is a pointer to memory allocated for saving the target contents. - It is guaranteed by the caller to be long enough to save the number - of bytes returned by BREAKPOINT_FROM_PC. */ + ADDR is the target location in the target machine. BPT is the breakpoint + being inserted or removed, which contains memory for saving the + target contents. */ static int -remote_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache) +remote_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt) { struct remote_state *rs = get_remote_state (); #ifdef DEPRECATED_REMOTE_BREAKPOINT int val; #endif - int bp_size; /* 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 @@ -4563,13 +4557,14 @@ remote_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache) char *buf = alloca (rs->remote_packet_size); char *p = buf; - addr = remote_address_masked (addr); *(p++) = 'Z'; *(p++) = '0'; *(p++) = ','; - p += hexnumstr (p, (ULONGEST) addr); - BREAKPOINT_FROM_PC (&addr, &bp_size); - sprintf (p, ",%d", bp_size); + bpt->placed_address = addr; + BREAKPOINT_FROM_PC (&bpt->placed_address, &bpt->placed_size); + addr = (ULONGEST) remote_address_masked (bpt->placed_address); + p += hexnumstr (p, addr); + sprintf (p, ",%d", bpt->placed_size); putpkt (buf); getpkt (buf, rs->remote_packet_size, 0); @@ -4586,7 +4581,7 @@ remote_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache) } #ifdef DEPRECATED_REMOTE_BREAKPOINT - val = target_read_memory (addr, contents_cache, sizeof big_break_insn); + val = target_read_memory (addr, bpt->shadow_contents, sizeof big_break_insn); if (val == 0) { @@ -4600,12 +4595,12 @@ remote_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache) return val; #else - return memory_insert_breakpoint (addr, contents_cache); + return memory_insert_breakpoint (addr, bpt); #endif /* DEPRECATED_REMOTE_BREAKPOINT */ } static int -remote_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache) +remote_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt) { struct remote_state *rs = get_remote_state (); int bp_size; @@ -4619,10 +4614,9 @@ remote_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache) *(p++) = '0'; *(p++) = ','; - addr = remote_address_masked (addr); - p += hexnumstr (p, (ULONGEST) addr); - BREAKPOINT_FROM_PC (&addr, &bp_size); - sprintf (p, ",%d", bp_size); + addr = (ULONGEST) remote_address_masked (bpt->placed_address); + p += hexnumstr (p, addr); + sprintf (p, ",%d", bpt->placed_size); putpkt (buf); getpkt (buf, rs->remote_packet_size, 0); @@ -4631,9 +4625,9 @@ remote_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache) } #ifdef DEPRECATED_REMOTE_BREAKPOINT - return target_write_memory (addr, contents_cache, sizeof big_break_insn); + return target_write_memory (addr, bpt->shadow_contents, sizeof big_break_insn); #else - return memory_remove_breakpoint (addr, contents_cache); + return memory_remove_breakpoint (addr, bpt); #endif /* DEPRECATED_REMOTE_BREAKPOINT */ } @@ -4779,9 +4773,8 @@ remote_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p) static int -remote_insert_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow) +remote_insert_hw_breakpoint (CORE_ADDR addr, struct bp_location *bpt) { - int len = 0; struct remote_state *rs = get_remote_state (); char *buf = alloca (rs->remote_packet_size); char *p = buf; @@ -4789,7 +4782,8 @@ remote_insert_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow) /* The length field should be set to the size of a breakpoint instruction. */ - BREAKPOINT_FROM_PC (&addr, &len); + bpt->placed_address = addr; + BREAKPOINT_FROM_PC (&bpt->placed_address, &bpt->placed_size); if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE) error (_("Can't set hardware breakpoint without the '%s' (%s) packet."), @@ -4800,9 +4794,9 @@ remote_insert_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow) *(p++) = '1'; *(p++) = ','; - addr = remote_address_masked (addr); + addr = remote_address_masked (bpt->placed_address); p += hexnumstr (p, (ULONGEST) addr); - sprintf (p, ",%x", len); + sprintf (p, ",%x", bpt->placed_size); putpkt (buf); getpkt (buf, rs->remote_packet_size, 0); @@ -4821,9 +4815,8 @@ remote_insert_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow) static int -remote_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow) +remote_remove_hw_breakpoint (CORE_ADDR addr, struct bp_location *bpt) { - int len; struct remote_state *rs = get_remote_state (); char *buf = alloca (rs->remote_packet_size); char *p = buf; @@ -4831,8 +4824,6 @@ remote_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow) /* The length field should be set to the size of a breakpoint instruction. */ - BREAKPOINT_FROM_PC (&addr, &len); - if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE) error (_("Can't clear hardware breakpoint without the '%s' (%s) packet."), remote_protocol_packets[PACKET_Z1].name, @@ -4842,9 +4833,9 @@ remote_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow) *(p++) = '1'; *(p++) = ','; - addr = remote_address_masked (addr); + addr = remote_address_masked (bpt->placed_address); p += hexnumstr (p, (ULONGEST) addr); - sprintf (p, ",%x", len); + sprintf (p, ",%x", bpt->placed_size); putpkt(buf); getpkt (buf, rs->remote_packet_size, 0); |