]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/gdbserver/mem-break.c
1 /* Memory breakpoint operations for the remote server for GDB.
2 Copyright (C) 2002, 2003, 2005, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc.
5 Contributed by MontaVista Software.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
27 const unsigned char *breakpoint_data
;
30 #define MAX_BREAKPOINT_LEN 8
32 /* GDB will never try to install multiple breakpoints at the same
33 address. But, we need to keep track of internal breakpoints too,
34 and so we do need to be able to install multiple breakpoints at the
35 same address transparently. We keep track of two different, and
36 closely related structures. A raw breakpoint, which manages the
37 low level, close to the metal aspect of a breakpoint. It holds the
38 breakpoint address, and a buffer holding a copy of the instructions
39 that would be in memory had not been a breakpoint there (we call
40 that the shadow memory of the breakpoint). We occasionally need to
41 temporarilly uninsert a breakpoint without the client knowing about
42 it (e.g., to step over an internal breakpoint), so we keep an
43 `inserted' state associated with this low level breakpoint
44 structure. There can only be one such object for a given address.
45 Then, we have (a bit higher level) breakpoints. This structure
46 holds a callback to be called whenever a breakpoint is hit, a
47 high-level type, and a link to a low level raw breakpoint. There
48 can be many high-level breakpoints at the same address, and all of
49 them will point to the same raw breakpoint, which is reference
52 /* The low level, physical, raw breakpoint. */
55 struct raw_breakpoint
*next
;
57 /* A reference count. Each high level breakpoint referencing this
58 raw breakpoint accounts for one reference. */
61 /* The breakpoint's insertion address. There can only be one raw
62 breakpoint for a given PC. */
65 /* The breakpoint's shadow memory. */
66 unsigned char old_data
[MAX_BREAKPOINT_LEN
];
68 /* Non-zero if this breakpoint is currently inserted in the
72 /* Non-zero if this breakpoint is currently disabled because we no
73 longer detect it as inserted. */
77 /* The type of a breakpoint. */
80 /* A GDB breakpoint, requested with a Z0 packet. */
83 /* A basic-software-single-step breakpoint. */
86 /* Any other breakpoint type that doesn't require specific
87 treatment goes here. E.g., an event breakpoint. */
91 /* A high level (in gdbserver's perspective) breakpoint. */
94 struct breakpoint
*next
;
96 /* The breakpoint's type. */
99 /* Link to this breakpoint's raw breakpoint. This is always
101 struct raw_breakpoint
*raw
;
103 /* Function to call when we hit this breakpoint. If it returns 1,
104 the breakpoint shall be deleted; 0 or if this callback is NULL,
105 it will be left inserted. */
106 int (*handler
) (CORE_ADDR
);
109 static struct raw_breakpoint
*
110 find_raw_breakpoint_at (CORE_ADDR where
)
112 struct process_info
*proc
= current_process ();
113 struct raw_breakpoint
*bp
;
115 for (bp
= proc
->raw_breakpoints
; bp
!= NULL
; bp
= bp
->next
)
122 static struct raw_breakpoint
*
123 set_raw_breakpoint_at (CORE_ADDR where
)
125 struct process_info
*proc
= current_process ();
126 struct raw_breakpoint
*bp
;
129 if (breakpoint_data
== NULL
)
130 error ("Target does not support breakpoints.");
132 bp
= find_raw_breakpoint_at (where
);
139 bp
= xcalloc (1, sizeof (*bp
));
143 /* Note that there can be fast tracepoint jumps installed in the
144 same memory range, so to get at the original memory, we need to
145 use read_inferior_memory, which masks those out. */
146 err
= read_inferior_memory (where
, bp
->old_data
, breakpoint_len
);
151 "Failed to read shadow memory of"
152 " breakpoint at 0x%s (%s).\n",
153 paddress (where
), strerror (err
));
158 err
= (*the_target
->write_memory
) (where
, breakpoint_data
,
164 "Failed to insert breakpoint at 0x%s (%s).\n",
165 paddress (where
), strerror (err
));
170 /* Link the breakpoint in. */
172 bp
->next
= proc
->raw_breakpoints
;
173 proc
->raw_breakpoints
= bp
;
177 /* Notice that breakpoint traps are always installed on top of fast
178 tracepoint jumps. This is even if the fast tracepoint is installed
179 at a later time compared to when the breakpoint was installed.
180 This means that a stopping breakpoint or tracepoint has higher
181 "priority". In turn, this allows having fast and slow tracepoints
182 (and breakpoints) at the same address behave correctly. */
185 /* A fast tracepoint jump. */
187 struct fast_tracepoint_jump
189 struct fast_tracepoint_jump
*next
;
191 /* A reference count. GDB can install more than one fast tracepoint
192 at the same address (each with its own action list, for
196 /* The fast tracepoint's insertion address. There can only be one
197 of these for a given PC. */
200 /* Non-zero if this fast tracepoint jump is currently inserted in
204 /* The length of the jump instruction. */
207 /* A poor-man's flexible array member, holding both the jump
208 instruction to insert, and a copy of the instruction that would
209 be in memory had not been a jump there (the shadow memory of the
211 unsigned char insn_and_shadow
[0];
214 /* Fast tracepoint FP's jump instruction to insert. */
215 #define fast_tracepoint_jump_insn(fp) \
216 ((fp)->insn_and_shadow + 0)
218 /* The shadow memory of fast tracepoint jump FP. */
219 #define fast_tracepoint_jump_shadow(fp) \
220 ((fp)->insn_and_shadow + (fp)->length)
223 /* Return the fast tracepoint jump set at WHERE. */
225 static struct fast_tracepoint_jump
*
226 find_fast_tracepoint_jump_at (CORE_ADDR where
)
228 struct process_info
*proc
= current_process ();
229 struct fast_tracepoint_jump
*jp
;
231 for (jp
= proc
->fast_tracepoint_jumps
; jp
!= NULL
; jp
= jp
->next
)
239 fast_tracepoint_jump_here (CORE_ADDR where
)
241 struct fast_tracepoint_jump
*jp
= find_fast_tracepoint_jump_at (where
);
247 delete_fast_tracepoint_jump (struct fast_tracepoint_jump
*todel
)
249 struct fast_tracepoint_jump
*bp
, **bp_link
;
251 struct process_info
*proc
= current_process ();
253 bp
= proc
->fast_tracepoint_jumps
;
254 bp_link
= &proc
->fast_tracepoint_jumps
;
260 if (--bp
->refcount
== 0)
262 struct fast_tracepoint_jump
*prev_bp_link
= *bp_link
;
267 /* Since there can be breakpoints inserted in the same
268 address range, we use `write_inferior_memory', which
269 takes care of layering breakpoints on top of fast
270 tracepoints, and on top of the buffer we pass it.
271 This works because we've already unlinked the fast
272 tracepoint jump above. Also note that we need to
273 pass the current shadow contents, because
274 write_inferior_memory updates any shadow memory with
275 what we pass here, and we want that to be a nop. */
276 ret
= write_inferior_memory (bp
->pc
,
277 fast_tracepoint_jump_shadow (bp
),
281 /* Something went wrong, relink the jump. */
282 *bp_link
= prev_bp_link
;
286 "Failed to uninsert fast tracepoint jump "
287 "at 0x%s (%s) while deleting it.\n",
288 paddress (bp
->pc
), strerror (ret
));
304 warning ("Could not find fast tracepoint jump in list.");
308 struct fast_tracepoint_jump
*
309 set_fast_tracepoint_jump (CORE_ADDR where
,
310 unsigned char *insn
, ULONGEST length
)
312 struct process_info
*proc
= current_process ();
313 struct fast_tracepoint_jump
*jp
;
316 /* We refcount fast tracepoint jumps. Check if we already know
317 about a jump at this address. */
318 jp
= find_fast_tracepoint_jump_at (where
);
325 /* We don't, so create a new object. Double the length, because the
326 flexible array member holds both the jump insn, and the
328 jp
= xcalloc (1, sizeof (*jp
) + (length
* 2));
331 memcpy (fast_tracepoint_jump_insn (jp
), insn
, length
);
334 /* Note that there can be trap breakpoints inserted in the same
335 address range. To access the original memory contents, we use
336 `read_inferior_memory', which masks out breakpoints. */
337 err
= read_inferior_memory (where
,
338 fast_tracepoint_jump_shadow (jp
), jp
->length
);
343 "Failed to read shadow memory of"
344 " fast tracepoint at 0x%s (%s).\n",
345 paddress (where
), strerror (err
));
350 /* Link the jump in. */
352 jp
->next
= proc
->fast_tracepoint_jumps
;
353 proc
->fast_tracepoint_jumps
= jp
;
355 /* Since there can be trap breakpoints inserted in the same address
356 range, we use use `write_inferior_memory', which takes care of
357 layering breakpoints on top of fast tracepoints, on top of the
358 buffer we pass it. This works because we've already linked in
359 the fast tracepoint jump above. Also note that we need to pass
360 the current shadow contents, because write_inferior_memory
361 updates any shadow memory with what we pass here, and we want
363 err
= write_inferior_memory (where
, fast_tracepoint_jump_shadow (jp
), length
);
368 "Failed to insert fast tracepoint jump at 0x%s (%s).\n",
369 paddress (where
), strerror (err
));
372 proc
->fast_tracepoint_jumps
= jp
->next
;
382 uninsert_fast_tracepoint_jumps_at (CORE_ADDR pc
)
384 struct fast_tracepoint_jump
*jp
;
387 jp
= find_fast_tracepoint_jump_at (pc
);
390 /* This can happen when we remove all breakpoints while handling
394 "Could not find fast tracepoint jump at 0x%s "
395 "in list (uninserting).\n",
404 /* Since there can be trap breakpoints inserted in the same
405 address range, we use use `write_inferior_memory', which
406 takes care of layering breakpoints on top of fast
407 tracepoints, and on top of the buffer we pass it. This works
408 because we've already marked the fast tracepoint fast
409 tracepoint jump uninserted above. Also note that we need to
410 pass the current shadow contents, because
411 write_inferior_memory updates any shadow memory with what we
412 pass here, and we want that to be a nop. */
413 err
= write_inferior_memory (jp
->pc
,
414 fast_tracepoint_jump_shadow (jp
),
422 "Failed to uninsert fast tracepoint jump at 0x%s (%s).\n",
423 paddress (pc
), strerror (err
));
429 reinsert_fast_tracepoint_jumps_at (CORE_ADDR where
)
431 struct fast_tracepoint_jump
*jp
;
434 jp
= find_fast_tracepoint_jump_at (where
);
437 /* This can happen when we remove breakpoints when a tracepoint
438 hit causes a tracing stop, while handling a step-over. */
441 "Could not find fast tracepoint jump at 0x%s "
442 "in list (reinserting).\n",
448 error ("Jump already inserted at reinsert time.");
452 /* Since there can be trap breakpoints inserted in the same address
453 range, we use `write_inferior_memory', which takes care of
454 layering breakpoints on top of fast tracepoints, and on top of
455 the buffer we pass it. This works because we've already marked
456 the fast tracepoint jump inserted above. Also note that we need
457 to pass the current shadow contents, because
458 write_inferior_memory updates any shadow memory with what we pass
459 here, and we want that to be a nop. */
460 err
= write_inferior_memory (where
,
461 fast_tracepoint_jump_shadow (jp
), jp
->length
);
468 "Failed to reinsert fast tracepoint jump at 0x%s (%s).\n",
469 paddress (where
), strerror (err
));
474 set_breakpoint_at (CORE_ADDR where
, int (*handler
) (CORE_ADDR
))
476 struct process_info
*proc
= current_process ();
477 struct breakpoint
*bp
;
478 struct raw_breakpoint
*raw
;
480 raw
= set_raw_breakpoint_at (where
);
488 bp
= xcalloc (1, sizeof (struct breakpoint
));
489 bp
->type
= other_breakpoint
;
492 bp
->handler
= handler
;
494 bp
->next
= proc
->breakpoints
;
495 proc
->breakpoints
= bp
;
501 delete_raw_breakpoint (struct process_info
*proc
, struct raw_breakpoint
*todel
)
503 struct raw_breakpoint
*bp
, **bp_link
;
506 bp
= proc
->raw_breakpoints
;
507 bp_link
= &proc
->raw_breakpoints
;
515 struct raw_breakpoint
*prev_bp_link
= *bp_link
;
519 /* Since there can be trap breakpoints inserted in the
520 same address range, we use `write_inferior_memory',
521 which takes care of layering breakpoints on top of
522 fast tracepoints, and on top of the buffer we pass
523 it. This works because we've already unlinked the
524 fast tracepoint jump above. Also note that we need
525 to pass the current shadow contents, because
526 write_inferior_memory updates any shadow memory with
527 what we pass here, and we want that to be a nop. */
528 ret
= write_inferior_memory (bp
->pc
, bp
->old_data
,
532 /* Something went wrong, relink the breakpoint. */
533 *bp_link
= prev_bp_link
;
537 "Failed to uninsert raw breakpoint "
538 "at 0x%s (%s) while deleting it.\n",
539 paddress (bp
->pc
), strerror (ret
));
557 warning ("Could not find raw breakpoint in list.");
562 release_breakpoint (struct process_info
*proc
, struct breakpoint
*bp
)
567 newrefcount
= bp
->raw
->refcount
- 1;
568 if (newrefcount
== 0)
570 ret
= delete_raw_breakpoint (proc
, bp
->raw
);
575 bp
->raw
->refcount
= newrefcount
;
583 delete_breakpoint_1 (struct process_info
*proc
, struct breakpoint
*todel
)
585 struct breakpoint
*bp
, **bp_link
;
588 bp
= proc
->breakpoints
;
589 bp_link
= &proc
->breakpoints
;
597 err
= release_breakpoint (proc
, bp
);
611 warning ("Could not find breakpoint in list.");
616 delete_breakpoint (struct breakpoint
*todel
)
618 struct process_info
*proc
= current_process ();
619 return delete_breakpoint_1 (proc
, todel
);
622 static struct breakpoint
*
623 find_gdb_breakpoint_at (CORE_ADDR where
)
625 struct process_info
*proc
= current_process ();
626 struct breakpoint
*bp
;
628 for (bp
= proc
->breakpoints
; bp
!= NULL
; bp
= bp
->next
)
629 if (bp
->type
== gdb_breakpoint
&& bp
->raw
->pc
== where
)
636 set_gdb_breakpoint_at (CORE_ADDR where
)
638 struct breakpoint
*bp
;
640 if (breakpoint_data
== NULL
)
643 /* If we see GDB inserting a second breakpoint at the same address,
644 then the first breakpoint must have disappeared due to a shared
645 library unload. On targets where the shared libraries are
646 handled by userspace, like SVR4, for example, GDBserver can't
647 tell if a library was loaded or unloaded. Since we refcount
648 breakpoints, if we didn't do this, we'd just increase the
649 refcount of the previous breakpoint at this address, but the trap
650 was not planted in the inferior anymore, thus the breakpoint
651 would never be hit. */
652 bp
= find_gdb_breakpoint_at (where
);
655 delete_gdb_breakpoint_at (where
);
657 /* Might as well validate all other breakpoints. */
658 validate_breakpoints ();
661 bp
= set_breakpoint_at (where
, NULL
);
665 bp
->type
= gdb_breakpoint
;
670 delete_gdb_breakpoint_at (CORE_ADDR addr
)
672 struct breakpoint
*bp
;
675 if (breakpoint_data
== NULL
)
678 bp
= find_gdb_breakpoint_at (addr
);
682 err
= delete_breakpoint (bp
);
690 gdb_breakpoint_here (CORE_ADDR where
)
692 struct breakpoint
*bp
= find_gdb_breakpoint_at (where
);
698 set_reinsert_breakpoint (CORE_ADDR stop_at
)
700 struct breakpoint
*bp
;
702 bp
= set_breakpoint_at (stop_at
, NULL
);
703 bp
->type
= reinsert_breakpoint
;
707 delete_reinsert_breakpoints (void)
709 struct process_info
*proc
= current_process ();
710 struct breakpoint
*bp
, **bp_link
;
712 bp
= proc
->breakpoints
;
713 bp_link
= &proc
->breakpoints
;
717 if (bp
->type
== reinsert_breakpoint
)
720 release_breakpoint (proc
, bp
);
732 uninsert_raw_breakpoint (struct raw_breakpoint
*bp
)
739 /* Since there can be fast tracepoint jumps inserted in the same
740 address range, we use `write_inferior_memory', which takes
741 care of layering breakpoints on top of fast tracepoints, and
742 on top of the buffer we pass it. This works because we've
743 already unlinked the fast tracepoint jump above. Also note
744 that we need to pass the current shadow contents, because
745 write_inferior_memory updates any shadow memory with what we
746 pass here, and we want that to be a nop. */
747 err
= write_inferior_memory (bp
->pc
, bp
->old_data
,
755 "Failed to uninsert raw breakpoint at 0x%s (%s).\n",
756 paddress (bp
->pc
), strerror (err
));
762 uninsert_breakpoints_at (CORE_ADDR pc
)
764 struct raw_breakpoint
*bp
;
766 bp
= find_raw_breakpoint_at (pc
);
769 /* This can happen when we remove all breakpoints while handling
773 "Could not find breakpoint at 0x%s "
774 "in list (uninserting).\n",
780 uninsert_raw_breakpoint (bp
);
784 uninsert_all_breakpoints (void)
786 struct process_info
*proc
= current_process ();
787 struct raw_breakpoint
*bp
;
789 for (bp
= proc
->raw_breakpoints
; bp
!= NULL
; bp
= bp
->next
)
791 uninsert_raw_breakpoint (bp
);
795 reinsert_raw_breakpoint (struct raw_breakpoint
*bp
)
800 error ("Breakpoint already inserted at reinsert time.");
802 err
= (*the_target
->write_memory
) (bp
->pc
, breakpoint_data
,
806 else if (debug_threads
)
808 "Failed to reinsert breakpoint at 0x%s (%s).\n",
809 paddress (bp
->pc
), strerror (err
));
813 reinsert_breakpoints_at (CORE_ADDR pc
)
815 struct raw_breakpoint
*bp
;
817 bp
= find_raw_breakpoint_at (pc
);
820 /* This can happen when we remove all breakpoints while handling
824 "Could not find raw breakpoint at 0x%s "
825 "in list (reinserting).\n",
830 reinsert_raw_breakpoint (bp
);
834 reinsert_all_breakpoints (void)
836 struct process_info
*proc
= current_process ();
837 struct raw_breakpoint
*bp
;
839 for (bp
= proc
->raw_breakpoints
; bp
!= NULL
; bp
= bp
->next
)
841 reinsert_raw_breakpoint (bp
);
845 check_breakpoints (CORE_ADDR stop_pc
)
847 struct process_info
*proc
= current_process ();
848 struct breakpoint
*bp
, **bp_link
;
850 bp
= proc
->breakpoints
;
851 bp_link
= &proc
->breakpoints
;
855 if (bp
->raw
->pc
== stop_pc
)
857 if (!bp
->raw
->inserted
)
859 warning ("Hit a removed breakpoint?");
863 if (bp
->handler
!= NULL
&& (*bp
->handler
) (stop_pc
))
867 release_breakpoint (proc
, bp
);
880 set_breakpoint_data (const unsigned char *bp_data
, int bp_len
)
882 breakpoint_data
= bp_data
;
883 breakpoint_len
= bp_len
;
887 breakpoint_here (CORE_ADDR addr
)
889 return (find_raw_breakpoint_at (addr
) != NULL
);
893 breakpoint_inserted_here (CORE_ADDR addr
)
895 struct raw_breakpoint
*bp
;
897 bp
= find_raw_breakpoint_at (addr
);
899 return (bp
!= NULL
&& bp
->inserted
);
903 validate_inserted_breakpoint (struct raw_breakpoint
*bp
)
908 gdb_assert (bp
->inserted
);
910 buf
= alloca (breakpoint_len
);
911 err
= (*the_target
->read_memory
) (bp
->pc
, buf
, breakpoint_len
);
912 if (err
|| memcmp (buf
, breakpoint_data
, breakpoint_len
) != 0)
914 /* Tag it as gone. */
916 bp
->shlib_disabled
= 1;
924 delete_disabled_breakpoints (void)
926 struct process_info
*proc
= current_process ();
927 struct breakpoint
*bp
, *next
;
929 for (bp
= proc
->breakpoints
; bp
!= NULL
; bp
= next
)
932 if (bp
->raw
->shlib_disabled
)
933 delete_breakpoint_1 (proc
, bp
);
937 /* Check if breakpoints we inserted still appear to be inserted. They
938 may disappear due to a shared library unload, and worse, a new
939 shared library may be reloaded at the same address as the
940 previously unloaded one. If that happens, we should make sure that
941 the shadow memory of the old breakpoints isn't used when reading or
945 validate_breakpoints (void)
947 struct process_info
*proc
= current_process ();
948 struct breakpoint
*bp
;
950 for (bp
= proc
->breakpoints
; bp
!= NULL
; bp
= bp
->next
)
952 if (bp
->raw
->inserted
)
953 validate_inserted_breakpoint (bp
->raw
);
956 delete_disabled_breakpoints ();
960 check_mem_read (CORE_ADDR mem_addr
, unsigned char *buf
, int mem_len
)
962 struct process_info
*proc
= current_process ();
963 struct raw_breakpoint
*bp
= proc
->raw_breakpoints
;
964 struct fast_tracepoint_jump
*jp
= proc
->fast_tracepoint_jumps
;
965 CORE_ADDR mem_end
= mem_addr
+ mem_len
;
966 int disabled_one
= 0;
968 for (; jp
!= NULL
; jp
= jp
->next
)
970 CORE_ADDR bp_end
= jp
->pc
+ jp
->length
;
971 CORE_ADDR start
, end
;
972 int copy_offset
, copy_len
, buf_offset
;
974 if (mem_addr
>= bp_end
)
976 if (jp
->pc
>= mem_end
)
980 if (mem_addr
> start
)
987 copy_len
= end
- start
;
988 copy_offset
= start
- jp
->pc
;
989 buf_offset
= start
- mem_addr
;
992 memcpy (buf
+ buf_offset
,
993 fast_tracepoint_jump_shadow (jp
) + copy_offset
,
997 for (; bp
!= NULL
; bp
= bp
->next
)
999 CORE_ADDR bp_end
= bp
->pc
+ breakpoint_len
;
1000 CORE_ADDR start
, end
;
1001 int copy_offset
, copy_len
, buf_offset
;
1003 if (mem_addr
>= bp_end
)
1005 if (bp
->pc
>= mem_end
)
1009 if (mem_addr
> start
)
1016 copy_len
= end
- start
;
1017 copy_offset
= start
- bp
->pc
;
1018 buf_offset
= start
- mem_addr
;
1022 if (validate_inserted_breakpoint (bp
))
1023 memcpy (buf
+ buf_offset
, bp
->old_data
+ copy_offset
, copy_len
);
1030 delete_disabled_breakpoints ();
1034 check_mem_write (CORE_ADDR mem_addr
, unsigned char *buf
, int mem_len
)
1036 struct process_info
*proc
= current_process ();
1037 struct raw_breakpoint
*bp
= proc
->raw_breakpoints
;
1038 struct fast_tracepoint_jump
*jp
= proc
->fast_tracepoint_jumps
;
1039 CORE_ADDR mem_end
= mem_addr
+ mem_len
;
1040 int disabled_one
= 0;
1042 /* First fast tracepoint jumps, then breakpoint traps on top. */
1044 for (; jp
!= NULL
; jp
= jp
->next
)
1046 CORE_ADDR jp_end
= jp
->pc
+ jp
->length
;
1047 CORE_ADDR start
, end
;
1048 int copy_offset
, copy_len
, buf_offset
;
1050 if (mem_addr
>= jp_end
)
1052 if (jp
->pc
>= mem_end
)
1056 if (mem_addr
> start
)
1063 copy_len
= end
- start
;
1064 copy_offset
= start
- jp
->pc
;
1065 buf_offset
= start
- mem_addr
;
1067 memcpy (fast_tracepoint_jump_shadow (jp
) + copy_offset
,
1068 buf
+ buf_offset
, copy_len
);
1070 memcpy (buf
+ buf_offset
,
1071 fast_tracepoint_jump_insn (jp
) + copy_offset
, copy_len
);
1074 for (; bp
!= NULL
; bp
= bp
->next
)
1076 CORE_ADDR bp_end
= bp
->pc
+ breakpoint_len
;
1077 CORE_ADDR start
, end
;
1078 int copy_offset
, copy_len
, buf_offset
;
1080 if (mem_addr
>= bp_end
)
1082 if (bp
->pc
>= mem_end
)
1086 if (mem_addr
> start
)
1093 copy_len
= end
- start
;
1094 copy_offset
= start
- bp
->pc
;
1095 buf_offset
= start
- mem_addr
;
1097 memcpy (bp
->old_data
+ copy_offset
, buf
+ buf_offset
, copy_len
);
1100 if (validate_inserted_breakpoint (bp
))
1101 memcpy (buf
+ buf_offset
, breakpoint_data
+ copy_offset
, copy_len
);
1108 delete_disabled_breakpoints ();
1111 /* Delete all breakpoints, and un-insert them from the inferior. */
1114 delete_all_breakpoints (void)
1116 struct process_info
*proc
= current_process ();
1118 while (proc
->breakpoints
)
1119 delete_breakpoint_1 (proc
, proc
->breakpoints
);
1122 /* Clear the "inserted" flag in all breakpoints. */
1125 mark_breakpoints_out (struct process_info
*proc
)
1127 struct raw_breakpoint
*raw_bp
;
1129 for (raw_bp
= proc
->raw_breakpoints
; raw_bp
!= NULL
; raw_bp
= raw_bp
->next
)
1130 raw_bp
->inserted
= 0;
1133 /* Release all breakpoints, but do not try to un-insert them from the
1137 free_all_breakpoints (struct process_info
*proc
)
1139 mark_breakpoints_out (proc
);
1141 /* Note: use PROC explicitly instead of deferring to
1142 delete_all_breakpoints --- CURRENT_INFERIOR may already have been
1143 released when we get here. There should be no call to
1144 current_process from here on. */
1145 while (proc
->breakpoints
)
1146 delete_breakpoint_1 (proc
, proc
->breakpoints
);