Statetrace: Fix compile problems with the AMD64 version of statetrace.

This commit is contained in:
Gabe Black 2010-05-02 00:39:46 -07:00
parent 51a3d65e25
commit d75ad847b3
2 changed files with 11 additions and 10 deletions

View file

@ -33,12 +33,13 @@
#include <errno.h> #include <errno.h>
#include <sys/ptrace.h> #include <sys/ptrace.h>
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include "tracechild_amd64.hh" #include "tracechild_amd64.hh"
using namespace std; using namespace std;
char * AMD64TraceChild::regNames[numregs] = { const char * AMD64TraceChild::regNames[numregs] = {
//GPRs //GPRs
"rax", "rbx", "rcx", "rdx", "rax", "rbx", "rcx", "rdx",
//Index registers //Index registers
@ -288,7 +289,7 @@ int64_t AMD64TraceChild::getOldRegVal(int num)
char * AMD64TraceChild::printReg(int num) char * AMD64TraceChild::printReg(int num)
{ {
sprintf(printBuffer, "0x%08X", getRegVal(num)); sprintf(printBuffer, "0x%016lX", getRegVal(num));
return printBuffer; return printBuffer;
} }
@ -298,14 +299,14 @@ ostream & AMD64TraceChild::outputStartState(ostream & os)
uint64_t pc = getPC(); uint64_t pc = getPC();
uint64_t highestInfo = 0; uint64_t highestInfo = 0;
char obuf[1024]; char obuf[1024];
sprintf(obuf, "Initial stack pointer = 0x%016llx\n", sp); sprintf(obuf, "Initial stack pointer = 0x%016lx\n", sp);
os << obuf; os << obuf;
sprintf(obuf, "Initial program counter = 0x%016llx\n", pc); sprintf(obuf, "Initial program counter = 0x%016lx\n", pc);
os << obuf; os << obuf;
//Output the argument count //Output the argument count
uint64_t cargc = ptrace(PTRACE_PEEKDATA, pid, sp, 0); uint64_t cargc = ptrace(PTRACE_PEEKDATA, pid, sp, 0);
sprintf(obuf, "0x%016llx: Argc = 0x%016llx\n", sp, cargc); sprintf(obuf, "0x%016lx: Argc = 0x%016lx\n", sp, cargc);
os << obuf; os << obuf;
sp += 8; sp += 8;
@ -315,7 +316,7 @@ ostream & AMD64TraceChild::outputStartState(ostream & os)
do do
{ {
cargv = ptrace(PTRACE_PEEKDATA, pid, sp, 0); cargv = ptrace(PTRACE_PEEKDATA, pid, sp, 0);
sprintf(obuf, "0x%016llx: argv[%d] = 0x%016llx\n", sprintf(obuf, "0x%016lx: argv[%d] = 0x%016lx\n",
sp, argCount++, cargv); sp, argCount++, cargv);
if(cargv) if(cargv)
if(highestInfo < cargv) if(highestInfo < cargv)
@ -330,7 +331,7 @@ ostream & AMD64TraceChild::outputStartState(ostream & os)
do do
{ {
cenvp = ptrace(PTRACE_PEEKDATA, pid, sp, 0); cenvp = ptrace(PTRACE_PEEKDATA, pid, sp, 0);
sprintf(obuf, "0x%016llx: envp[%d] = 0x%016llx\n", sprintf(obuf, "0x%016lx: envp[%d] = 0x%016lx\n",
sp, envCount++, cenvp); sp, envCount++, cenvp);
os << obuf; os << obuf;
sp += 8; sp += 8;
@ -342,7 +343,7 @@ ostream & AMD64TraceChild::outputStartState(ostream & os)
sp += 8; sp += 8;
auxVal = ptrace(PTRACE_PEEKDATA, pid, sp, 0); auxVal = ptrace(PTRACE_PEEKDATA, pid, sp, 0);
sp += 8; sp += 8;
sprintf(obuf, "0x%016llx: Auxiliary vector = {0x%016llx, 0x%016llx}\n", sprintf(obuf, "0x%016lx: Auxiliary vector = {0x%016lx, 0x%016lx}\n",
sp - 16, auxType, auxVal); sp - 16, auxType, auxVal);
os << obuf; os << obuf;
} while(auxType != 0 || auxVal != 0); } while(auxType != 0 || auxVal != 0);
@ -361,7 +362,7 @@ ostream & AMD64TraceChild::outputStartState(ostream & os)
current += cbuf[x]; current += cbuf[x];
else else
{ {
sprintf(obuf, "0x%016llx: \"%s\"\n", sprintf(obuf, "0x%016lx: \"%s\"\n",
currentStart, current.c_str()); currentStart, current.c_str());
os << obuf; os << obuf;
current = ""; current = "";

View file

@ -88,7 +88,7 @@ class AMD64TraceChild : public TraceChild
}; };
private: private:
char printBuffer [256]; char printBuffer [256];
static char * regNames[numregs]; static const char * regNames[numregs];
int64_t getRegs(user_regs_struct & myregs, int64_t getRegs(user_regs_struct & myregs,
user_fpregs_struct &myfpregs,int num); user_fpregs_struct &myfpregs,int num);
user_regs_struct regs; user_regs_struct regs;