This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc] [4/4] SPU overlay support: Bugfix in remove_breakpoint
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 8 May 2007 00:27:05 +0200 (CEST)
- Subject: [rfc] [4/4] SPU overlay support: Bugfix in remove_breakpoint
Hello,
this fixes a bug we discovered during SPU overlay testing.
The problem occurs when remove_breakpoint attempts to remove a
software breakpoint in an overlay section that is not currently
mapped. The routine simply goes and writes the saved shadow
contents over that location -- but if another overlay section
is now mapped there, this will clobber its code.
The current behaviour was introduced by Michael Snyder's patch:
http://sourceware.org/ml/gdb-patches/2002-04/msg00149.html
to support hardware breakpoints in overlays.
And I guess if this is a hardware breakpoint, it *should* be
removed -- otherwise the overlay manager would have to fiddle
with hardware breakpoint registers when swapping overlays.
However, for *software* breakpoints this looks definitely
wrong to me. So the patch below restores the old behaviour
for those: the shadow contents are restored only if the
section is still mapped.
Any comments? I plan on committing this after the rest of
the SPU overlay support patches.
Bye,
Ulrich
ChangeLog:
* breakpoint.c (remove_breakpoint): Do not remove software
breakpoints in unmapped overlay sections.
diff -urNp gdb-orig/gdb/breakpoint.c gdb-head/gdb/breakpoint.c
--- gdb-orig/gdb/breakpoint.c 2007-05-06 16:07:05.000000000 +0200
+++ gdb-head/gdb/breakpoint.c 2007-05-07 22:44:15.698329784 +0200
@@ -1585,8 +1585,14 @@ remove_breakpoint (struct bp_location *b
don't know what the overlay manager might do. */
if (b->loc_type == bp_loc_hardware_breakpoint)
val = target_remove_hw_breakpoint (&b->target_info);
- else
+
+ /* However, we should remove *software* breakpoints only
+ if the section is still mapped, or else we overwrite
+ wrong code with the saved shadow contents. */
+ else if (section_is_mapped (b->section))
val = target_remove_breakpoint (&b->target_info);
+ else
+ val = 0;
}
else
{
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com