]> granicus.if.org Git - strace/commitdiff
2003-01-14 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Tue, 14 Jan 2003 09:59:00 +0000 (09:59 +0000)
committerRoland McGrath <roland@redhat.com>
Tue, 14 Jan 2003 09:59:00 +0000 (09:59 +0000)
* configure.ac: Match powerpc* (includes powerpc64), and don't match
ppc (never comes out of config.sub).
* process.c (sys_ptrace): Use #lx format for address argument.
[POWERPC]: Use sizeof(unsigned long) in place of 4 for multipliers.
* process.c [POWERPC]: Likewise.
* signal.c (sys_sigreturn) [POWERPC]: Likewise.
* syscall.c (get_scno) [POWERPC]: Likewise.
* util.c [POWERPC]: Likewise.
(printnum): Use long for NUM.
From Anton Blanchard <anton@samba.org>.

configure.ac
process.c
signal.c
syscall.c
util.c

index f78a4286e3615a0f700c5d95c3298a6b17e0e88a..6d83bbe3fd13285ef29d76ea0d67bf4fe8df4a16 100644 (file)
@@ -67,7 +67,7 @@ alpha*)
        arch=alpha
        AC_DEFINE([ALPHA], 1, [Define for the Alpha architecture.])
        ;;
-ppc|powerpc)
+powerpc*)
        arch=powerpc
        AC_DEFINE([POWERPC], 1, [Define for the PowerPC architecture.])
        ;;
index c66e7c2ff2950f5c6d39b2aa312f59f9b6133ea9..633a5820d9db847ebc5d3635d0385f3e8cbb6d50 100644 (file)
--- a/process.c
+++ b/process.c
@@ -609,7 +609,8 @@ int new;
                return -1;
        return 0;
 #elif defined(POWERPC)
-       if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R0), new) < 0)
+       if (ptrace(PTRACE_POKEUSER, tcp->pid,
+                  (char*)(sizeof(unsigned long)*PT_R0), new) < 0)
                return -1;
        return 0;
 #elif defined(S390) || defined(S390X)
