• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision2716529498941971b698f603e9aa0edc89905cb8 (tree)
Time2015-10-22 00:24:55
AuthorAntoine Tremblay <antoine.tremblay@eric...>
CommiterAntoine Tremblay

Log Message

Support breakpoint kinds for software breakpoints in GDBServer.

There's two ways to set breakpoints in GDBServer.

- GDBServer setting its own breakpoints, through API set_breakpoint_at.
- GDBServer setting breakpoints according to the information in Z
packets, through API set_gdb_breakpoint.

Before this patch the breakpoint kinds were a concept unique to GDB and Z
packets, as GDBServer never had to set different kinds of breakpoint on its
own.

This patch teaches GDBServer to handle breakpoint kinds for its own
breakpoints. It generalizes the breakpoint kind as per Z packets to
represent different kinds of breakpoints directly set by GDBServer also.

GDBServer now querys breakpoint_kind_from_pc to know what breakpoint kind to
set on its own.

As the kind is now a differentiating factor equivalent to size for the
breakpoint struct and that it's size can be queried using
sw_breakpoint_from_kind, the size field has been replaced with the kind field.
All references to size are now replaced by kind or a call to bp_size that wraps
sw_breakpoing_from_kind and returns the size of the breakpoint in memory.

To fetch the software breakpoint data bp_opcode is called and wraps the
sw_breakpoint_from_kind call.

No regressions on Ubuntu 14.04 on ARMv7 and x86.
With gdbserver-{native,extended} / { -marm -mthumb }

gdb/gdbserver/ChangeLog:

* linux-low.c (initialize_low): Ajdust for breakpoint global variables
removal.
* mem-break.c : Remove breakpoint_data/breakpoint_len global variables.
(struct raw_breakpoint) <size>: Remove.
(struct raw_breakpoint) <kind>: Add.
(bp_size): New function.
(bp_opcode): Likewise.
(find_raw_breakpoint_at): Adjust for kind.
(insert_memory_breakpoint): Adjust for kind call bp_size,bp_opcode.
(remove_memory_breakpoint): Adjust for kind call bp_size.
(set_raw_breakpoint_at): Adjust for kind.
(set_breakpoint): Likewise.
(set_breakpoint_at): Call breakpoint_kind_from_pc.
(delete_raw_breakpoint): Adjust for kind.
(delete_breakpoint): Likewise.
(find_gdb_breakpoint): Likewise.
(set_gdb_breakpoint_1): Likewise.
(set_gdb_breakpoint): Likewise.
(delete_gdb_breakpoint_1): Likewise.
(delete_gdb_breakpoint): Likewise.
(uninsert_raw_breakpoint): Likewise.
(reinsert_raw_breakpoint): Likewise.
(set_breakpoint_data): Remove.
(validate_inserted_breakpoint): Adjust for kind call bp_size,bp_opcode.
(check_mem_read): Adjust for kind call bp_size.
(check_mem_write): Adjust for kind call bp_size,bp_opcode.
(clone_one_breakpoint): Adjust for kind.
* mem-break.h (set_gdb_breakpoint): Likewise.
(delete_gdb_breakpoint): Likewise.
* server.c (process_serial_event): Likewise.

Change Summary

Incremental Difference

