Browse files

Fix insertion of breakpoints on Thumb code.

When a program has been built in Thumb mode, global symbols will
have their low bit set.  Ensure that breakpoints are set at the
correct address and using Thumb instructions.

Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
  • Loading branch information...
1 parent 799b01f commit a2ff9d6db878e564caffef8807907aa0faedb7fd @zwelch-mgc zwelch-mgc committed with Oct 8, 2010
Showing with 11 additions and 1 deletion.
  1. +4 −0 ChangeLog
  2. +7 −1 breakpoints.c
View
4 ChangeLog
@@ -9,6 +9,10 @@
* sysdeps/linux-gnu/cris/syscallent.h: Ditto.
* sysdeps/linux-gnu/cris/trace.c: Ditto.
+2010-10-07 Zach Welch <zwelch@codesourcery.com>
+
+ * Improve breakpoint insertion to work with Thumb procedures.
+
2010-09-30 Zach Welch <zwelch@codesourcery.com>
* Improve ARM syscall_p to handle Thumb-2 syscalls.
View
8 breakpoints.c
@@ -23,6 +23,12 @@ insert_breakpoint(Process *proc, void *addr,
struct library_symbol *libsym) {
Breakpoint *sbp;
+#ifdef __arm__
+ int thumb_mode = (int)addr & 1;
+ if (thumb_mode)
+ addr = (void *)((int)addr & ~1);
+#endif
+
debug(DEBUG_FUNCTION, "insert_breakpoint(pid=%d, addr=%p, symbol=%s)", proc->pid, addr, libsym ? libsym->name : "NULL");
debug(1, "symbol=%s, addr=%p", libsym?libsym->name:"(nil)", addr);
@@ -43,7 +49,7 @@ insert_breakpoint(Process *proc, void *addr,
sbp->libsym = libsym;
}
#ifdef __arm__
- sbp->thumb_mode = proc->thumb_mode;
+ sbp->thumb_mode = thumb_mode | proc->thumb_mode;
proc->thumb_mode = 0;
#endif
sbp->enabled++;

0 comments on commit a2ff9d6

Please sign in to comment.