mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-25 13:42:06 +00:00
GP-3605 Only log error message once and improve efficiency of allocating
new spaces
This commit is contained in:
parent
a7063c672e
commit
365f526877
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user