diff --git a/src/arch/arm/nativetrace.cc b/src/arch/arm/nativetrace.cc index 469869e56..7c9c70e0c 100644 --- a/src/arch/arm/nativetrace.cc +++ b/src/arch/arm/nativetrace.cc @@ -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]); + } } } diff --git a/util/statetrace/arch/tracechild_arm.cc b/util/statetrace/arch/tracechild_arm.cc index fc2eb3e24..4687b46f0 100644 --- a/util/statetrace/arch/tracechild_arm.cc +++ b/util/statetrace/arch/tracechild_arm.cc @@ -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(®s, 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, ®Val, 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; diff --git a/util/statetrace/tracechild.cc b/util/statetrace/tracechild.cc index 52e19a0e9..85f42addd 100644 --- a/util/statetrace/tracechild.cc +++ b/util/statetrace/tracechild.cc @@ -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; }