tracechild.cc (8229:78bf55f23338) | tracechild.cc (8271:1d3733d3acee) |
---|---|
1/* 2 * Copyright (c) 2010 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 42 unchanged lines hidden (view full) --- 51#include "arch/arm/tracechild.hh" 52 53using namespace std; 54 55ARMTraceChild::ARMTraceChild() 56{ 57 foundMvn = false; 58 | 1/* 2 * Copyright (c) 2010 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 42 unchanged lines hidden (view full) --- 51#include "arch/arm/tracechild.hh" 52 53using namespace std; 54 55ARMTraceChild::ARMTraceChild() 56{ 57 foundMvn = false; 58 |
59 memset(®s, 0, sizeof(regs)); 60 memset(&oldregs, 0, sizeof(regs)); 61 memset(&fpregs, 0, sizeof(vfp_regs)); 62 memset(&oldfpregs, 0, sizeof(vfp_regs)); 63 |
|
59 for (int x = 0; x < numregs; x++) { | 64 for (int x = 0; x < numregs; x++) { |
60 memset(®s, 0, sizeof(regs)); 61 memset(&oldregs, 0, sizeof(regs)); | |
62 regDiffSinceUpdate[x] = false; 63 } | 65 regDiffSinceUpdate[x] = false; 66 } |
67 68 assert(sizeof(regs.uregs)/sizeof(regs.uregs[0]) > CPSR); |
|
64} 65 66bool 67ARMTraceChild::sendState(int socket) 68{ 69 uint32_t regVal = 0; | 69} 70 71bool 72ARMTraceChild::sendState(int socket) 73{ 74 uint32_t regVal = 0; |
70 uint32_t message[numregs + 1]; | 75 uint64_t message[numregs + 1]; |
71 int pos = 1; 72 message[0] = 0; 73 for (int x = 0; x < numregs; x++) { 74 if (regDiffSinceUpdate[x]) { | 76 int pos = 1; 77 message[0] = 0; 78 for (int x = 0; x < numregs; x++) { 79 if (regDiffSinceUpdate[x]) { |
75 message[0] = message[0] | (1 << x); | 80 message[0] = message[0] | (1ULL << x); |
76 message[pos++] = getRegVal(x); 77 } 78 } 79 80 size_t sent = 0; 81 size_t toSend = pos * sizeof(message[0]); 82 uint8_t *messagePtr = (uint8_t *)message; 83 while (toSend != 0) { --- 8 unchanged lines hidden (view full) --- 92 } 93 94 return true; 95} 96 97uint32_t 98ARMTraceChild::getRegs(user_regs &myregs, int num) 99{ | 81 message[pos++] = getRegVal(x); 82 } 83 } 84 85 size_t sent = 0; 86 size_t toSend = pos * sizeof(message[0]); 87 uint8_t *messagePtr = (uint8_t *)message; 88 while (toSend != 0) { --- 8 unchanged lines hidden (view full) --- 97 } 98 99 return true; 100} 101 102uint32_t 103ARMTraceChild::getRegs(user_regs &myregs, int num) 104{ |
100 assert(num < numregs && num >= 0); | 105 assert(num <= CPSR && num >= 0); |
101 return myregs.uregs[num]; 102} 103 | 106 return myregs.uregs[num]; 107} 108 |
109uint64_t 110ARMTraceChild::getFpRegs(vfp_regs &my_fp_regs, int num) 111{ 112 assert(num >= F0 && num < numregs); 113 if (num == FPSCR) 114 return my_fp_regs.fpscr; 115 116 num -= F0; 117 return my_fp_regs.fpregs[num]; 118} 119 |
|
104bool 105ARMTraceChild::update(int pid) 106{ 107 oldregs = regs; 108 if (ptrace(PTRACE_GETREGS, pid, 0, ®s) != 0) { 109 cerr << "update: " << strerror(errno) << endl; 110 return false; 111 } 112 | 120bool 121ARMTraceChild::update(int pid) 122{ 123 oldregs = regs; 124 if (ptrace(PTRACE_GETREGS, pid, 0, ®s) != 0) { 125 cerr << "update: " << strerror(errno) << endl; 126 return false; 127 } 128 |
129 const uint32_t get_vfp_regs = 32; 130 131 oldfpregs = fpregs; 132 if (ptrace((__ptrace_request)get_vfp_regs, pid, 0, &fpregs) != 0) { 133 cerr << "update: " << strerror(errno) << endl; 134 return false; 135 } 136 |
|
113 for (unsigned int x = 0; x < numregs; x++) 114 regDiffSinceUpdate[x] = (getRegVal(x) != getOldRegVal(x)); | 137 for (unsigned int x = 0; x < numregs; x++) 138 regDiffSinceUpdate[x] = (getRegVal(x) != getOldRegVal(x)); |
139 |
|
115 return true; 116} 117 118int64_t 119ARMTraceChild::getRegVal(int num) 120{ | 140 return true; 141} 142 143int64_t 144ARMTraceChild::getRegVal(int num) 145{ |
121 return getRegs(regs, num); | 146 if (num <= CPSR) 147 return getRegs(regs, num); 148 else 149 return (int64_t)getFpRegs(fpregs, num); |
122} 123 124int64_t 125ARMTraceChild::getOldRegVal(int num) 126{ | 150} 151 152int64_t 153ARMTraceChild::getOldRegVal(int num) 154{ |
127 return getRegs(oldregs, num); | 155 if (num <= CPSR) 156 return getRegs(oldregs, num); 157 else 158 return (int64_t)getFpRegs(oldfpregs, num); |
128} 129 130ostream & 131ARMTraceChild::outputStartState(ostream & os) 132{ 133 uint32_t sp = getSP(); 134 uint32_t pc = getPC(); 135 uint32_t highestInfo = 0; --- 120 unchanged lines hidden --- | 159} 160 161ostream & 162ARMTraceChild::outputStartState(ostream & os) 163{ 164 uint32_t sp = getSP(); 165 uint32_t pc = getPC(); 166 uint32_t highestInfo = 0; --- 120 unchanged lines hidden --- |