Source-Changes-HG archive

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

[src/trunk]: src/gnu/dist/toolchain/gdb Add some support for debugging 32-bit...



details:   https://anonhg.NetBSD.org/src/rev/38dfbdd6144f
branches:  trunk
changeset: 503420:38dfbdd6144f
user:      eeh <eeh%NetBSD.org@localhost>
date:      Mon Feb 05 18:47:10 2001 +0000

description:
Add some support for debugging 32-bit binaries.  But watch out: addresses
are not truncated to 32-bits yet.

diffstat:

 gnu/dist/toolchain/gdb/sp64nbsd-nat.c |  120 +++++++++++++++++++++++++--------
 gnu/dist/toolchain/gdb/sparc-tdep.c   |   10 ++
 2 files changed, 101 insertions(+), 29 deletions(-)

diffs (202 lines):

diff -r 01925c9b7ac3 -r 38dfbdd6144f gnu/dist/toolchain/gdb/sp64nbsd-nat.c
--- a/gnu/dist/toolchain/gdb/sp64nbsd-nat.c     Mon Feb 05 18:43:34 2001 +0000
+++ b/gnu/dist/toolchain/gdb/sp64nbsd-nat.c     Mon Feb 05 18:47:10 2001 +0000
@@ -152,25 +152,51 @@
   if (regno == -1)
     {
       CORE_ADDR sp = *(CORE_ADDR*)&registers[REGISTER_BYTE (SP_REGNUM)];
-      if (sp & 0x1) 
+      if (sp & 0x1) {
              sp += BIAS;
-      target_read_memory (sp,
-                         &registers[REGISTER_BYTE (L0_REGNUM)],
-                         16*REGISTER_RAW_SIZE (L0_REGNUM));
-      for (i = L0_REGNUM; i <= I7_REGNUM; i++)
-       register_valid[i] = 1;
+             target_read_memory (sp,
+                                 &registers[REGISTER_BYTE (L0_REGNUM)],
+                                 16*REGISTER_RAW_SIZE (L0_REGNUM));
+             for (i = L0_REGNUM; i <= I7_REGNUM; i++)
+                     register_valid[i] = 1;
+      } else {
+             int tmp[16];
+
+             sp &= 0x0ffffffffL;
+             target_read_memory (sp, (void *)&tmp, sizeof(tmp));
+             for (i = L0_REGNUM; i <= I7_REGNUM; i++) {
+                     *(long *)&registers[REGISTER_BYTE (i)] =
+                             (long)tmp[i];
+                     printf_unfiltered("register %d valid is now %lx from %x\n", i, tmp[i], registers[REGISTER_BYTE (i)]);
+                     register_valid[i] = 1;
+             }
+      }
     }
   else if (regno >= L0_REGNUM && regno <= I7_REGNUM)
     {
       CORE_ADDR sp = *(CORE_ADDR*)&registers[REGISTER_BYTE (SP_REGNUM)];
-      if (sp & 0x1) 
+      if (sp & 0x1) {
              sp += BIAS;
-      i = REGISTER_BYTE (regno);
-      if (register_valid[regno])
-       printf_unfiltered("register %d valid and read\n", regno);
-      target_read_memory (sp + i - REGISTER_BYTE (L0_REGNUM),
-                         &registers[i], REGISTER_RAW_SIZE (regno));
-      register_valid[regno] = 1;
+             i = REGISTER_BYTE (regno);
+             if (register_valid[regno])
+                     printf_unfiltered("register %d valid and read\n", regno);
+             target_read_memory (sp + i - REGISTER_BYTE (L0_REGNUM),
+                                 &registers[i], REGISTER_RAW_SIZE (regno));
+             register_valid[regno] = 1;
+      } else {
+             int tmp;
+
+             sp &= 0x0ffffffffL;
+             i = REGISTER_BYTE (regno);
+             if (register_valid[regno])
+                     printf_unfiltered("register %d valid and read\n", regno);
+             target_read_memory (sp + sizeof(tmp) * (regno - L0_REGNUM),
+                                 (void *)&tmp, sizeof(tmp));
+             *(long *)&registers[i] = (long)tmp;
+             printf_unfiltered("register %d valid is now %lx from %x\n", i, tmp, *(long *)&registers[i]);
+      
+             register_valid[regno] = 1;
+      }
     }
 }
 
