plugin/tracing: fix extended trace on umapped memory areas

When a register in the extended trace was dereferenced and the value
was smaller than the memory pool size, but the address was not mapped
an assertion occured and the tracing plugin terminated the
simulator. Now the dereferenced memory address is checked for being
mapped and not being smaller than the memory pool.

Change-Id: I9ac954988ef860969679f9f360814c5e4b66f473
This commit is contained in:
Christian Dietrich
2013-10-28 15:09:35 +01:00
parent 148b09be2e
commit 5171645d9a
3 changed files with 20 additions and 1 deletions

View File

@ -60,6 +60,14 @@ public:
* @param src Pointer to data to be copied.
*/
virtual void setBytes(guest_address_t addr, size_t cnt, void const *src) = 0;
/**
* Checks whether memory is mapped and available.
* @param addr The guest address to check.
*/
virtual bool isMapped(guest_address_t addr) {
// default implementation
return addr < getPoolSize();
}
};
} // end-of-namespace: fail

View File

@ -103,6 +103,17 @@ public:
else
return (reinterpret_cast<host_address_t>(hostAddr)); // okay
}
/**
* Checks whether memory is mapped and available.
* @param addr The guest address to check.
*/
virtual bool isMapped(guest_address_t addr) {
host_address_t hostaddr = guestToHost(addr);
if (hostaddr == (host_address_t)ADDR_INV)
return false;
return true;
}
};
} // end-of-namespace: fail

View File

@ -133,7 +133,7 @@ bool TracingPlugin::run()
Trace_Event_Extended_Registers *er = ext.add_registers();
er->set_id((*it)->getId());
er->set_value(simulator.getCPU(0).getRegisterContent(*it));
if (er->value() <= mm.getPoolSize() - 4) {
if (mm.isMapped(er->value())) {
uint32_t value_deref;
mm.getBytes(er->value(), 4, &value_deref);
er->set_value_deref(value_deref);