@@ -693,7 +694,7 @@ setarg(tcp, argnum)
 #endif
        {
                ptrace(PTRACE_POKEUSER, tcp->pid,
-                      (char*)((argnum==0 ? PT_ORIG_R3 : argnum+PT_R3)*4),
+                      (char*)((argnum==0 ? PT_ORIG_R3 : argnum+PT_R3)*sizeof(unsigned long)),
                       tcp->u_arg[argnum]);
                if (errno)
                        return -1;
@@ -2126,46 +2127,48 @@ struct xlat struct_user_offsets[] = {
 #ifndef PT_ORIG_R3
 #define PT_ORIG_R3 34
 #endif
-       { 4*PT_R0,              "4*PT_R0"                               },
-       { 4*PT_R1,              "4*PT_R1"                               },
-       { 4*PT_R2,              "4*PT_R2"                               },
-       { 4*PT_R3,              "4*PT_R3"                               },
-       { 4*PT_R4,              "4*PT_R4"                               },
-       { 4*PT_R5,              "4*PT_R5"                               },
-       { 4*PT_R6,              "4*PT_R6"                               },
-       { 4*PT_R7,              "4*PT_R7"                               },
-       { 4*PT_R8,              "4*PT_R8"                               },
-       { 4*PT_R9,              "4*PT_R9"                               },
-       { 4*PT_R10,             "4*PT_R10"                              },
-       { 4*PT_R11,             "4*PT_R11"                              },
-       { 4*PT_R12,             "4*PT_R12"                              },
-       { 4*PT_R13,             "4*PT_R13"                              },
-       { 4*PT_R14,             "4*PT_R14"                              },
-       { 4*PT_R15,             "4*PT_R15"                              },
-       { 4*PT_R16,             "4*PT_R16"                              },
-       { 4*PT_R17,             "4*PT_R17"                              },
-       { 4*PT_R18,             "4*PT_R18"                              },
-       { 4*PT_R19,             "4*PT_R19"                              },
-       { 4*PT_R20,             "4*PT_R20"                              },
-       { 4*PT_R21,             "4*PT_R21"                              },
-       { 4*PT_R22,             "4*PT_R22"                              },
-       { 4*PT_R23,             "4*PT_R23"                              },
-       { 4*PT_R24,             "4*PT_R24"                              },
-       { 4*PT_R25,             "4*PT_R25"                              },
-       { 4*PT_R26,             "4*PT_R26"                              },
-       { 4*PT_R27,             "4*PT_R27"                              },
-       { 4*PT_R28,             "4*PT_R28"                              },
-       { 4*PT_R29,             "4*PT_R29"                              },
-       { 4*PT_R30,             "4*PT_R30"                              },
-       { 4*PT_R31,             "4*PT_R31"                              },
-       { 4*PT_NIP,             "4*PT_NIP"                              },
-       { 4*PT_MSR,             "4*PT_MSR"                              },
-       { 4*PT_ORIG_R3,         "4*PT_ORIG_R3"                          },
-       { 4*PT_CTR,             "4*PT_CTR"                              },
-       { 4*PT_LNK,             "4*PT_LNK"                              },
-       { 4*PT_XER,             "4*PT_XER"                              },
-       { 4*PT_CCR,             "4*PT_CCR"                              },
-       { 4*PT_FPR0,            "4*PT_FPR0"                             },
+#define REGSIZE (sizeof(unsigned long))
+       { REGSIZE*PT_R0,                "r0"                            },
+       { REGSIZE*PT_R1,                "r1"                            },
+       { REGSIZE*PT_R2,                "r2"                            },
+       { REGSIZE*PT_R3,                "r3"                            },
+       { REGSIZE*PT_R4,                "r4"                            },
+       { REGSIZE*PT_R5,                "r5"                            },
+       { REGSIZE*PT_R6,                "r6"                            },
+       { REGSIZE*PT_R7,                "r7"                            },
+       { REGSIZE*PT_R8,                "r8"                            },
+       { REGSIZE*PT_R9,                "r9"                            },
+       { REGSIZE*PT_R10,               "r10"                           },
+       { REGSIZE*PT_R11,               "r11"                           },
+       { REGSIZE*PT_R12,               "r12"                           },
+       { REGSIZE*PT_R13,               "r13"                           },
+       { REGSIZE*PT_R14,               "r14"                           },
+       { REGSIZE*PT_R15,               "r15"                           },
+       { REGSIZE*PT_R16,               "r16"                           },
+       { REGSIZE*PT_R17,               "r17"                           },
+       { REGSIZE*PT_R18,               "r18"                           },
+       { REGSIZE*PT_R19,               "r19"                           },
+       { REGSIZE*PT_R20,               "r20"                           },
+       { REGSIZE*PT_R21,               "r21"                           },
+       { REGSIZE*PT_R22,               "r22"                           },
+       { REGSIZE*PT_R23,               "r23"                           },
+       { REGSIZE*PT_R24,               "r24"                           },
+       { REGSIZE*PT_R25,               "r25"                           },
+       { REGSIZE*PT_R26,               "r26"                           },
+       { REGSIZE*PT_R27,               "r27"                           },
+       { REGSIZE*PT_R28,               "r28"                           },
+       { REGSIZE*PT_R29,               "r29"                           },
+       { REGSIZE*PT_R30,               "r30"                           },
+       { REGSIZE*PT_R31,               "r31"                           },
+       { REGSIZE*PT_NIP,               "NIP"                           },
+       { REGSIZE*PT_MSR,               "MSR"                           },
+       { REGSIZE*PT_ORIG_R3,           "ORIG_R3"                       },
+       { REGSIZE*PT_CTR,               "CTR"                           },
+       { REGSIZE*PT_LNK,               "LNK"                           },
+       { REGSIZE*PT_XER,               "XER"                           },
+       { REGSIZE*PT_CCR,               "CCR"                           },
+       { REGSIZE*PT_FPR0,              "FPR0"                          },
+#undef REGSIZE
 #else
 #ifdef ALPHA
        { 0,                    "r0"                                    },
@@ -2569,7 +2572,7 @@ struct tcb *tcp;
                case PTRACE_PEEKDATA:
                case PTRACE_PEEKTEXT:
                case PTRACE_PEEKUSER:
-                       printnum(tcp, tcp->u_arg[3], "%#x");
+                       printnum(tcp, tcp->u_arg[3], "%#lx");
                        break;
                }
        }
index e2cb8d0221e610147e170facd506cc59fd5e6f80..ad9e616f038c972d6c206dc16dc3957634909a70 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -1253,7 +1253,7 @@ struct tcb *tcp;
 
        if (entering(tcp)) {
                   tcp->u_arg[0] = 0;
-                  if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
+                  if (upeek(tcp->pid, sizeof(unsigned long)*PT_R1, &esp) < 0)
                           return 0;
                   if (umove(tcp, esp, &sc) < 0)
                           return 0;
index b2ecd7aad3ff227741c220110e26908c49ef75e5..f9e39d4ef0ed1a5a441a700b93625eb44c50a8a4 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -806,7 +806,7 @@ struct tcb *tcp;
                }
        }
 #elif defined (POWERPC)
-       if (upeek(pid, 4*PT_R0, &scno) < 0)
+       if (upeek(pid, sizeof(unsigned long)*PT_R0, &scno) < 0)
                return -1;
        if (!(tcp->flags & TCB_INSYSCALL)) {
                /* Check if we return from execve. */
@@ -1204,9 +1204,9 @@ struct tcb *tcp;
        }
 #elif defined (POWERPC)
 # define SO_MASK 0x10000000
