util: disassembler register/address mapping fix
For def/use pruning, the linear address mapping of the x86 sub-registers (e.g., AX represents the lower 16 bits of EAX) must overlap. If it doesn't, e.g., AX and EAX are considered separate registers by def/use pruning, resulting in a failure to correlate an EAX def with a subsequent AX use. The only user of this mapping up to now, RegisterImporter, forced all register widths to 8 bits, thereby fortunately canceling out this problem. Nevertheless it makes no sense to continue encoding a constant width in these virtual addresses. Existing trace, fspgroup, fsppilot and result tables may be converted to the new encoding by using this query: UPDATE <tablename> SET data_address = ((data_address >> 4) & ~0xf) | data_address & 0xf; Change-Id: I7a942b78c34f6140803a86af639eeedef3550f34
This commit is contained in:
@ -13,6 +13,12 @@ namespace fail {
|
|||||||
*/
|
*/
|
||||||
class LLVMtoFailTranslator {
|
class LLVMtoFailTranslator {
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Maps registers to/from linear addresses usable for def/use-pruning
|
||||||
|
* purposes and storage in the database. Takes care that the linear
|
||||||
|
* addresses of x86 subregisters (e.g., AX represents the lower 16 bits of
|
||||||
|
* EAX) overlap with their siblings.
|
||||||
|
*/
|
||||||
struct reginfo_t {
|
struct reginfo_t {
|
||||||
int id;
|
int id;
|
||||||
regwidth_t width;
|
regwidth_t width;
|
||||||
@ -20,18 +26,17 @@ public:
|
|||||||
byte_t offset;
|
byte_t offset;
|
||||||
|
|
||||||
int toDataAddress() const {
|
int toDataAddress() const {
|
||||||
// .. 5 4 | 7 6 5 4 | 3 2 1 0
|
// .. 5 4 | 3 2 1 0
|
||||||
// <reg> | <width> | <offset>
|
// <reg> | <offset>
|
||||||
return (id << 8) | ((width/8) << 4) | (offset / 8);
|
return (id << 4) | (offset / 8);
|
||||||
}
|
}
|
||||||
|
// does not recreate width or mask
|
||||||
static reginfo_t fromDataAddress(int addr) {
|
static reginfo_t fromDataAddress(int addr) {
|
||||||
int id = addr >> 8;
|
int id = addr >> 4;
|
||||||
regwidth_t width = ((addr >> 4) & 0xf) * 8;
|
byte_t offset = (addr & 0xf) * 8;
|
||||||
byte_t offset = (addr & 0xf) * 8;
|
return reginfo_t(id, 0, offset);
|
||||||
return reginfo_t(id, width, offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
reginfo_t(int id=-1, regwidth_t width = 32, byte_t offs = 0)
|
reginfo_t(int id=-1, regwidth_t width = 32, byte_t offs = 0)
|
||||||
: id(id), width(width), mask((regwidth_t)((((long long)1 << width) - 1) << offs)), offset(offs) {};
|
: id(id), width(width), mask((regwidth_t)((((long long)1 << width) - 1) << offs)), offset(offs) {};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -33,9 +33,8 @@ bool RegisterImporter::addRegisterTrace(simtime_t curtime, instruction_count_t i
|
|||||||
const Trace_Event &ev,
|
const Trace_Event &ev,
|
||||||
const LLVMtoFailTranslator::reginfo_t &info,
|
const LLVMtoFailTranslator::reginfo_t &info,
|
||||||
char access_type) {
|
char access_type) {
|
||||||
LLVMtoFailTranslator::reginfo_t one_byte_window = info;
|
address_t from = info.toDataAddress();
|
||||||
one_byte_window.width = 8;
|
address_t to = from + info.width / 8;
|
||||||
address_t from = one_byte_window.toDataAddress(), to = one_byte_window.toDataAddress() + (info.width) / 8;
|
|
||||||
|
|
||||||
// Iterate over all accessed bytes
|
// Iterate over all accessed bytes
|
||||||
for (address_t data_address = from; data_address < to; ++data_address) {
|
for (address_t data_address = from; data_address < to; ++data_address) {
|
||||||
|
|||||||
Reference in New Issue
Block a user