changes from review

This commit is contained in:
ghidravore 2020-06-02 12:58:36 -04:00
parent e3aebe3adb
commit ca58264d65
6 changed files with 41 additions and 277 deletions

View file

@ -162,11 +162,8 @@ class OverlaySpaceAdapterDB {
}
}
}
if (map.size() != 0) {
for (OverlayAddressSpace space : map.values()) {
factory.removeOverlaySpace(space.getName());
}
map.clear();
for (OverlayAddressSpace space : map.values()) {
factory.removeOverlaySpace(space.getName());
}
}

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +15,11 @@
*/
package ghidra.program.database.properties;
import java.io.IOException;
import java.util.NoSuchElementException;
import db.*;
import db.util.ErrorHandler;
import ghidra.program.database.map.*;
import ghidra.program.database.util.DatabaseTableUtils;
import ghidra.program.model.address.*;
@ -28,12 +32,6 @@ import ghidra.util.exception.*;
import ghidra.util.task.TaskMonitor;
import ghidra.util.task.TaskMonitorAdapter;
import java.io.IOException;
import java.util.NoSuchElementException;
import db.*;
import db.util.ErrorHandler;
/**
* Abstract class which defines a map containing properties over a set of addresses.
* The map is stored within a database table.
@ -137,8 +135,9 @@ public abstract class PropertyMapDB implements PropertyMap {
monitor.setProgress(++count);
}
if (tempTable == null)
if (tempTable == null) {
return;
}
// Remove old table
dbHandle.deleteTable(getTableName());
@ -192,6 +191,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#getName()
*/
@Override
public String getName() {
return name;
}
@ -221,7 +221,7 @@ public abstract class PropertyMapDB implements PropertyMap {
lock.acquire();
try {
if (propertyTable != null) {
cache.clear();
cache = null;
dbHandle.deleteTable(getTableName());
propertyTable = null;
}
@ -234,6 +234,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#intersects(ghidra.program.model.address.Address, ghidra.program.model.address.Address)
*/
@Override
public boolean intersects(Address startAddr, Address endAddr) {
if (propertyTable == null) {
return false;
@ -252,6 +253,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#intersects(ghidra.program.model.address.AddressSetView)
*/
@Override
public boolean intersects(AddressSetView set) {
if (propertyTable == null) {
return false;
@ -270,6 +272,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#removeRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address)
*/
@Override
public boolean removeRange(Address startAddr, Address endAddr) {
if (propertyTable == null) {
return false;
@ -277,7 +280,7 @@ public abstract class PropertyMapDB implements PropertyMap {
lock.acquire();
try {
if (AddressRecordDeleter.deleteRecords(propertyTable, addrMap, startAddr, endAddr)) {
cache.clear();
cache = new ObjectCache(DEFAULT_CACHE_SIZE);
return true;
}
}
@ -293,6 +296,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#remove(ghidra.program.model.address.Address)
*/
@Override
public boolean remove(Address addr) {
if (propertyTable == null) {
return false;
@ -317,6 +321,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#hasProperty(ghidra.program.model.address.Address)
*/
@Override
public boolean hasProperty(Address addr) {
if (propertyTable == null) {
return false;
@ -341,6 +346,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#getNextPropertyAddress(ghidra.program.model.address.Address)
*/
@Override
public Address getNextPropertyAddress(Address addr) {
if (propertyTable == null) {
return null;
@ -360,6 +366,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#getPreviousPropertyAddress(ghidra.program.model.address.Address)
*/
@Override
public Address getPreviousPropertyAddress(Address addr) {
if (propertyTable == null) {
return null;
@ -379,6 +386,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#getFirstPropertyAddress()
*/
@Override
public Address getFirstPropertyAddress() {
if (propertyTable == null) {
return null;
@ -398,6 +406,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#getLastPropertyAddress()
*/
@Override
public Address getLastPropertyAddress() {
if (propertyTable == null) {
return null;
@ -419,6 +428,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#getSize()
*/
@Override
public int getSize() {
return propertyTable != null ? propertyTable.getRecordCount() : 0;
}
@ -434,8 +444,9 @@ public abstract class PropertyMapDB implements PropertyMap {
public AddressKeyIterator getAddressKeyIterator(AddressSetView set, boolean atStart)
throws IOException {
if (propertyTable == null)
if (propertyTable == null) {
return new AddressKeyIterator();
}
if (atStart) {
return new AddressKeyIterator(propertyTable, addrMap, set, set.getMinAddress(), true);
}
@ -452,8 +463,9 @@ public abstract class PropertyMapDB implements PropertyMap {
public AddressKeyIterator getAddressKeyIterator(Address start, boolean before)
throws IOException {
if (propertyTable == null)
if (propertyTable == null) {
return new AddressKeyIterator();
}
return new AddressKeyIterator(propertyTable, addrMap, start, before);
}
@ -469,8 +481,9 @@ public abstract class PropertyMapDB implements PropertyMap {
public AddressKeyIterator getAddressKeyIterator(Address start, Address end, boolean atStart)
throws IOException {
if (propertyTable == null)
if (propertyTable == null) {
return new AddressKeyIterator();
}
if (atStart) {
return new AddressKeyIterator(propertyTable, addrMap, start, end, start, true);
}
@ -480,6 +493,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#getPropertyIterator(ghidra.program.model.address.Address, ghidra.program.model.address.Address)
*/
@Override
public AddressIterator getPropertyIterator(Address start, Address end) {
AddressKeyIterator keyIter = null;
try {
@ -494,6 +508,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#getPropertyIterator(ghidra.program.model.address.Address, ghidra.program.model.address.Address, boolean)
*/
@Override
public AddressIterator getPropertyIterator(Address start, Address end, boolean forward) {
AddressKeyIterator keyIter = null;
try {
@ -508,6 +523,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#getPropertyIterator()
*/
@Override
public AddressIterator getPropertyIterator() {
if (propertyTable == null) {
return new EmptyAddressIterator();
@ -525,6 +541,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#getPropertyIterator(ghidra.program.model.address.AddressSetView)
*/
@Override
public AddressIterator getPropertyIterator(AddressSetView asv) {
if (propertyTable == null) {
return new EmptyAddressIterator();
@ -543,6 +560,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#getPropertyIterator(ghidra.program.model.address.AddressSetView, boolean)
*/
@Override
public AddressIterator getPropertyIterator(AddressSetView asv, boolean forward) {
if (propertyTable == null) {
return new EmptyAddressIterator();
@ -567,6 +585,7 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#getPropertyIterator(ghidra.program.model.address.Address, boolean)
*/
@Override
public AddressIterator getPropertyIterator(Address start, boolean forward) {
if (propertyTable == null) {
return new EmptyAddressIterator();
@ -588,7 +607,7 @@ public abstract class PropertyMapDB implements PropertyMap {
lock.acquire();
try {
propertyTable = dbHandle.getTable(getTableName());
cache.clear();
cache = new ObjectCache(DEFAULT_CACHE_SIZE);
}
finally {
lock.release();
@ -599,10 +618,11 @@ public abstract class PropertyMapDB implements PropertyMap {
/**
* @see ghidra.program.model.util.PropertyMap#moveRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address, ghidra.program.model.address.Address)
*/
@Override
public void moveRange(Address start, Address end, Address newStart) {
lock.acquire();
try {
cache.clear();
cache = new ObjectCache(DEFAULT_CACHE_SIZE);
if (propertyTable != null) {
try {
DatabaseTableUtils.updateAddressKey(propertyTable, addrMap, start, end,