@@ -233,17 +259,37 @@
       if (regno < 0 || regno == SP_REGNUM)
        {
          if (!register_valid[L0_REGNUM+5]) abort();
-         target_write_memory (sp, 
-                              &registers[REGISTER_BYTE (L0_REGNUM)],
-                              16*REGISTER_RAW_SIZE (L0_REGNUM));
+         if (sp & 0x1) {
+                 sp += BIAS;
+                 target_write_memory (sp, 
+                                      &registers[REGISTER_BYTE (L0_REGNUM)],
+                                      16*REGISTER_RAW_SIZE (L0_REGNUM));
+         } else {
+                 int i, tmp[16];
+
+                 sp &= 0x0ffffffffL;
+                 for (i = L0_REGNUM; i <= I7_REGNUM; i++)
+                         tmp[i] = *(long *)&registers[REGISTER_BYTE (i)];
+                 target_write_memory (sp, (void *)&tmp, sizeof(tmp));
+         }
        }
       else
        {
          if (!register_valid[regno]) abort();
-         target_write_memory ((sp + REGISTER_BYTE (regno) -
-                              REGISTER_BYTE (L0_REGNUM)),
-                              &registers[REGISTER_BYTE (regno)],
-                              REGISTER_RAW_SIZE (regno));
+         if (sp & 0x1) {
+                 sp += BIAS;
+                 target_write_memory ((sp + REGISTER_BYTE (regno) -
+                                       REGISTER_BYTE (L0_REGNUM)),
+                                      &registers[REGISTER_BYTE (regno)],
+                                      REGISTER_RAW_SIZE (regno));
+         } else {
+                 int tmp;
+
+                 sp &= 0x0ffffffffL;
+                 tmp = *(long *)&registers[REGISTER_BYTE (regno)];
+                 target_write_memory (sp + sizeof(tmp) * (regno - L0_REGNUM),
+                                      (void *)&tmp, sizeof(tmp));
+         }
        }
        
     }
@@ -353,15 +399,31 @@
     CORE_ADDR sp;
 
     sp = *(CORE_ADDR *)&registers[REGISTER_BYTE (SP_REGNUM)];
-      if (sp & 0x1) 
-             sp += BIAS;
-    if (0 != target_read_memory (sp, &registers[REGISTER_BYTE (L0_REGNUM)], 
-                                16 * REGISTER_RAW_SIZE (L0_REGNUM)))
-      {
-       /* fprintf_unfiltered so user can still use gdb */
-       fprintf_unfiltered (gdb_stderr,
-               "Couldn't read input and local registers from core file\n");
-      }
+    if (sp & 0x1) {
+           sp += BIAS;
+           if (0 != target_read_memory (sp, &registers[REGISTER_BYTE (L0_REGNUM)], 
+                                        16 * REGISTER_RAW_SIZE (L0_REGNUM)))
+           {
+                   /* fprintf_unfiltered so user can still use gdb */
+                   fprintf_unfiltered (gdb_stderr,
+                                       "Couldn't read input and local registers from core file\n");
+           }
+    } else {
+           int i, tmp[16];
+
+           sp &= 0x0ffffffff;
+           if (0 != target_read_memory (sp, (void *)&tmp, sizeof(tmp))) {
+                   /* fprintf_unfiltered so user can still use gdb */
+                   fprintf_unfiltered (gdb_stderr,
+                                       "Couldn't read input and local registers from core file\n");
+           } else
+           for (i = L0_REGNUM; i <= I7_REGNUM; i++) {
+                   *(long *)&registers[REGISTER_BYTE (i)] =
+                           (long)tmp[i];
+                   register_valid[i] = 1;
+           }
+           
+    }
   }
 
   /* Floating point registers */
diff -r 01925c9b7ac3 -r 38dfbdd6144f gnu/dist/toolchain/gdb/sparc-tdep.c
--- a/gnu/dist/toolchain/gdb/sparc-tdep.c       Mon Feb 05 18:43:34 2001 +0000
+++ b/gnu/dist/toolchain/gdb/sparc-tdep.c       Mon Feb 05 18:47:10 2001 +0000
@@ -254,6 +254,8 @@
 #ifdef GDB_TARGET_IS_SPARC64
          if (fi->frame & 1)
            fi->frame += 2047;
+         else
+           fi->frame &= 0x0ffffffffL;
 #endif
 
        }
@@ -295,6 +297,8 @@
 #ifdef GDB_TARGET_IS_SPARC64
              if (fi->frame & 1)
                fi->frame += 2047;
+             else
+               fi->frame &= 0x0ffffffffL;
 #endif
              /* Record where the fp got saved.  */
              fi->fp_addr = fi->frame + fi->sp_offset + X_SIMM13 (insn);
@@ -1163,6 +1167,8 @@
 #ifdef GDB_TARGET_IS_SPARC64
       if (sp & 1)
        sp += 2047;
+      else
+       sp &= 0x0ffffffffL;
 #endif
       read_memory (sp, reg_temp, SPARC_INTREG_SIZE * 16);
 
@@ -1984,6 +1990,8 @@
 
   if (sp & 1)
     sp += 2047;
+  else
+    sp &= 0x0ffffffffL;
   return sp;
 }
 
@@ -1994,6 +2002,8 @@
 
   if (fp & 1)
     fp += 2047;
+  else
+    fp &= 0x0ffffffffL;
   return fp;
 }
 



Home | Main Index | Thread Index | Old Index