ARM: Only send information that changed between statetrace and M5.

This commit is contained in:
Gabe Black 2009-07-27 00:54:30 -07:00
parent 90d3d3535b
commit 52b4a7c36f
3 changed files with 46 additions and 15 deletions

View file

@ -51,10 +51,31 @@ Trace::ArmNativeTrace::ThreadState::update(NativeTrace *parent)
current = (current + 1) % 2;
newState = state[current];
parent->read(newState, sizeof(newState[0]) * STATE_NUMVALS);
memcpy(newState, oldState, sizeof(state[0]));
uint32_t diffVector;
parent->read(&diffVector, sizeof(diffVector));
diffVector = ArmISA::gtoh(diffVector);
int changes = 0;
for (int i = 0; i < STATE_NUMVALS; i++) {
newState[i] = ArmISA::gtoh(newState[i]);
changed[i] = (oldState[i] != newState[i]);
if (diffVector & 0x1) {
changed[i] = true;
changes++;
} else {
changed[i] = false;
}
diffVector >>= 1;
}
uint32_t values[changes];
parent->read(values, sizeof(values));
int pos = 0;
for (int i = 0; i < STATE_NUMVALS; i++) {
if (changed[i]) {
newState[i] = ArmISA::gtoh(values[pos++]);
changed[i] = (newState[i] != oldState[i]);
}
}
}

View file

@ -46,23 +46,38 @@ const char* ARMTraceChild::regNames[numregs] = {
ARMTraceChild::ARMTraceChild()
{
for (int x = 0; x < numregs; x++)
for (int x = 0; x < numregs; x++) {
memset(&regs, 0, sizeof(regs));
memset(&oldregs, 0, sizeof(regs));
regDiffSinceUpdate[x] = false;
}
}
bool ARMTraceChild::sendState(int socket)
{
uint32_t regVal = 0;
for(int x = 0; x < numregs; x++)
{
regVal = getRegVal(x);
if(write(socket, &regVal, sizeof(regVal)) == -1)
{
uint32_t message[numregs + 1];
int pos = 1;
message[0] = 0;
for (int x = 0; x < numregs; x++) {
if (regDiffSinceUpdate[x]) {
message[0] = message[0] | (1 << x);
message[pos++] = getRegVal(x);
}
}
size_t sent = 0;
size_t toSend = pos * sizeof(message[0]);
uint8_t *messagePtr = (uint8_t *)message;
while (toSend != 0) {
sent = write(socket, messagePtr, toSend);
if (sent == -1) {
cerr << "Write failed! " << strerror(errno) << endl;
tracing = false;
return false;
}
toSend -= sent;
messagePtr += sent;
}
return true;

View file

@ -79,11 +79,6 @@ bool TraceChild::startTracing(const char * pathToFile, char * const argv[])
return false;
}
tracing = true;
if(!update(pid))
{
cout << "Didn't update successfully!" << endl;
return false;
}
return true;
}