ARM: Only send information that changed between statetrace and M5.
This commit is contained in:
parent
90d3d3535b
commit
52b4a7c36f
3 changed files with 46 additions and 15 deletions
|
@ -51,10 +51,31 @@ Trace::ArmNativeTrace::ThreadState::update(NativeTrace *parent)
|
||||||
current = (current + 1) % 2;
|
current = (current + 1) % 2;
|
||||||
newState = state[current];
|
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++) {
|
for (int i = 0; i < STATE_NUMVALS; i++) {
|
||||||
newState[i] = ArmISA::gtoh(newState[i]);
|
if (diffVector & 0x1) {
|
||||||
changed[i] = (oldState[i] != newState[i]);
|
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]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,23 +46,38 @@ const char* ARMTraceChild::regNames[numregs] = {
|
||||||
|
|
||||||
ARMTraceChild::ARMTraceChild()
|
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;
|
regDiffSinceUpdate[x] = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ARMTraceChild::sendState(int socket)
|
bool ARMTraceChild::sendState(int socket)
|
||||||
{
|
{
|
||||||
uint32_t regVal = 0;
|
uint32_t regVal = 0;
|
||||||
for(int x = 0; x < numregs; x++)
|
uint32_t message[numregs + 1];
|
||||||
{
|
int pos = 1;
|
||||||
regVal = getRegVal(x);
|
message[0] = 0;
|
||||||
if(write(socket, ®Val, sizeof(regVal)) == -1)
|
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;
|
cerr << "Write failed! " << strerror(errno) << endl;
|
||||||
tracing = false;
|
tracing = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
toSend -= sent;
|
||||||
|
messagePtr += sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -79,11 +79,6 @@ bool TraceChild::startTracing(const char * pathToFile, char * const argv[])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
tracing = true;
|
tracing = true;
|
||||||
if(!update(pid))
|
|
||||||
{
|
|
||||||
cout << "Didn't update successfully!" << endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue