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/>. */
24 const unsigned char *breakpoint_data
;
27 #define MAX_BREAKPOINT_LEN 8
29 /* GDB will never try to install multiple breakpoints at the same
30 address. But, we need to keep track of internal breakpoints too,
31 and so we do need to be able to install multiple breakpoints at the
32 same address transparently. We keep track of two different, and
33 closely related structures. A raw breakpoint, which manages the
34 low level, close to the metal aspect of a breakpoint. It holds the
35 breakpoint address, and a buffer holding a copy of the instructions
36 that would be in memory had not been a breakpoint there (we call
37 that the shadow memory of the breakpoint). We occasionally need to
38 temporarilly uninsert a breakpoint without the client knowing about
39 it (e.g., to step over an internal breakpoint), so we keep an
40 `inserted' state associated with this low level breakpoint
41 structure. There can only be one such object for a given address.
42 Then, we have (a bit higher level) breakpoints. This structure
43 holds a callback to be called whenever a breakpoint is hit, a
44 high-level type, and a link to a low level raw breakpoint. There
45 can be many high-level breakpoints at the same address, and all of
46 them will point to the same raw breakpoint, which is reference
49 /* The low level, physical, raw breakpoint. */
52 struct raw_breakpoint
*next
;
54 /* A reference count. Each high level breakpoint referencing this
55 raw breakpoint accounts for one reference. */
58 /* The breakpoint's insertion address. There can only be one raw
59 breakpoint for a given PC. */
62 /* The breakpoint's shadow memory. */
63 unsigned char old_data
[MAX_BREAKPOINT_LEN
];
65 /* Non-zero if this breakpoint is currently inserted in the
69 /* Non-zero if this breakpoint is currently disabled because we no
70 longer detect it as inserted. */
74 /* The type of a breakpoint. */
77 /* A GDB breakpoint, requested with a Z0 packet. */
80 /* A basic-software-single-step breakpoint. */
83 /* Any other breakpoint type that doesn't require specific
84 treatment goes here. E.g., an event breakpoint. */
88 /* A high level (in gdbserver's perspective) breakpoint. */
91 struct breakpoint
*next
;
93 /* The breakpoint's type. */
96 /* Link to this breakpoint's raw breakpoint. This is always
98 struct raw_breakpoint
*raw
;
100 /* Function to call when we hit this breakpoint. If it returns 1,
101 the breakpoint shall be deleted; 0 or if this callback is NULL,
102 it will be left inserted. */
103 int (*handler
) (CORE_ADDR
);
106 static struct raw_breakpoint
*
107 find_raw_breakpoint_at (CORE_ADDR where
)
109 struct process_info
*proc
= current_process ();
110 struct raw_breakpoint
*bp
;
112 for (bp
= proc
->raw_breakpoints
; bp
!= NULL
; bp
= bp
->next
)
119 static struct raw_breakpoint
*
120 set_raw_breakpoint_at (CORE_ADDR where
)
122 struct process_info
*proc
= current_process ();
123 struct raw_breakpoint
*bp
;
126 if (breakpoint_data
== NULL
)
127 error ("Target does not support breakpoints.");
129 bp
= find_raw_breakpoint_at (where
);
136 bp
= xcalloc (1, sizeof (*bp
));
140 /* Note that there can be fast tracepoint jumps installed in the
141 same memory range, so to get at the original memory, we need to
142 use read_inferior_memory, which masks those out. */
143 err
= read_inferior_memory (where
, bp
->old_data
, breakpoint_len
);
148 "Failed to read shadow memory of"
149 " breakpoint at 0x%s (%s).\n",
150 paddress (where
), strerror (err
));
155 err
= (*the_target
->write_memory
) (where
, breakpoint_data
,
161 "Failed to insert breakpoint at 0x%s (%s).\n",
162 paddress (where
), strerror (err
));
167 /* Link the breakpoint in. */
169 bp
->next
= proc
->raw_breakpoints
;
170 proc
->raw_breakpoints
= bp
;
174 /* Notice that breakpoint traps are always installed on top of fast
175 tracepoint jumps. This is even if the fast tracepoint is installed
176 at a later time compared to when the breakpoint was installed.
177 This means that a stopping breakpoint or tracepoint has higher
178 "priority". In turn, this allows having fast and slow tracepoints
179 (and breakpoints) at the same address behave correctly. */
182 /* A fast tracepoint jump. */
184 struct fast_tracepoint_jump
186 struct fast_tracepoint_jump
*next
;
188 /* A reference count. GDB can install more than one fast tracepoint
189 at the same address (each with its own action list, for
193 /* The fast tracepoint's insertion address. There can only be one
194 of these for a given PC. */
197 /* Non-zero if this fast tracepoint jump is currently inserted in
201 /* The length of the jump instruction. */
204 /* A poor-man's flexible array member, holding both the jump
205 instruction to insert, and a copy of the instruction that would
206 be in memory had not been a jump there (the shadow memory of the
208 unsigned char insn_and_shadow
[0];
211 /* Fast tracepoint FP's jump instruction to insert. */
212 #define fast_tracepoint_jump_insn(fp) \
213 ((fp)->insn_and_shadow + 0)
215 /* The shadow memory of fast tracepoint jump FP. */
216 #define fast_tracepoint_jump_shadow(fp) \
217 ((fp)->insn_and_shadow + (fp)->length)
220 /* Return the fast tracepoint jump set at WHERE. */
222 static struct fast_tracepoint_jump
*
223 find_fast_tracepoint_jump_at (CORE_ADDR where
)
225 struct process_info
*proc
= current_process ();
226 struct fast_tracepoint_jump
*jp
;
228 for (jp
= proc
->fast_tracepoint_jumps
; jp
!= NULL
; jp
= jp
->next
)
236 fast_tracepoint_jump_here (CORE_ADDR where
)
238 struct fast_tracepoint_jump
*jp
= find_fast_tracepoint_jump_at (where
);
244 delete_fast_tracepoint_jump (struct fast_tracepoint_jump
*todel
)
246 struct fast_tracepoint_jump
*bp
, **bp_link
;
248 struct process_info
*proc
= current_process ();
250 bp
= proc
->fast_tracepoint_jumps
;
251 bp_link
= &proc
->fast_tracepoint_jumps
;
257 if (--bp
->refcount
== 0)
259 struct fast_tracepoint_jump
*prev_bp_link
= *bp_link
;
264 /* Since there can be breakpoints inserted in the same
265 address range, we use `write_inferior_memory', which
266 takes care of layering breakpoints on top of fast
267 tracepoints, and on top of the buffer we pass it.
268 This works because we've already unlinked the fast
269 tracepoint jump above. Also note that we need to
270 pass the current shadow contents, because
271 write_inferior_memory updates any shadow memory with
272 what we pass here, and we want that to be a nop. */
273 ret
= write_inferior_memory (bp
->pc
,
274 fast_tracepoint_jump_shadow (bp
),
278 /* Something went wrong, relink the jump. */
279 *bp_link
= prev_bp_link
;
283 "Failed to uninsert fast tracepoint jump "
284 "at 0x%s (%s) while deleting it.\n",
285 paddress (bp
->pc
), strerror (ret
));
301 warning ("Could not find fast tracepoint jump in list.");
305 struct fast_tracepoint_jump
*
306 set_fast_tracepoint_jump (CORE_ADDR where
,
307 unsigned char *insn
, ULONGEST length
)
309 struct process_info
*proc
= current_process ();
310 struct fast_tracepoint_jump
*jp
;
313 /* We refcount fast tracepoint jumps. Check if we already know
314 about a jump at this address. */
315 jp
= find_fast_tracepoint_jump_at (where
);
322 /* We don't, so create a new object. Double the length, because the
323 flexible array member holds both the jump insn, and the
325 jp
= xcalloc (1, sizeof (*jp
) + (length
* 2));
328 memcpy (fast_tracepoint_jump_insn (jp
), insn
, length
);
331 /* Note that there can be trap breakpoints inserted in the same
332 address range. To access the original memory contents, we use
333 `read_inferior_memory', which masks out breakpoints. */
334 err
= read_inferior_memory (where
,
335 fast_tracepoint_jump_shadow (jp
), jp
->length
);
340 "Failed to read shadow memory of"
341 " fast tracepoint at 0x%s (%s).\n",
342 paddress (where
), strerror (err
));
347 /* Link the jump in. */
349 jp
->next
= proc
->fast_tracepoint_jumps
;
350 proc
->fast_tracepoint_jumps
= jp
;
352 /* Since there can be trap breakpoints inserted in the same address
353 range, we use use `write_inferior_memory', which takes care of
354 layering breakpoints on top of fast tracepoints, on top of the
355 buffer we pass it. This works because we've already linked in
356 the fast tracepoint jump above. Also note that we need to pass
357 the current shadow contents, because write_inferior_memory
358 updates any shadow memory with what we pass here, and we want
360 err
= write_inferior_memory (where
, fast_tracepoint_jump_shadow (jp
), length
);
365 "Failed to insert fast tracepoint jump at 0x%s (%s).\n",
366 paddress (where
), strerror (err
));
369 proc
->fast_tracepoint_jumps
= jp
->next
;
379 uninsert_fast_tracepoint_jumps_at (CORE_ADDR pc
)
381 struct fast_tracepoint_jump
*jp
;
384 jp
= find_fast_tracepoint_jump_at (pc
);
387 /* This can happen when we remove all breakpoints while handling
391 "Could not find fast tracepoint jump at 0x%s "
392 "in list (uninserting).\n",
401 /* Since there can be trap breakpoints inserted in the same
402 address range, we use use `write_inferior_memory', which
403 takes care of layering breakpoints on top of fast
404 tracepoints, and on top of the buffer we pass it. This works
405 because we've already marked the fast tracepoint fast
406 tracepoint jump uninserted above. Also note that we need to
407 pass the current shadow contents, because
408 write_inferior_memory updates any shadow memory with what we
409 pass here, and we want that to be a nop. */
410 err
= write_inferior_memory (jp
->pc
,
411 fast_tracepoint_jump_shadow (jp
),
419 "Failed to uninsert fast tracepoint jump at 0x%s (%s).\n",
420 paddress (pc
), strerror (err
));
426 reinsert_fast_tracepoint_jumps_at (CORE_ADDR where
)
428 struct fast_tracepoint_jump
*jp
;
431 jp
= find_fast_tracepoint_jump_at (where
);
434 /* This can happen when we remove breakpoints when a tracepoint
435 hit causes a tracing stop, while handling a step-over. */
438 "Could not find fast tracepoint jump at 0x%s "
439 "in list (reinserting).\n",
445 error ("Jump already inserted at reinsert time.");
449 /* Since there can be trap breakpoints inserted in the same address
450 range, we use `write_inferior_memory', which takes care of
451 layering breakpoints on top of fast tracepoints, and on top of
452 the buffer we pass it. This works because we've already marked
453 the fast tracepoint jump inserted above. Also note that we need
454 to pass the current shadow contents, because
455 write_inferior_memory updates any shadow memory with what we pass
456 here, and we want that to be a nop. */
457 err
= write_inferior_memory (where
,
458 fast_tracepoint_jump_shadow (jp
), jp
->length
);
465 "Failed to reinsert fast tracepoint jump at 0x%s (%s).\n",
466 paddress (where
), strerror (err
));
471 set_breakpoint_at (CORE_ADDR where
, int (*handler
) (CORE_ADDR
))
473 struct process_info
*proc
= current_process ();
474 struct breakpoint
*bp
;
475 struct raw_breakpoint
*raw
;
477 raw
= set_raw_breakpoint_at (where
);
485 bp
= xcalloc (1, sizeof (struct breakpoint
));
486 bp
->type
= other_breakpoint
;
489 bp
->handler
= handler
;
491 bp
->next
= proc
->breakpoints
;
492 proc
->breakpoints
= bp
;
498 delete_raw_breakpoint (struct process_info
*proc
, struct raw_breakpoint
*todel
)
500 struct raw_breakpoint
*bp
, **bp_link
;
503 bp
= proc
->raw_breakpoints
;
504 bp_link
= &proc
->raw_breakpoints
;
512 struct raw_breakpoint
*prev_bp_link
= *bp_link
;
516 /* Since there can be trap breakpoints inserted in the
517 same address range, we use `write_inferior_memory',
518 which takes care of layering breakpoints on top of
519 fast tracepoints, and on top of the buffer we pass
520 it. This works because we've already unlinked the
521 fast tracepoint jump above. Also note that we need
522 to pass the current shadow contents, because
523 write_inferior_memory updates any shadow memory with
524 what we pass here, and we want that to be a nop. */
525 ret
= write_inferior_memory (bp
->pc
, bp
->old_data
,
529 /* Something went wrong, relink the breakpoint. */
530 *bp_link
= prev_bp_link
;
534 "Failed to uninsert raw breakpoint "
535 "at 0x%s (%s) while deleting it.\n",
536 paddress (bp
->pc
), strerror (ret
));
554 warning ("Could not find raw breakpoint in list.");
559 release_breakpoint (struct process_info
*proc
, struct breakpoint
*bp
)
564 newrefcount
= bp
->raw
->refcount
- 1;
565 if (newrefcount
== 0)
567 ret
= delete_raw_breakpoint (proc
, bp
->raw
);
572 bp
->raw
->refcount
= newrefcount
;
580 delete_breakpoint_1 (struct process_info
*proc
, struct breakpoint
*todel
)
582 struct breakpoint
*bp
, **bp_link
;
585 bp
= proc
->breakpoints
;
586 bp_link
= &proc
->breakpoints
;
594 err
= release_breakpoint (proc
, bp
);
608 warning ("Could not find breakpoint in list.");
613 delete_breakpoint (struct breakpoint
*todel
)
615 struct process_info
*proc
= current_process ();
616 return delete_breakpoint_1 (proc
, todel
);
619 static struct breakpoint
*
620 find_gdb_breakpoint_at (CORE_ADDR where
)
622 struct process_info
*proc
= current_process ();
623 struct breakpoint
*bp
;
625 for (bp
= proc
->breakpoints
; bp
!= NULL
; bp
= bp
->next
)
626 if (bp
->type
== gdb_breakpoint
&& bp
->raw
->pc
== where
)
633 set_gdb_breakpoint_at (CORE_ADDR where
)
635 struct breakpoint
*bp
;
637 if (breakpoint_data
== NULL
)
640 /* If we see GDB inserting a second breakpoint at the same address,
641 then the first breakpoint must have disappeared due to a shared
642 library unload. On targets where the shared libraries are
643 handled by userspace, like SVR4, for example, GDBserver can't
644 tell if a library was loaded or unloaded. Since we refcount
645 breakpoints, if we didn't do this, we'd just increase the
646 refcount of the previous breakpoint at this address, but the trap
647 was not planted in the inferior anymore, thus the breakpoint
648 would never be hit. */
649 bp
= find_gdb_breakpoint_at (where
);
652 delete_gdb_breakpoint_at (where
);
654 /* Might as well validate all other breakpoints. */
655 validate_breakpoints ();
658 bp
= set_breakpoint_at (where
, NULL
);
662 bp
->type
= gdb_breakpoint
;
667 delete_gdb_breakpoint_at (CORE_ADDR addr
)
669 struct breakpoint
*bp
;
672 if (breakpoint_data
== NULL
)
675 bp
= find_gdb_breakpoint_at (addr
);
679 err
= delete_breakpoint (bp
);
687 gdb_breakpoint_here (CORE_ADDR where
)
689 struct breakpoint
*bp
= find_gdb_breakpoint_at (where
);
695 set_reinsert_breakpoint (CORE_ADDR stop_at
)
697 struct breakpoint
*bp
;
699 bp
= set_breakpoint_at (stop_at
, NULL
);
700 bp
->type
= reinsert_breakpoint
;
704 delete_reinsert_breakpoints (void)
706 struct process_info
*proc
= current_process ();
707 struct breakpoint
*bp
, **bp_link
;
709 bp
= proc
->breakpoints
;
710 bp_link
= &proc
->breakpoints
;
714 if (bp
->type
== reinsert_breakpoint
)
717 release_breakpoint (proc
, bp
);
729 uninsert_raw_breakpoint (struct raw_breakpoint
*bp
)
736 /* Since there can be fast tracepoint jumps inserted in the same
737 address range, we use `write_inferior_memory', which takes
738 care of layering breakpoints on top of fast tracepoints, and
739 on top of the buffer we pass it. This works because we've
740 already unlinked the fast tracepoint jump above. Also note
741 that we need to pass the current shadow contents, because
742 write_inferior_memory updates any shadow memory with what we
743 pass here, and we want that to be a nop. */
744 err
= write_inferior_memory (bp
->pc
, bp
->old_data
,
752 "Failed to uninsert raw breakpoint at 0x%s (%s).\n",
753 paddress (bp
->pc
), strerror (err
));
759 uninsert_breakpoints_at (CORE_ADDR pc
)
761 struct raw_breakpoint
*bp
;
763 bp
= find_raw_breakpoint_at (pc
);
766 /* This can happen when we remove all breakpoints while handling
770 "Could not find breakpoint at 0x%s "
771 "in list (uninserting).\n",
777 uninsert_raw_breakpoint (bp
);
781 uninsert_all_breakpoints (void)
783 struct process_info
*proc
= current_process ();
784 struct raw_breakpoint
*bp
;
786 for (bp
= proc
->raw_breakpoints
; bp
!= NULL
; bp
= bp
->next
)
788 uninsert_raw_breakpoint (bp
);
792 reinsert_raw_breakpoint (struct raw_breakpoint
*bp
)
797 error ("Breakpoint already inserted at reinsert time.");
799 err
= (*the_target
->write_memory
) (bp
->pc
, breakpoint_data
,
803 else if (debug_threads
)
805 "Failed to reinsert breakpoint at 0x%s (%s).\n",
806 paddress (bp
->pc
), strerror (err
));
810 reinsert_breakpoints_at (CORE_ADDR pc
)
812 struct raw_breakpoint
*bp
;
814 bp
= find_raw_breakpoint_at (pc
);
817 /* This can happen when we remove all breakpoints while handling
821 "Could not find raw breakpoint at 0x%s "
822 "in list (reinserting).\n",
827 reinsert_raw_breakpoint (bp
);
831 reinsert_all_breakpoints (void)
833 struct process_info
*proc
= current_process ();
834 struct raw_breakpoint
*bp
;
836 for (bp
= proc
->raw_breakpoints
; bp
!= NULL
; bp
= bp
->next
)
838 reinsert_raw_breakpoint (bp
);
842 check_breakpoints (CORE_ADDR stop_pc
)
844 struct process_info
*proc
= current_process ();
845 struct breakpoint
*bp
, **bp_link
;
847 bp
= proc
->breakpoints
;
848 bp_link
= &proc
->breakpoints
;
852 if (bp
->raw
->pc
== stop_pc
)
854 if (!bp
->raw
->inserted
)
856 warning ("Hit a removed breakpoint?");
860 if (bp
->handler
!= NULL
&& (*bp
->handler
) (stop_pc
))
864 release_breakpoint (proc
, bp
);
877 set_breakpoint_data (const unsigned char *bp_data
, int bp_len
)
879 breakpoint_data
= bp_data
;
880 breakpoint_len
= bp_len
;
884 breakpoint_here (CORE_ADDR addr
)
886 return (find_raw_breakpoint_at (addr
) != NULL
);
890 breakpoint_inserted_here (CORE_ADDR addr
)
892 struct raw_breakpoint
*bp
;
894 bp
= find_raw_breakpoint_at (addr
);
896 return (bp
!= NULL
&& bp
->inserted
);
900 validate_inserted_breakpoint (struct raw_breakpoint
*bp
)
905 gdb_assert (bp
->inserted
);
907 buf
= alloca (breakpoint_len
);
908 err
= (*the_target
->read_memory
) (bp
->pc
, buf
, breakpoint_len
);
909 if (err
|| memcmp (buf
, breakpoint_data
, breakpoint_len
) != 0)
911 /* Tag it as gone. */
913 bp
->shlib_disabled
= 1;
921 delete_disabled_breakpoints (void)
923 struct process_info
*proc
= current_process ();
924 struct breakpoint
*bp
, *next
;
926 for (bp
= proc
->breakpoints
; bp
!= NULL
; bp
= next
)
929 if (bp
->raw
->shlib_disabled
)
930 delete_breakpoint_1 (proc
, bp
);
934 /* Check if breakpoints we inserted still appear to be inserted. They
935 may disappear due to a shared library unload, and worse, a new
936 shared library may be reloaded at the same address as the
937 previously unloaded one. If that happens, we should make sure that
938 the shadow memory of the old breakpoints isn't used when reading or
942 validate_breakpoints (void)
944 struct process_info
*proc
= current_process ();
945 struct breakpoint
*bp
;
947 for (bp
= proc
->breakpoints
; bp
!= NULL
; bp
= bp
->next
)
949 if (bp
->raw
->inserted
)
950 validate_inserted_breakpoint (bp
->raw
);
953 delete_disabled_breakpoints ();
957 check_mem_read (CORE_ADDR mem_addr
, unsigned char *buf
, int mem_len
)
959 struct process_info
*proc
= current_process ();
960 struct raw_breakpoint
*bp
= proc
->raw_breakpoints
;
961 struct fast_tracepoint_jump
*jp
= proc
->fast_tracepoint_jumps
;
962 CORE_ADDR mem_end
= mem_addr
+ mem_len
;
963 int disabled_one
= 0;
965 for (; jp
!= NULL
; jp
= jp
->next
)
967 CORE_ADDR bp_end
= jp
->pc
+ jp
->length
;
968 CORE_ADDR start
, end
;
969 int copy_offset
, copy_len
, buf_offset
;
971 if (mem_addr
>= bp_end
)
973 if (jp
->pc
>= mem_end
)
977 if (mem_addr
> start
)
984 copy_len
= end
- start
;
985 copy_offset
= start
- jp
->pc
;
986 buf_offset
= start
- mem_addr
;
989 memcpy (buf
+ buf_offset
,
990 fast_tracepoint_jump_shadow (jp
) + copy_offset
,
994 for (; bp
!= NULL
; bp
= bp
->next
)
996 CORE_ADDR bp_end
= bp
->pc
+ breakpoint_len
;
997 CORE_ADDR start
, end
;
998 int copy_offset
, copy_len
, buf_offset
;
1000 if (mem_addr
>= bp_end
)
1002 if (bp
->pc
>= mem_end
)
1006 if (mem_addr
> start
)
1013 copy_len
= end
- start
;
1014 copy_offset
= start
- bp
->pc
;
1015 buf_offset
= start
- mem_addr
;
1019 if (validate_inserted_breakpoint (bp
))
1020 memcpy (buf
+ buf_offset
, bp
->old_data
+ copy_offset
, copy_len
);
1027 delete_disabled_breakpoints ();
1031 check_mem_write (CORE_ADDR mem_addr
, unsigned char *buf
, int mem_len
)
1033 struct process_info
*proc
= current_process ();
1034 struct raw_breakpoint
*bp
= proc
->raw_breakpoints
;
1035 struct fast_tracepoint_jump
*jp
= proc
->fast_tracepoint_jumps
;
1036 CORE_ADDR mem_end
= mem_addr
+ mem_len
;
1037 int disabled_one
= 0;
1039 /* First fast tracepoint jumps, then breakpoint traps on top. */
1041 for (; jp
!= NULL
; jp
= jp
->next
)
1043 CORE_ADDR jp_end
= jp
->pc
+ jp
->length
;
1044 CORE_ADDR start
, end
;
1045 int copy_offset
, copy_len
, buf_offset
;
1047 if (mem_addr
>= jp_end
)
1049 if (jp
->pc
>= mem_end
)
1053 if (mem_addr
> start
)
1060 copy_len
= end
- start
;
1061 copy_offset
= start
- jp
->pc
;
1062 buf_offset
= start
- mem_addr
;
1064 memcpy (fast_tracepoint_jump_shadow (jp
) + copy_offset
,
1065 buf
+ buf_offset
, copy_len
);
1067 memcpy (buf
+ buf_offset
,
1068 fast_tracepoint_jump_insn (jp
) + copy_offset
, copy_len
);
1071 for (; bp
!= NULL
; bp
= bp
->next
)
1073 CORE_ADDR bp_end
= bp
->pc
+ breakpoint_len
;
1074 CORE_ADDR start
, end
;
1075 int copy_offset
, copy_len
, buf_offset
;
1077 if (mem_addr
>= bp_end
)
1079 if (bp
->pc
>= mem_end
)
1083 if (mem_addr
> start
)
1090 copy_len
= end
- start
;
1091 copy_offset
= start
- bp
->pc
;
1092 buf_offset
= start
- mem_addr
;
1094 memcpy (bp
->old_data
+ copy_offset
, buf
+ buf_offset
, copy_len
);
1097 if (validate_inserted_breakpoint (bp
))
1098 memcpy (buf
+ buf_offset
, breakpoint_data
+ copy_offset
, copy_len
);
1105 delete_disabled_breakpoints ();
1108 /* Delete all breakpoints, and un-insert them from the inferior. */
1111 delete_all_breakpoints (void)
1113 struct process_info
*proc
= current_process ();
1115 while (proc
->breakpoints
)
1116 delete_breakpoint_1 (proc
, proc
->breakpoints
);
1119 /* Clear the "inserted" flag in all breakpoints. */
1122 mark_breakpoints_out (struct process_info
*proc
)
1124 struct raw_breakpoint
*raw_bp
;
1126 for (raw_bp
= proc
->raw_breakpoints
; raw_bp
!= NULL
; raw_bp
= raw_bp
->next
)
1127 raw_bp
->inserted
= 0;
1130 /* Release all breakpoints, but do not try to un-insert them from the
1134 free_all_breakpoints (struct process_info
*proc
)
1136 mark_breakpoints_out (proc
);
1138 /* Note: use PROC explicitly instead of deferring to
1139 delete_all_breakpoints --- CURRENT_INFERIOR may already have been
1140 released when we get here. There should be no call to
1141 current_process from here on. */
1142 while (proc
->breakpoints
)
1143 delete_breakpoint_1 (proc
, proc
->breakpoints
);