GNU Binutils with patches for OS216
Revision | 2716529498941971b698f603e9aa0edc89905cb8 (tree) |
---|---|
Time | 2015-10-22 00:24:55 |
Author | Antoine Tremblay <antoine.tremblay@eric...> |
Commiter | Antoine Tremblay |
Support breakpoint kinds for software breakpoints in GDBServer.
There's two ways to set breakpoints in GDBServer.
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.
@@ -1,5 +1,38 @@ | ||
1 | 1 | 2015-10-21 Antoine Tremblay <antoine.tremblay@ericsson.com> |
2 | 2 | |
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 | + | |
3 | 36 | * linux-aarch64-low.c (aarch64_sw_breakpoint_from_kind): New function. |
4 | 37 | (struct linux_target_ops) <breakpoint>: Remove. |
5 | 38 | (struct linux_target_ops) <breakpoint_len>: Remove. |
@@ -7082,20 +7082,10 @@ void | ||
7082 | 7082 | initialize_low (void) |
7083 | 7083 | { |
7084 | 7084 | struct sigaction sigchld_action; |
7085 | - int breakpoint_kind = 0; | |
7086 | - int breakpoint_size = 0; | |
7087 | - const gdb_byte *breakpoint = NULL; | |
7088 | 7085 | |
7089 | 7086 | memset (&sigchld_action, 0, sizeof (sigchld_action)); |
7090 | 7087 | set_target_ops (&linux_target_ops); |
7091 | 7088 | |
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 | - | |
7099 | 7089 | linux_init_signals (); |
7100 | 7090 | linux_ptrace_init_warnings (); |
7101 | 7091 |
@@ -21,8 +21,6 @@ | ||
21 | 21 | #include "server.h" |
22 | 22 | #include "regcache.h" |
23 | 23 | #include "ax.h" |
24 | -const unsigned char *breakpoint_data; | |
25 | -int breakpoint_len; | |
26 | 24 | |
27 | 25 | #define MAX_BREAKPOINT_LEN 8 |
28 | 26 |
@@ -100,8 +98,13 @@ struct raw_breakpoint | ||
100 | 98 | breakpoint for a given PC. */ |
101 | 99 | CORE_ADDR pc; |
102 | 100 | |
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; | |
105 | 108 | |
106 | 109 | /* The breakpoint's shadow memory. */ |
107 | 110 | unsigned char old_data[MAX_BREAKPOINT_LEN]; |
@@ -189,6 +192,27 @@ struct breakpoint | ||
189 | 192 | int (*handler) (CORE_ADDR); |
190 | 193 | }; |
191 | 194 | |
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 | + | |
192 | 216 | /* See mem-break.h. */ |
193 | 217 | |
194 | 218 | enum target_hw_bp_type |
@@ -281,13 +305,13 @@ find_enabled_raw_code_breakpoint_at (CORE_ADDR addr, enum raw_bkpt_type type) | ||
281 | 305 | NULL if not found. */ |
282 | 306 | |
283 | 307 | 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) | |
285 | 309 | { |
286 | 310 | struct process_info *proc = current_process (); |
287 | 311 | struct raw_breakpoint *bp; |
288 | 312 | |
289 | 313 | 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) | |
291 | 315 | return bp; |
292 | 316 | |
293 | 317 | return NULL; |
@@ -301,24 +325,10 @@ insert_memory_breakpoint (struct raw_breakpoint *bp) | ||
301 | 325 | unsigned char buf[MAX_BREAKPOINT_LEN]; |
302 | 326 | int err; |
303 | 327 | |
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 | - | |
318 | 328 | /* Note that there can be fast tracepoint jumps installed in the |
319 | 329 | same memory range, so to get at the original memory, we need to |
320 | 330 | 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)); | |
322 | 332 | if (err != 0) |
323 | 333 | { |
324 | 334 | if (debug_threads) |
@@ -328,10 +338,10 @@ insert_memory_breakpoint (struct raw_breakpoint *bp) | ||
328 | 338 | } |
329 | 339 | else |
330 | 340 | { |
331 | - memcpy (bp->old_data, buf, breakpoint_len); | |
341 | + memcpy (bp->old_data, buf, bp_size (bp)); | |
332 | 342 | |
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)); | |
335 | 345 | if (err != 0) |
336 | 346 | { |
337 | 347 | if (debug_threads) |
@@ -358,8 +368,8 @@ remove_memory_breakpoint (struct raw_breakpoint *bp) | ||
358 | 368 | note that we need to pass the current shadow contents, because |
359 | 369 | write_inferior_memory updates any shadow memory with what we pass |
360 | 370 | 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)); | |
363 | 373 | if (err != 0) |
364 | 374 | { |
365 | 375 | if (debug_threads) |
@@ -370,12 +380,12 @@ remove_memory_breakpoint (struct raw_breakpoint *bp) | ||
370 | 380 | return err != 0 ? -1 : 0; |
371 | 381 | } |
372 | 382 | |
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 | |
374 | 384 | success, a pointer to the new breakpoint is returned. On failure, |
375 | 385 | returns NULL and writes the error code to *ERR. */ |
376 | 386 | |
377 | 387 | 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, | |
379 | 389 | int *err) |
380 | 390 | { |
381 | 391 | struct process_info *proc = current_process (); |
@@ -384,19 +394,19 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int size, | ||
384 | 394 | if (type == raw_bkpt_type_sw || type == raw_bkpt_type_hw) |
385 | 395 | { |
386 | 396 | bp = find_enabled_raw_code_breakpoint_at (where, type); |
387 | - if (bp != NULL && bp->size != size) | |
397 | + if (bp != NULL && bp->kind != kind) | |
388 | 398 | { |
389 | - /* A different size than previously seen. The previous | |
399 | + /* A different kind than previously seen. The previous | |
390 | 400 | breakpoint must be gone then. */ |
391 | 401 | 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); | |
394 | 404 | bp->inserted = -1; |
395 | 405 | bp = NULL; |
396 | 406 | } |
397 | 407 | } |
398 | 408 | else |
399 | - bp = find_raw_breakpoint_at (where, type, size); | |
409 | + bp = find_raw_breakpoint_at (where, type, kind); | |
400 | 410 | |
401 | 411 | if (bp != NULL) |
402 | 412 | { |
@@ -406,11 +416,11 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int size, | ||
406 | 416 | |
407 | 417 | bp = XCNEW (struct raw_breakpoint); |
408 | 418 | bp->pc = where; |
409 | - bp->size = size; | |
419 | + bp->kind = kind; | |
410 | 420 | bp->refcount = 1; |
411 | 421 | bp->raw_type = type; |
412 | 422 | |
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); | |
414 | 424 | if (*err != 0) |
415 | 425 | { |
416 | 426 | if (debug_threads) |
@@ -732,7 +742,7 @@ reinsert_fast_tracepoint_jumps_at (CORE_ADDR where) | ||
732 | 742 | } |
733 | 743 | |
734 | 744 | /* 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 | |
736 | 746 | breakpoint is returned. On failure, returns NULL and writes the |
737 | 747 | error code to *ERR. HANDLER is called when the breakpoint is hit. |
738 | 748 | HANDLER should return 1 if the breakpoint should be deleted, 0 |
@@ -740,14 +750,14 @@ reinsert_fast_tracepoint_jumps_at (CORE_ADDR where) | ||
740 | 750 | |
741 | 751 | static struct breakpoint * |
742 | 752 | set_breakpoint (enum bkpt_type type, enum raw_bkpt_type raw_type, |
743 | - CORE_ADDR where, int size, | |
753 | + CORE_ADDR where, int kind, | |
744 | 754 | int (*handler) (CORE_ADDR), int *err) |
745 | 755 | { |
746 | 756 | struct process_info *proc = current_process (); |
747 | 757 | struct breakpoint *bp; |
748 | 758 | struct raw_breakpoint *raw; |
749 | 759 | |
750 | - raw = set_raw_breakpoint_at (raw_type, where, size, err); | |
760 | + raw = set_raw_breakpoint_at (raw_type, where, kind, err); | |
751 | 761 | |
752 | 762 | if (raw == NULL) |
753 | 763 | { |
@@ -773,9 +783,11 @@ struct breakpoint * | ||
773 | 783 | set_breakpoint_at (CORE_ADDR where, int (*handler) (CORE_ADDR)) |
774 | 784 | { |
775 | 785 | int err_ignored; |
786 | + CORE_ADDR placed_address = where; | |
787 | + int breakpoint_kind = the_target->breakpoint_kind_from_pc (&placed_address); | |
776 | 788 | |
777 | 789 | return set_breakpoint (other_breakpoint, raw_bkpt_type_sw, |
778 | - where, breakpoint_len, handler, | |
790 | + placed_address, breakpoint_kind, handler, | |
779 | 791 | &err_ignored); |
780 | 792 | } |
781 | 793 |
@@ -799,7 +811,7 @@ delete_raw_breakpoint (struct process_info *proc, struct raw_breakpoint *todel) | ||
799 | 811 | |
800 | 812 | *bp_link = bp->next; |
801 | 813 | |
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, | |
803 | 815 | bp); |
804 | 816 | if (ret != 0) |
805 | 817 | { |
@@ -891,12 +903,12 @@ delete_breakpoint (struct breakpoint *todel) | ||
891 | 903 | return delete_breakpoint_1 (proc, todel); |
892 | 904 | } |
893 | 905 | |
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. */ | |
897 | 909 | |
898 | 910 | 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) | |
900 | 912 | { |
901 | 913 | struct process_info *proc = current_process (); |
902 | 914 | struct breakpoint *bp; |
@@ -904,7 +916,7 @@ find_gdb_breakpoint (char z_type, CORE_ADDR addr, int size) | ||
904 | 916 | |
905 | 917 | for (bp = proc->breakpoints; bp != NULL; bp = bp->next) |
906 | 918 | if (bp->type == type && bp->raw->pc == addr |
907 | - && (size == -1 || bp->raw->size == size)) | |
919 | + && (kind == -1 || bp->raw->kind == kind)) | |
908 | 920 | return bp; |
909 | 921 | |
910 | 922 | return NULL; |
@@ -918,13 +930,13 @@ z_type_supported (char z_type) | ||
918 | 930 | && the_target->supports_z_point_type (z_type)); |
919 | 931 | } |
920 | 932 | |
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. | |
922 | 934 | Returns a pointer to the newly created breakpoint on success. On |
923 | 935 | failure returns NULL and sets *ERR to either -1 for error, or 1 if |
924 | 936 | Z_TYPE breakpoints are not supported on this target. */ |
925 | 937 | |
926 | 938 | 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) | |
928 | 940 | { |
929 | 941 | struct breakpoint *bp; |
930 | 942 | enum bkpt_type type; |
@@ -952,9 +964,9 @@ set_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int size, int *err) | ||
952 | 964 | |
953 | 965 | if (bp != NULL) |
954 | 966 | { |
955 | - if (bp->raw->size != size) | |
967 | + if (bp->raw->kind != kind) | |
956 | 968 | { |
957 | - /* A different size than previously seen. The previous | |
969 | + /* A different kind than previously seen. The previous | |
958 | 970 | breakpoint must be gone then. */ |
959 | 971 | bp->raw->inserted = -1; |
960 | 972 | delete_breakpoint (bp); |
@@ -975,10 +987,10 @@ set_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int size, int *err) | ||
975 | 987 | } |
976 | 988 | else |
977 | 989 | { |
978 | - /* Data breakpoints for the same address but different size are | |
990 | + /* Data breakpoints for the same address but different kind are | |
979 | 991 | expected. GDB doesn't merge these. The backend gets to do |
980 | 992 | that if it wants/can. */ |
981 | - bp = find_gdb_breakpoint (z_type, addr, size); | |
993 | + bp = find_gdb_breakpoint (z_type, addr, kind); | |
982 | 994 | } |
983 | 995 | |
984 | 996 | if (bp != NULL) |
@@ -993,7 +1005,7 @@ set_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int size, int *err) | ||
993 | 1005 | |
994 | 1006 | raw_type = Z_packet_to_raw_bkpt_type (z_type); |
995 | 1007 | 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); | |
997 | 1009 | } |
998 | 1010 | |
999 | 1011 | static int |
@@ -1024,7 +1036,7 @@ check_gdb_bp_preconditions (char z_type, int *err) | ||
1024 | 1036 | knows to prepare to access memory for Z0 breakpoints. */ |
1025 | 1037 | |
1026 | 1038 | 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) | |
1028 | 1040 | { |
1029 | 1041 | struct breakpoint *bp; |
1030 | 1042 |
@@ -1040,7 +1052,7 @@ set_gdb_breakpoint (char z_type, CORE_ADDR addr, int size, int *err) | ||
1040 | 1052 | return NULL; |
1041 | 1053 | } |
1042 | 1054 | |
1043 | - bp = set_gdb_breakpoint_1 (z_type, addr, size, err); | |
1055 | + bp = set_gdb_breakpoint_1 (z_type, addr, kind, err); | |
1044 | 1056 | |
1045 | 1057 | if (z_type == Z_PACKET_SW_BP) |
1046 | 1058 | done_accessing_memory (); |
@@ -1048,18 +1060,18 @@ set_gdb_breakpoint (char z_type, CORE_ADDR addr, int size, int *err) | ||
1048 | 1060 | return bp; |
1049 | 1061 | } |
1050 | 1062 | |
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 | |
1052 | 1064 | inserted at ADDR with set_gdb_breakpoint_at. Returns 0 on success, |
1053 | 1065 | -1 on error, and 1 if Z_TYPE breakpoints are not supported on this |
1054 | 1066 | target. */ |
1055 | 1067 | |
1056 | 1068 | 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) | |
1058 | 1070 | { |
1059 | 1071 | struct breakpoint *bp; |
1060 | 1072 | int err; |
1061 | 1073 | |
1062 | - bp = find_gdb_breakpoint (z_type, addr, size); | |
1074 | + bp = find_gdb_breakpoint (z_type, addr, kind); | |
1063 | 1075 | if (bp == NULL) |
1064 | 1076 | return -1; |
1065 | 1077 |
@@ -1077,7 +1089,7 @@ delete_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int size) | ||
1077 | 1089 | knows to prepare to access memory for Z0 breakpoints. */ |
1078 | 1090 | |
1079 | 1091 | 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) | |
1081 | 1093 | { |
1082 | 1094 | int ret; |
1083 | 1095 |
@@ -1095,7 +1107,7 @@ delete_gdb_breakpoint (char z_type, CORE_ADDR addr, int size) | ||
1095 | 1107 | return -1; |
1096 | 1108 | } |
1097 | 1109 | |
1098 | - ret = delete_gdb_breakpoint_1 (z_type, addr, size); | |
1110 | + ret = delete_gdb_breakpoint_1 (z_type, addr, kind); | |
1099 | 1111 | |
1100 | 1112 | if (z_type == Z_PACKET_SW_BP) |
1101 | 1113 | done_accessing_memory (); |
@@ -1438,7 +1450,7 @@ uninsert_raw_breakpoint (struct raw_breakpoint *bp) | ||
1438 | 1450 | |
1439 | 1451 | bp->inserted = 0; |
1440 | 1452 | |
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); | |
1442 | 1454 | if (err != 0) |
1443 | 1455 | { |
1444 | 1456 | bp->inserted = 1; |
@@ -1500,7 +1512,7 @@ reinsert_raw_breakpoint (struct raw_breakpoint *bp) | ||
1500 | 1512 | if (bp->inserted) |
1501 | 1513 | error ("Breakpoint already inserted at reinsert time."); |
1502 | 1514 | |
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); | |
1504 | 1516 | if (err == 0) |
1505 | 1517 | bp->inserted = 1; |
1506 | 1518 | else if (debug_threads) |
@@ -1588,13 +1600,6 @@ check_breakpoints (CORE_ADDR stop_pc) | ||
1588 | 1600 | } |
1589 | 1601 | } |
1590 | 1602 | |
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 | - | |
1598 | 1603 | int |
1599 | 1604 | breakpoint_here (CORE_ADDR addr) |
1600 | 1605 | { |
@@ -1669,9 +1674,9 @@ validate_inserted_breakpoint (struct raw_breakpoint *bp) | ||
1669 | 1674 | gdb_assert (bp->inserted); |
1670 | 1675 | gdb_assert (bp->raw_type == raw_bkpt_type_sw); |
1671 | 1676 | |
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) | |
1675 | 1680 | { |
1676 | 1681 | /* Tag it as gone. */ |
1677 | 1682 | bp->inserted = -1; |
@@ -1762,7 +1767,7 @@ check_mem_read (CORE_ADDR mem_addr, unsigned char *buf, int mem_len) | ||
1762 | 1767 | |
1763 | 1768 | for (; bp != NULL; bp = bp->next) |
1764 | 1769 | { |
1765 | - CORE_ADDR bp_end = bp->pc + breakpoint_len; | |
1770 | + CORE_ADDR bp_end = bp->pc + bp_size (bp); | |
1766 | 1771 | CORE_ADDR start, end; |
1767 | 1772 | int copy_offset, copy_len, buf_offset; |
1768 | 1773 |
@@ -1851,7 +1856,7 @@ check_mem_write (CORE_ADDR mem_addr, unsigned char *buf, | ||
1851 | 1856 | |
1852 | 1857 | for (; bp != NULL; bp = bp->next) |
1853 | 1858 | { |
1854 | - CORE_ADDR bp_end = bp->pc + breakpoint_len; | |
1859 | + CORE_ADDR bp_end = bp->pc + bp_size (bp); | |
1855 | 1860 | CORE_ADDR start, end; |
1856 | 1861 | int copy_offset, copy_len, buf_offset; |
1857 | 1862 |
@@ -1882,7 +1887,7 @@ check_mem_write (CORE_ADDR mem_addr, unsigned char *buf, | ||
1882 | 1887 | if (bp->inserted > 0) |
1883 | 1888 | { |
1884 | 1889 | 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); | |
1886 | 1891 | else |
1887 | 1892 | disabled_one = 1; |
1888 | 1893 | } |
@@ -1963,7 +1968,7 @@ clone_one_breakpoint (const struct breakpoint *src) | ||
1963 | 1968 | dest_raw->raw_type = src->raw->raw_type; |
1964 | 1969 | dest_raw->refcount = src->raw->refcount; |
1965 | 1970 | dest_raw->pc = src->raw->pc; |
1966 | - dest_raw->size = src->raw->size; | |
1971 | + dest_raw->kind = src->raw->kind; | |
1967 | 1972 | memcpy (dest_raw->old_data, src->raw->old_data, MAX_BREAKPOINT_LEN); |
1968 | 1973 | dest_raw->inserted = src->raw->inserted; |
1969 | 1974 |
@@ -65,20 +65,20 @@ enum raw_bkpt_type Z_packet_to_raw_bkpt_type (char z_type); | ||
65 | 65 | enum target_hw_bp_type raw_bkpt_type_to_target_hw_bp_type |
66 | 66 | (enum raw_bkpt_type raw_type); |
67 | 67 | |
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. | |
69 | 69 | Returns a pointer to the newly created breakpoint on success. On |
70 | 70 | failure returns NULL and sets *ERR to either -1 for error, or 1 if |
71 | 71 | Z_TYPE breakpoints are not supported on this target. */ |
72 | 72 | |
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, | |
74 | 74 | int *err); |
75 | 75 | |
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 | |
77 | 77 | inserted at ADDR with set_gdb_breakpoint_at. Returns 0 on success, |
78 | 78 | -1 on error, and 1 if Z_TYPE breakpoints are not supported on this |
79 | 79 | target. */ |
80 | 80 | |
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); | |
82 | 82 | |
83 | 83 | /* Returns TRUE if there's a software or hardware (code) breakpoint at |
84 | 84 | ADDR in our tables, inserted, or not. */ |
@@ -4069,20 +4069,20 @@ process_serial_event (void) | ||
4069 | 4069 | { |
4070 | 4070 | char *dataptr; |
4071 | 4071 | ULONGEST addr; |
4072 | - int len; | |
4072 | + int kind; | |
4073 | 4073 | char type = own_buf[1]; |
4074 | 4074 | int res; |
4075 | 4075 | const int insert = ch == 'Z'; |
4076 | 4076 | char *p = &own_buf[3]; |
4077 | 4077 | |
4078 | 4078 | p = unpack_varlen_hex (p, &addr); |
4079 | - len = strtol (p + 1, &dataptr, 16); | |
4079 | + kind = strtol (p + 1, &dataptr, 16); | |
4080 | 4080 | |
4081 | 4081 | if (insert) |
4082 | 4082 | { |
4083 | 4083 | struct breakpoint *bp; |
4084 | 4084 | |
4085 | - bp = set_gdb_breakpoint (type, addr, len, &res); | |
4085 | + bp = set_gdb_breakpoint (type, addr, kind, &res); | |
4086 | 4086 | if (bp != NULL) |
4087 | 4087 | { |
4088 | 4088 | res = 0; |
@@ -4097,7 +4097,7 @@ process_serial_event (void) | ||
4097 | 4097 | } |
4098 | 4098 | } |
4099 | 4099 | else |
4100 | - res = delete_gdb_breakpoint (type, addr, len); | |
4100 | + res = delete_gdb_breakpoint (type, addr, kind); | |
4101 | 4101 | |
4102 | 4102 | if (res == 0) |
4103 | 4103 | write_ok (own_buf); |