-       if (upeek(pid, 4*PT_CCR, &flags) < 0)
+       if (upeek(pid, sizeof(unsigned long)*PT_CCR, &flags) < 0)
                return -1;
-       if (upeek(pid, 4*PT_R3, &result) < 0)
+       if (upeek(pid, sizeof(unsigned long)*PT_R3, &result) < 0)
                return -1;
        if (flags & SO_MASK)
                result = -result;
@@ -1528,7 +1528,7 @@ force_result(tcp, error, rval)
                return -1;
 #else
 #ifdef POWERPC
-       if (upeek(tcp->pid, 4*PT_CCR, &flags) < 0)
+       if (upeek(tcp->pid, sizeof(unsigned long)*PT_CCR, &flags) < 0)
                return -1;
        if (error) {
                flags |= SO_MASK;
@@ -1538,8 +1538,8 @@ force_result(tcp, error, rval)
                flags &= ~SO_MASK;
                result = rval;
        }
-       if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_CCR), flags) < 0 ||
-           ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R3), result) < 0)
+       if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(sizeof(unsigned long)*PT_CCR), flags) < 0 ||
+           ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(sizeof(unsigned long)*PT_R3), result) < 0)
                return -1;
 #else /* !POWERPC */
 #ifdef M68K
@@ -1762,7 +1762,10 @@ struct tcb *tcp;
                else
                        tcp->u_nargs = MAX_ARGS;
                for (i = 0; i < tcp->u_nargs; i++) {
-                       if (upeek(pid, (i==0) ? (4*PT_ORIG_R3) : ((i+PT_R3)*4), &tcp->u_arg[i]) < 0)
+                       if (upeek(pid, (i==0) ?
+                               (sizeof(unsigned long)*PT_ORIG_R3) :
+                               ((i+PT_R3)*sizeof(unsigned long)),
+                                       &tcp->u_arg[i]) < 0)
                                return -1;
                }
        }
diff --git a/util.c b/util.c
index d3cec2d1090790f1bbd925eb70d7ca95bf146000..d01b1d84c398fb86ed880b6128076df2f2d34d70 100644 (file)
--- a/util.c
+++ b/util.c
@@ -292,7 +292,7 @@ struct tcb *tcp;
 long addr;
 char *fmt;
 {
-       int num;
+       long num;
 
        if (!addr) {
                tprintf("NULL");
@@ -942,7 +942,7 @@ struct tcb *tcp;
        if (upeek(tcp->pid, 4*15, &pc) < 0)
                return -1;
 #elif defined(POWERPC)
-       if (upeek(tcp->pid, 4*PT_NIP, &pc) < 0)
+       if (upeek(tcp->pid, sizeof(unsigned long)*PT_NIP, &pc) < 0)
                return -1;
 #elif defined(M68k)
        if (upeek(tcp->pid, 4*PT_PC, &pc) < 0)
@@ -1030,7 +1030,7 @@ struct tcb *tcp;
 #elif defined(POWERPC)
        long pc;
 
-       if (upeek(tcp->pid, 4*PT_NIP, &pc) < 0) {
+       if (upeek(tcp->pid, sizeof(unsigned long)*PT_NIP, &pc) < 0) {
                tprintf ("[????????] ");
                return;
        }
@@ -1203,8 +1203,8 @@ typedef struct regs arg_setup_state;
 #  define arg0_offset  REG_A0
 #  define arg1_offset  (REG_A0+1)
 # elif defined (POWERPC)
-#  define arg0_offset  (4*PT_R3)
-#  define arg1_offset  (4*PT_R4)
+#  define arg0_offset  (sizeof(unsigned long)*PT_R3)
+#  define arg1_offset  (sizeof(unsigned long)*PT_R4)
 #  define restore_arg0(tcp, state, val) 0
 # elif defined (HPPA)
 #  define arg0_offset   PT_GR26
@@ -1483,7 +1483,7 @@ struct tcb *tcp;
 #elif defined (MIPS)
        return -1;              /* FIXME: I do not know what i do - Flo */
 #elif defined (POWERPC)
-       if (upeek(tcp->pid, 4*PT_NIP, &tcp->baddr) < 0)
+       if (upeek(tcp->pid, sizeof(unsigned long)*PT_NIP, &tcp->baddr) < 0)
                return -1;
 #elif defined(S390) || defined(S390X)
        if (upeek(tcp->pid,PT_PSWADDR, &tcp->baddr) < 0)
@@ -1707,7 +1707,7 @@ struct tcb *tcp;
                return 0;
        }
 #elif defined(POWERPC)
-       if (upeek(tcp->pid, 4*PT_NIP, &pc) < 0)
+       if (upeek(tcp->pid, sizeof(unsigned long)*PT_NIP, &pc) < 0)
                return -1;
        if (pc != tcp->baddr) {
                /* The breakpoint has not been reached yet.  */