libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libunwind-devel] [PATCH 17/17] ptrace: add more Debug to access_reg


From: Cody P Schafer
Subject: [Libunwind-devel] [PATCH 17/17] ptrace: add more Debug to access_reg
Date: Fri, 14 Sep 2012 17:12:02 -0700

This was useful in debugging issues with the libunwind-ptrace code on
ppc64.
---
 src/ptrace/_UPT_access_reg.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/ptrace/_UPT_access_reg.c b/src/ptrace/_UPT_access_reg.c
index 99949b2..910f0f7 100644
--- a/src/ptrace/_UPT_access_reg.c
+++ b/src/ptrace/_UPT_access_reg.c
@@ -43,6 +43,10 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, 
unw_word_t *val,
   pid_t pid = ui->pid;
 
 #if UNW_DEBUG
+  Debug(16, "using pokeuser: reg: %s [%u], val: %lx, write: %d\n", 
unw_regname(reg), (unsigned) reg, (long) val, write);
+#endif
+
+#if UNW_DEBUG
   if (write)
     Debug (16, "%s <- %lx\n", unw_regname (reg), (long) *val);
 #endif
@@ -221,10 +225,13 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, 
unw_word_t *val,
          }
        break;
       }
-#endif
+#endif /* End of IA64 */
 
   if ((unsigned) reg >= sizeof (_UPT_reg_offset) / sizeof (_UPT_reg_offset[0]))
     {
+#if UNW_DEBUG
+      Debug(2, "register out of range: >= %zu / %zu\n", 
sizeof(_UPT_reg_offset), sizeof(_UPT_reg_offset[0]));
+#endif
       errno = EINVAL;
       goto badreg;
     }
@@ -235,10 +242,19 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, 
unw_word_t *val,
   errno = 0;
   if (write)
     ptrace (PTRACE_POKEUSER, pid, _UPT_reg_offset[reg], *val);
-  else
+  else {
+#if UNW_DEBUG
+    Debug(16, "ptrace PEEKUSER pid: %lu , reg: %lu , offs: %lu\n", (unsigned 
long)pid, (unsigned long)reg,
+        (unsigned long)_UPT_reg_offset[reg]);
+#endif
     *val = ptrace (PTRACE_PEEKUSER, pid, _UPT_reg_offset[reg], 0);
-  if (errno)
+  }
+  if (errno) {
+#if UNW_DEBUG
+    Debug(2, "ptrace failure\n");
+#endif
     goto badreg;
+  }
 #endif
 
 #ifdef UNW_TARGET_IA64
@@ -246,7 +262,7 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, 
unw_word_t *val,
 #endif
 #if UNW_DEBUG
   if (!write)
-    Debug (16, "%s -> %lx\n", unw_regname (reg), (long) *val);
+    Debug (16, "%s[%u] -> %lx\n", unw_regname (reg), (unsigned) reg, (long) 
*val);
 #endif
   return 0;
 
@@ -265,8 +281,12 @@ _UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, 
unw_word_t *val,
   char *r;
 
 #if UNW_DEBUG
+  Debug(16, "using getregs: reg: %s [%u], val: %lx, write: %u\n", 
unw_regname(reg), (unsigned) reg, (long) val, write);
+#endif
+
+#if UNW_DEBUG
   if (write)
-    Debug (16, "%s <- %lx\n", unw_regname (reg), (long) *val);
+    Debug (16, "%s [%u] <- %lx\n", unw_regname (reg), (unsigned) reg, (long) 
*val);
 #endif
   if ((unsigned) reg >= sizeof (_UPT_reg_offset) / sizeof (_UPT_reg_offset[0]))
     {
-- 
1.7.11.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]