mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-18 00:20:10 +00:00
GT-2872 - Search - review fixes
This commit is contained in:
parent
96788aa7fc
commit
8a7a58a297
@ -55,10 +55,14 @@ import ghidra.util.task.TaskMonitor;
|
||||
*/
|
||||
|
||||
public class ProgramDatabaseSearcher implements Searcher {
|
||||
|
||||
private List<ProgramDatabaseFieldSearcher> searchers = new ArrayList<>();
|
||||
private Address currentAddress;
|
||||
private boolean isForward;
|
||||
private SearchOptions searchOptions;
|
||||
|
||||
private long totalSearchCount;
|
||||
private AddressSet remainingAddresses;
|
||||
private TaskMonitor monitor;
|
||||
|
||||
public ProgramDatabaseSearcher(ServiceProvider serviceProvider, Program program,
|
||||
@ -74,7 +78,7 @@ public class ProgramDatabaseSearcher implements Searcher {
|
||||
|
||||
initialize(serviceProvider, program, startLoc, set, options);
|
||||
currentAddress = findNextSignificantAddress();
|
||||
monitor.initialize(set.getNumAddresses());
|
||||
monitor.initialize(totalSearchCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -105,8 +109,22 @@ public class ProgramDatabaseSearcher implements Searcher {
|
||||
return; // finished
|
||||
}
|
||||
|
||||
int diff = (int) Math.abs(newAddress.subtract(lastAddress));
|
||||
monitor.incrementProgress(diff);
|
||||
AddressSpace lastSpace = lastAddress.getAddressSpace();
|
||||
AddressSpace newSpace = newAddress.getAddressSpace();
|
||||
if (!lastSpace.equals(newSpace)) {
|
||||
remainingAddresses.delete(lastSpace.getMinAddress(), lastSpace.getMaxAddress());
|
||||
}
|
||||
|
||||
Address from = newSpace.getMinAddress();
|
||||
Address to = newAddress.subtract(1);
|
||||
if (!isForward) {
|
||||
to = newSpace.getMaxAddress();
|
||||
from = newAddress.add(1);
|
||||
}
|
||||
|
||||
remainingAddresses.delete(from, to);
|
||||
long progress = totalSearchCount - remainingAddresses.getNumAddresses();
|
||||
monitor.setProgress(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -129,6 +147,7 @@ public class ProgramDatabaseSearcher implements Searcher {
|
||||
nextAddress = isForward ? getMin(nextAddress, nextAddressToCheck)
|
||||
: getMax(nextAddress, nextAddressToCheck);
|
||||
}
|
||||
|
||||
return nextAddress;
|
||||
}
|
||||
|
||||
@ -160,6 +179,8 @@ public class ProgramDatabaseSearcher implements Searcher {
|
||||
|
||||
AddressSetView trimmedSet = adjustSearchSet(program, start, view, forward);
|
||||
ProgramLocation adjustedStart = adjustStartLocation(program, start, trimmedSet, forward);
|
||||
remainingAddresses = new AddressSet(trimmedSet);
|
||||
totalSearchCount = trimmedSet.getNumAddresses();
|
||||
|
||||
Pattern pattern =
|
||||
UserSearchUtils.createSearchPattern(options.getText(), options.isCaseSensitive());
|
||||
|
@ -165,12 +165,11 @@ public interface Address extends Comparable<Address> {
|
||||
public int getSize();
|
||||
|
||||
/**
|
||||
* Calculates the displacement between two addresses (<code>this -
|
||||
* addr</code>).
|
||||
*
|
||||
* @param addr the Address to subtract from <code>this</code> address.
|
||||
* @return the difference. (thisAddress.offset - thatAddress.offset
|
||||
* Calculates the displacement between two addresses (<code>this - addr</code>)
|
||||
*
|
||||
* @param addr the Address to subtract from <code>this</code> address
|
||||
* @return the difference (thisAddress.offset - thatAddress.offset)
|
||||
* @throws IllegalArgumentException if the two addresses are not in the same address space
|
||||
*/
|
||||
public long subtract(Address addr);
|
||||
|
||||
|
@ -29,7 +29,7 @@ import ghidra.util.datastruct.RedBlackTree;
|
||||
|
||||
public class AddressSet implements AddressSetView {
|
||||
private final static double LOGBASE2 = Math.log(2);
|
||||
private RedBlackTree<Address, Address> rbTree = new RedBlackTree<Address, Address>();
|
||||
private RedBlackTree<Address, Address> rbTree = new RedBlackTree<>();
|
||||
private RedBlackEntry<Address, Address> lastNode;
|
||||
private long addressCount = 0;
|
||||
|
||||
@ -282,7 +282,7 @@ public class AddressSet implements AddressSetView {
|
||||
/**
|
||||
* Deletes a range of addresses from this set
|
||||
* @param start the starting address of the range to be removed
|
||||
* @param end the ending address of the range to be removed
|
||||
* @param end the ending address of the range to be removed (inclusive)
|
||||
*/
|
||||
public final void delete(Address start, Address end) {
|
||||
if (start.compareTo(end) > 0) {
|
||||
@ -403,7 +403,7 @@ public class AddressSet implements AddressSetView {
|
||||
* @return a list of the AddressRanges in this set.
|
||||
*/
|
||||
public List<AddressRange> toList() {
|
||||
ArrayList<AddressRange> list = new ArrayList<AddressRange>();
|
||||
ArrayList<AddressRange> list = new ArrayList<>();
|
||||
for (AddressRange range : this) {
|
||||
list.add(range);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user