GP-3605 Only log error message once and improve efficiency of allocating

new spaces
This commit is contained in:
emteere 2023-07-03 16:10:27 +00:00
parent a7063c672e
commit 365f526877

View File

@ -1383,15 +1383,9 @@ public class VarnodeContext implements ProcessorContext {
return result;
}
// This is bad since registers could have multiple associated spaces
// private int getSymbolSpaceID(Varnode val) {
// Register reg = trans.getRegister(val);
// if (reg == null) {
// return -1;
// }
// return getAddressSpace(reg.getName());
// }
// flag running out of address spaces, so error only printed once
private boolean hitMaxAddressSpaces = false;
public int getAddressSpace(String name) {
int spaceID;
AddressSpace regSpace = addrFactory.getAddressSpace(name);
@ -1399,7 +1393,10 @@ public class VarnodeContext implements ProcessorContext {
regSpace = ((OffsetAddressFactory) addrFactory).createNewOffsetSpace(name);
}
if (regSpace == null) {
Msg.error(this, "VarnodeContext: out of address spaces for: " + name);
if (!hitMaxAddressSpaces) {
Msg.error(this, "VarnodeContext: out of address spaces at @" + currentAddress +" for: " + name);
hitMaxAddressSpaces = true;
}
return BAD_SPACE_ID_VALUE;
}
spaceID = regSpace.getSpaceID();
@ -1762,13 +1759,18 @@ class OffsetAddressFactory extends DefaultAddressFactory {
}
}
// Maximum space ID used to create spaces
private int curMaxID = 0;
private int getNextUniqueID() {
int maxID = 0;
AddressSpace[] spaces = getAllAddressSpaces();
for (AddressSpace space : spaces) {
maxID = Math.max(maxID, space.getUnique());
if (curMaxID == 0) {
AddressSpace[] spaces = getAllAddressSpaces();
for (AddressSpace space : spaces) {
curMaxID = Math.max(curMaxID, space.getUnique());
}
}
return maxID + 1;
curMaxID += 1;
return curMaxID;
}
/**