--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,38 @@
11 2015-10-21 Antoine Tremblay <antoine.tremblay@ericsson.com>
22
3+ * linux-low.c (initialize_low): Ajdust for breakpoint global variables
4+ removal.
5+ * mem-break.c : Remove breakpoint_data/breakpoint_len global variables.
6+ (struct raw_breakpoint) <size>: Remove.
7+ (struct raw_breakpoint) <kind>: Add.
8+ (bp_size): New function.
9+ (bp_opcode): Likewise.
10+ (find_raw_breakpoint_at): Adjust for kind.
11+ (insert_memory_breakpoint): Adjust for kind call bp_size,bp_opcode.
12+ (remove_memory_breakpoint): Adjust for kind call bp_size.
13+ (set_raw_breakpoint_at): Adjust for kind.
14+ (set_breakpoint): Likewise.
15+ (set_breakpoint_at): Call breakpoint_kind_from_pc.
16+ (delete_raw_breakpoint): Adjust for kind.
17+ (delete_breakpoint): Likewise.
18+ (find_gdb_breakpoint): Likewise.
19+ (set_gdb_breakpoint_1): Likewise.
20+ (set_gdb_breakpoint): Likewise.
21+ (delete_gdb_breakpoint_1): Likewise.
22+ (delete_gdb_breakpoint): Likewise.
23+ (uninsert_raw_breakpoint): Likewise.
24+ (reinsert_raw_breakpoint): Likewise.
25+ (set_breakpoint_data): Remove.
26+ (validate_inserted_breakpoint): Adjust for kind call bp_size,bp_opcode.
27+ (check_mem_read): Adjust for kind call bp_size.
28+ (check_mem_write): Adjust for kind call bp_size,bp_opcode.
29+ (clone_one_breakpoint): Adjust for kind.
30+ * mem-break.h (set_gdb_breakpoint): Likewise.
31+ (delete_gdb_breakpoint): Likewise.
32+ * server.c (process_serial_event): Likewise.
33+
34+2015-10-21 Antoine Tremblay <antoine.tremblay@ericsson.com>
35+
336 * linux-aarch64-low.c (aarch64_sw_breakpoint_from_kind): New function.
437 (struct linux_target_ops) <breakpoint>: Remove.
538 (struct linux_target_ops) <breakpoint_len>: Remove.
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -7082,20 +7082,10 @@ void
70827082 initialize_low (void)
70837083 {
70847084 struct sigaction sigchld_action;
7085- int breakpoint_kind = 0;
7086- int breakpoint_size = 0;
7087- const gdb_byte *breakpoint = NULL;
70887085
70897086 memset (&sigchld_action, 0, sizeof (sigchld_action));
70907087 set_target_ops (&linux_target_ops);
70917088
7092- breakpoint_kind = the_target->breakpoint_kind_from_pc (NULL);
7093- breakpoint = the_target->sw_breakpoint_from_kind (breakpoint_kind,
7094- &breakpoint_size);
7095-
7096- set_breakpoint_data (breakpoint,
7097- breakpoint_size);
7098-
70997089 linux_init_signals ();
71007090 linux_ptrace_init_warnings ();
71017091
--- a/gdb/gdbserver/mem-break.c
+++ b/gdb/gdbserver/mem-break.c
@@ -21,8 +21,6 @@
2121 #include "server.h"
2222 #include "regcache.h"
2323 #include "ax.h"
24-const unsigned char *breakpoint_data;
25-int breakpoint_len;
2624
2725 #define MAX_BREAKPOINT_LEN 8
2826
@@ -100,8 +98,13 @@ struct raw_breakpoint
10098 breakpoint for a given PC. */
10199 CORE_ADDR pc;
102100
103- /* The breakpoint's size. */
104- int size;
101+ /* The breakpoint's kind. This is target specific. Most
102+ architectures only use one specific instruction for breakpoints, while
103+ others may use more than one. E.g., on ARM, we need to use different
104+ breakpoint instructions on Thumb, Thumb-2, and ARM code. Likewise for
105+ hardware breakpoints -- some architectures (including ARM) need to
106+ setup debug registers differently depending on mode. */
107+ int kind;
105108
106109 /* The breakpoint's shadow memory. */
107110 unsigned char old_data[MAX_BREAKPOINT_LEN];
@@ -189,6 +192,27 @@ struct breakpoint
189192 int (*handler) (CORE_ADDR);
190193 };
191194
195+/* Return the breakpoint size from its kind. */
196+
197+static int
198+bp_size (struct raw_breakpoint *bp)
199+{
200+ int size = 0;
201+
202+ the_target->sw_breakpoint_from_kind (bp->kind, &size);
203+ return size;
204+}
205+
206+/* Return the breakpoint opcode from its kind. */
207+
208+static const gdb_byte *
209+bp_opcode (struct raw_breakpoint *bp)
210+{
211+ int size = 0;
212+
213+ return the_target->sw_breakpoint_from_kind (bp->kind, &size);
214+}
215+
192216 /* See mem-break.h. */
193217
194218 enum target_hw_bp_type
@@ -281,13 +305,13 @@ find_enabled_raw_code_breakpoint_at (CORE_ADDR addr, enum raw_bkpt_type type)
281305 NULL if not found. */
282306
283307 static struct raw_breakpoint *
284-find_raw_breakpoint_at (CORE_ADDR addr, enum raw_bkpt_type type, int size)
308+find_raw_breakpoint_at (CORE_ADDR addr, enum raw_bkpt_type type, int kind)
285309 {
286310 struct process_info *proc = current_process ();
287311 struct raw_breakpoint *bp;
288312
289313 for (bp = proc->raw_breakpoints; bp != NULL; bp = bp->next)
290- if (bp->pc == addr && bp->raw_type == type && bp->size == size)
314+ if (bp->pc == addr && bp->raw_type == type && bp->kind == kind)
291315 return bp;
292316
293317 return NULL;
@@ -301,24 +325,10 @@ insert_memory_breakpoint (struct raw_breakpoint *bp)
301325 unsigned char buf[MAX_BREAKPOINT_LEN];
302326 int err;
303327
304- if (breakpoint_data == NULL)
305- return 1;
306-
307- /* If the architecture treats the size field of Z packets as a
308- 'kind' field, then we'll need to be able to know which is the
309- breakpoint instruction too. */
310- if (bp->size != breakpoint_len)
311- {
312- if (debug_threads)
313- debug_printf ("Don't know how to insert breakpoints of size %d.\n",
314- bp->size);
315- return -1;
316- }
317-
318328 /* Note that there can be fast tracepoint jumps installed in the
319329 same memory range, so to get at the original memory, we need to
320330 use read_inferior_memory, which masks those out. */
321- err = read_inferior_memory (bp->pc, buf, breakpoint_len);
331+ err = read_inferior_memory (bp->pc, buf, bp_size (bp));
322332 if (err != 0)
323333 {
324334 if (debug_threads)
@@ -328,10 +338,10 @@ insert_memory_breakpoint (struct raw_breakpoint *bp)
328338 }
329339 else
330340 {
331- memcpy (bp->old_data, buf, breakpoint_len);
341+ memcpy (bp->old_data, buf, bp_size (bp));
332342
333- err = (*the_target->write_memory) (bp->pc, breakpoint_data,
334- breakpoint_len);
343+ err = (*the_target->write_memory) (bp->pc, bp_opcode (bp),
344+ bp_size (bp));
335345 if (err != 0)
336346 {
337347 if (debug_threads)
@@ -358,8 +368,8 @@ remove_memory_breakpoint (struct raw_breakpoint *bp)
358368 note that we need to pass the current shadow contents, because
359369 write_inferior_memory updates any shadow memory with what we pass
360370 here, and we want that to be a nop. */
361- memcpy (buf, bp->old_data, breakpoint_len);
362- err = write_inferior_memory (bp->pc, buf, breakpoint_len);
371+ memcpy (buf, bp->old_data, bp_size (bp));
372+ err = write_inferior_memory (bp->pc, buf, bp_size (bp));
363373 if (err != 0)
364374 {
365375 if (debug_threads)
@@ -370,12 +380,12 @@ remove_memory_breakpoint (struct raw_breakpoint *bp)
370380 return err != 0 ? -1 : 0;
371381 }
372382
373-/* Set a RAW breakpoint of type TYPE and size SIZE at WHERE. On
383+/* Set a RAW breakpoint of type TYPE and kind KIND at WHERE. On
374384 success, a pointer to the new breakpoint is returned. On failure,
375385 returns NULL and writes the error code to *ERR. */
376386
377387 static struct raw_breakpoint *
378-set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int size,
388+set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int kind,
379389 int *err)
380390 {
381391 struct process_info *proc = current_process ();
@@ -384,19 +394,19 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int size,
384394 if (type == raw_bkpt_type_sw || type == raw_bkpt_type_hw)
385395 {
386396 bp = find_enabled_raw_code_breakpoint_at (where, type);
387- if (bp != NULL && bp->size != size)
397+ if (bp != NULL && bp->kind != kind)
388398 {
389- /* A different size than previously seen. The previous
399+ /* A different kind than previously seen. The previous
390400 breakpoint must be gone then. */
391401 if (debug_threads)
392- debug_printf ("Inconsistent breakpoint size? Was %d, now %d.\n",
393- bp->size, size);
402+ debug_printf ("Inconsistent breakpoint kind? Was %d, now %d.\n",
403+ bp->kind, kind);
394404 bp->inserted = -1;
395405 bp = NULL;
396406 }
397407 }
398408 else
399- bp = find_raw_breakpoint_at (where, type, size);
409+ bp = find_raw_breakpoint_at (where, type, kind);
400410
401411 if (bp != NULL)
402412 {
@@ -406,11 +416,11 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int size,
406416
407417 bp = XCNEW (struct raw_breakpoint);
408418 bp->pc = where;
409- bp->size = size;
419+ bp->kind = kind;
410420 bp->refcount = 1;
411421 bp->raw_type = type;
412422
413- *err = the_target->insert_point (bp->raw_type, bp->pc, bp->size, bp);
423+ *err = the_target->insert_point (bp->raw_type, bp->pc, bp->kind, bp);
414424 if (*err != 0)
415425 {
416426 if (debug_threads)
@@ -732,7 +742,7 @@ reinsert_fast_tracepoint_jumps_at (CORE_ADDR where)
732742 }
733743
734744 /* Set a high-level breakpoint of type TYPE, with low level type
735- RAW_TYPE and size SIZE, at WHERE. On success, a pointer to the new
745+ RAW_TYPE and kind KIND, at WHERE. On success, a pointer to the new
736746 breakpoint is returned. On failure, returns NULL and writes the
737747 error code to *ERR. HANDLER is called when the breakpoint is hit.
738748 HANDLER should return 1 if the breakpoint should be deleted, 0
@@ -740,14 +750,14 @@ reinsert_fast_tracepoint_jumps_at (CORE_ADDR where)
740750
741751 static struct breakpoint *
742752 set_breakpoint (enum bkpt_type type, enum raw_bkpt_type raw_type,
743- CORE_ADDR where, int size,
753+ CORE_ADDR where, int kind,
744754 int (*handler) (CORE_ADDR), int *err)
745755 {
746756 struct process_info *proc = current_process ();
747757 struct breakpoint *bp;
748758 struct raw_breakpoint *raw;
749759
750- raw = set_raw_breakpoint_at (raw_type, where, size, err);
760+ raw = set_raw_breakpoint_at (raw_type, where, kind, err);
751761
752762 if (raw == NULL)
753763 {
@@ -773,9 +783,11 @@ struct breakpoint *
773783 set_breakpoint_at (CORE_ADDR where, int (*handler) (CORE_ADDR))
774784 {
775785 int err_ignored;
786+ CORE_ADDR placed_address = where;
787+ int breakpoint_kind = the_target->breakpoint_kind_from_pc (&placed_address);
776788
777789 return set_breakpoint (other_breakpoint, raw_bkpt_type_sw,
778- where, breakpoint_len, handler,
790+ placed_address, breakpoint_kind, handler,
779791 &err_ignored);
780792 }
781793
@@ -799,7 +811,7 @@ delete_raw_breakpoint (struct process_info *proc, struct raw_breakpoint *todel)
799811
800812 *bp_link = bp->next;
801813
802- ret = the_target->remove_point (bp->raw_type, bp->pc, bp->size,
814+ ret = the_target->remove_point (bp->raw_type, bp->pc, bp->kind,
803815 bp);
804816 if (ret != 0)
805817 {
@@ -891,12 +903,12 @@ delete_breakpoint (struct breakpoint *todel)
891903 return delete_breakpoint_1 (proc, todel);
892904 }
893905
894-/* Locate a GDB breakpoint of type Z_TYPE and size SIZE placed at
895- address ADDR and return a pointer to its structure. If SIZE is -1,
896- the breakpoints' sizes are ignored. */
906+/* Locate a GDB breakpoint of type Z_TYPE and kind KIND placed at
907+ address ADDR and return a pointer to its structure. If KIND is -1,
908+ the breakpoint's kind is ignored. */
897909
898910 static struct breakpoint *
899-find_gdb_breakpoint (char z_type, CORE_ADDR addr, int size)
911+find_gdb_breakpoint (char z_type, CORE_ADDR addr, int kind)
900912 {
901913 struct process_info *proc = current_process ();
902914 struct breakpoint *bp;
@@ -904,7 +916,7 @@ find_gdb_breakpoint (char z_type, CORE_ADDR addr, int size)
904916
905917 for (bp = proc->breakpoints; bp != NULL; bp = bp->next)
906918 if (bp->type == type && bp->raw->pc == addr
907- && (size == -1 || bp->raw->size == size))
919+ && (kind == -1 || bp->raw->kind == kind))
908920 return bp;
909921
910922 return NULL;
@@ -918,13 +930,13 @@ z_type_supported (char z_type)
918930 && the_target->supports_z_point_type (z_type));
919931 }
920932
921-/* Create a new GDB breakpoint of type Z_TYPE at ADDR with size SIZE.
933+/* Create a new GDB breakpoint of type Z_TYPE at ADDR with kind KIND.
922934 Returns a pointer to the newly created breakpoint on success. On
923935 failure returns NULL and sets *ERR to either -1 for error, or 1 if
924936 Z_TYPE breakpoints are not supported on this target. */
925937
926938 static struct breakpoint *
927-set_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int size, int *err)
939+set_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int kind, int *err)
928940 {
929941 struct breakpoint *bp;
930942 enum bkpt_type type;
@@ -952,9 +964,9 @@ set_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int size, int *err)
952964
953965 if (bp != NULL)
954966 {
955- if (bp->raw->size != size)
967+ if (bp->raw->kind != kind)
956968 {
957- /* A different size than previously seen. The previous
969+ /* A different kind than previously seen. The previous
958970 breakpoint must be gone then. */
959971 bp->raw->inserted = -1;
960972 delete_breakpoint (bp);
@@ -975,10 +987,10 @@ set_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int size, int *err)
975987 }
976988 else
977989 {
978- /* Data breakpoints for the same address but different size are
990+ /* Data breakpoints for the same address but different kind are
979991 expected. GDB doesn't merge these. The backend gets to do
980992 that if it wants/can. */
981- bp = find_gdb_breakpoint (z_type, addr, size);
993+ bp = find_gdb_breakpoint (z_type, addr, kind);
982994 }
983995
984996 if (bp != NULL)
@@ -993,7 +1005,7 @@ set_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int size, int *err)
9931005
9941006 raw_type = Z_packet_to_raw_bkpt_type (z_type);
9951007 type = Z_packet_to_bkpt_type (z_type);
996- return set_breakpoint (type, raw_type, addr, size, NULL, err);
1008+ return set_breakpoint (type, raw_type, addr, kind, NULL, err);
9971009 }
9981010
9991011 static int
@@ -1024,7 +1036,7 @@ check_gdb_bp_preconditions (char z_type, int *err)
10241036 knows to prepare to access memory for Z0 breakpoints. */
10251037
10261038 struct breakpoint *
1027-set_gdb_breakpoint (char z_type, CORE_ADDR addr, int size, int *err)
1039+set_gdb_breakpoint (char z_type, CORE_ADDR addr, int kind, int *err)
10281040 {
10291041 struct breakpoint *bp;
10301042
@@ -1040,7 +1052,7 @@ set_gdb_breakpoint (char z_type, CORE_ADDR addr, int size, int *err)
10401052 return NULL;
10411053 }
10421054
1043- bp = set_gdb_breakpoint_1 (z_type, addr, size, err);
1055+ bp = set_gdb_breakpoint_1 (z_type, addr, kind, err);
10441056
10451057 if (z_type == Z_PACKET_SW_BP)
10461058 done_accessing_memory ();
@@ -1048,18 +1060,18 @@ set_gdb_breakpoint (char z_type, CORE_ADDR addr, int size, int *err)
10481060 return bp;
10491061 }
10501062
1051-/* Delete a GDB breakpoint of type Z_TYPE and size SIZE previously
1063+/* Delete a GDB breakpoint of type Z_TYPE and kind KIND previously
10521064 inserted at ADDR with set_gdb_breakpoint_at. Returns 0 on success,
10531065 -1 on error, and 1 if Z_TYPE breakpoints are not supported on this
10541066 target. */
10551067
10561068 static int
1057-delete_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int size)
1069+delete_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int kind)
10581070 {
10591071 struct breakpoint *bp;
10601072 int err;
10611073
1062- bp = find_gdb_breakpoint (z_type, addr, size);
1074+ bp = find_gdb_breakpoint (z_type, addr, kind);
10631075 if (bp == NULL)
10641076 return -1;
10651077
@@ -1077,7 +1089,7 @@ delete_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int size)
10771089 knows to prepare to access memory for Z0 breakpoints. */
10781090
10791091 int
1080-delete_gdb_breakpoint (char z_type, CORE_ADDR addr, int size)
1092+delete_gdb_breakpoint (char z_type, CORE_ADDR addr, int kind)
10811093 {
10821094 int ret;
10831095
@@ -1095,7 +1107,7 @@ delete_gdb_breakpoint (char z_type, CORE_ADDR addr, int size)
10951107 return -1;
10961108 }
10971109
1098- ret = delete_gdb_breakpoint_1 (z_type, addr, size);
1110+ ret = delete_gdb_breakpoint_1 (z_type, addr, kind);
10991111
11001112 if (z_type == Z_PACKET_SW_BP)
11011113 done_accessing_memory ();
@@ -1438,7 +1450,7 @@ uninsert_raw_breakpoint (struct raw_breakpoint *bp)
14381450
14391451 bp->inserted = 0;
14401452
1441- err = the_target->remove_point (bp->raw_type, bp->pc, bp->size, bp);
1453+ err = the_target->remove_point (bp->raw_type, bp->pc, bp->kind, bp);
14421454 if (err != 0)
14431455 {
14441456 bp->inserted = 1;
@@ -1500,7 +1512,7 @@ reinsert_raw_breakpoint (struct raw_breakpoint *bp)
15001512 if (bp->inserted)
15011513 error ("Breakpoint already inserted at reinsert time.");
15021514
1503- err = the_target->insert_point (bp->raw_type, bp->pc, bp->size, bp);
1515+ err = the_target->insert_point (bp->raw_type, bp->pc, bp->kind, bp);
15041516 if (err == 0)
15051517 bp->inserted = 1;
15061518 else if (debug_threads)
@@ -1588,13 +1600,6 @@ check_breakpoints (CORE_ADDR stop_pc)
15881600 }
15891601 }
15901602
1591-void
1592-set_breakpoint_data (const unsigned char *bp_data, int bp_len)
1593-{
1594- breakpoint_data = bp_data;
1595- breakpoint_len = bp_len;
1596-}
1597-
15981603 int
15991604 breakpoint_here (CORE_ADDR addr)
16001605 {
@@ -1669,9 +1674,9 @@ validate_inserted_breakpoint (struct raw_breakpoint *bp)
16691674 gdb_assert (bp->inserted);
16701675 gdb_assert (bp->raw_type == raw_bkpt_type_sw);
16711676
1672- buf = (unsigned char *) alloca (breakpoint_len);
1673- err = (*the_target->read_memory) (bp->pc, buf, breakpoint_len);
1674- if (err || memcmp (buf, breakpoint_data, breakpoint_len) != 0)
1677+ buf = (unsigned char *) alloca (bp_size (bp));
1678+ err = (*the_target->read_memory) (bp->pc, buf, bp_size (bp));
1679+ if (err || memcmp (buf, bp_opcode (bp), bp_size (bp)) != 0)
16751680 {
16761681 /* Tag it as gone. */
16771682 bp->inserted = -1;
@@ -1762,7 +1767,7 @@ check_mem_read (CORE_ADDR mem_addr, unsigned char *buf, int mem_len)
17621767
17631768 for (; bp != NULL; bp = bp->next)
17641769 {
1765- CORE_ADDR bp_end = bp->pc + breakpoint_len;
1770+ CORE_ADDR bp_end = bp->pc + bp_size (bp);
17661771 CORE_ADDR start, end;
17671772 int copy_offset, copy_len, buf_offset;
17681773
@@ -1851,7 +1856,7 @@ check_mem_write (CORE_ADDR mem_addr, unsigned char *buf,
18511856
18521857 for (; bp != NULL; bp = bp->next)
18531858 {
1854- CORE_ADDR bp_end = bp->pc + breakpoint_len;
1859+ CORE_ADDR bp_end = bp->pc + bp_size (bp);
18551860 CORE_ADDR start, end;
18561861 int copy_offset, copy_len, buf_offset;
18571862
@@ -1882,7 +1887,7 @@ check_mem_write (CORE_ADDR mem_addr, unsigned char *buf,
18821887 if (bp->inserted > 0)
18831888 {
18841889 if (validate_inserted_breakpoint (bp))
1885- memcpy (buf + buf_offset, breakpoint_data + copy_offset, copy_len);
1890+ memcpy (buf + buf_offset, bp_opcode (bp) + copy_offset, copy_len);
18861891 else
18871892 disabled_one = 1;
18881893 }
@@ -1963,7 +1968,7 @@ clone_one_breakpoint (const struct breakpoint *src)
19631968 dest_raw->raw_type = src->raw->raw_type;
19641969 dest_raw->refcount = src->raw->refcount;
19651970 dest_raw->pc = src->raw->pc;
1966- dest_raw->size = src->raw->size;
1971+ dest_raw->kind = src->raw->kind;
19671972 memcpy (dest_raw->old_data, src->raw->old_data, MAX_BREAKPOINT_LEN);
19681973 dest_raw->inserted = src->raw->inserted;
19691974
--- a/gdb/gdbserver/mem-break.h
+++ b/gdb/gdbserver/mem-break.h
@@ -65,20 +65,20 @@ enum raw_bkpt_type Z_packet_to_raw_bkpt_type (char z_type);
6565 enum target_hw_bp_type raw_bkpt_type_to_target_hw_bp_type
6666 (enum raw_bkpt_type raw_type);
6767
68-/* Create a new GDB breakpoint of type Z_TYPE at ADDR with size SIZE.
68+/* Create a new GDB breakpoint of type Z_TYPE at ADDR with kind KIND.
6969 Returns a pointer to the newly created breakpoint on success. On
7070 failure returns NULL and sets *ERR to either -1 for error, or 1 if
7171 Z_TYPE breakpoints are not supported on this target. */
7272
73-struct breakpoint *set_gdb_breakpoint (char z_type, CORE_ADDR addr, int size,
73+struct breakpoint *set_gdb_breakpoint (char z_type, CORE_ADDR addr, int kind,
7474 int *err);
7575
76-/* Delete a GDB breakpoint of type Z_TYPE and size SIZE previously
76+/* Delete a GDB breakpoint of type Z_TYPE and kind KIND previously
7777 inserted at ADDR with set_gdb_breakpoint_at. Returns 0 on success,
7878 -1 on error, and 1 if Z_TYPE breakpoints are not supported on this
7979 target. */
8080
81-int delete_gdb_breakpoint (char z_type, CORE_ADDR addr, int size);
81+int delete_gdb_breakpoint (char z_type, CORE_ADDR addr, int kind);
8282
8383 /* Returns TRUE if there's a software or hardware (code) breakpoint at
8484 ADDR in our tables, inserted, or not. */
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -4069,20 +4069,20 @@ process_serial_event (void)
40694069 {
40704070 char *dataptr;
40714071 ULONGEST addr;
4072- int len;
4072+ int kind;
40734073 char type = own_buf[1];
40744074 int res;
40754075 const int insert = ch == 'Z';
40764076 char *p = &own_buf[3];
40774077
40784078 p = unpack_varlen_hex (p, &addr);
4079- len = strtol (p + 1, &dataptr, 16);
4079+ kind = strtol (p + 1, &dataptr, 16);
40804080
40814081 if (insert)
40824082 {
40834083 struct breakpoint *bp;
40844084
4085- bp = set_gdb_breakpoint (type, addr, len, &res);
4085+ bp = set_gdb_breakpoint (type, addr, kind, &res);
40864086 if (bp != NULL)
40874087 {
40884088 res = 0;
@@ -4097,7 +4097,7 @@ process_serial_event (void)
40974097 }
40984098 }
40994099 else
4100- res = delete_gdb_breakpoint (type, addr, len);
4100+ res = delete_gdb_breakpoint (type, addr, kind);
41014101
41024102 if (res == 0)
41034103 write_ok (own_buf);