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 <[email protected]>
---
 ChangeLog     |    4 ++++
 breakpoints.c |    7 ++++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0501982..d93acc2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-10-07  Zach Welch <[email protected]>
+
+       * Improve breakpoint insertion to work with Thumb procedures.
+
 2010-09-30  Zach Welch <[email protected]>
 
        * Improve ARM syscall_p to handle Thumb-2 syscalls.
diff --git a/breakpoints.c b/breakpoints.c
index ba3b060..ad68f0d 100644
--- a/breakpoints.c
+++ b/breakpoints.c
@@ -22,6 +22,11 @@ void
 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 +48,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++;
-- 
1.7.2.2


_______________________________________________
Ltrace-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/ltrace-devel

Reply via email to