diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/ListingDisplaySearcher.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/ListingDisplaySearcher.java index 5fd6335e87..77a05d2995 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/ListingDisplaySearcher.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/ListingDisplaySearcher.java @@ -38,19 +38,19 @@ import ghidra.util.UserSearchUtils; import ghidra.util.task.TaskMonitor; /** - * This class attempts to search for text as it is rendered on the screen. This in in - * contrast to the Program Database Searcher which searches the database. This is - * needed because some information on the screen is rendered "on the fly" and not - * stored in the database. This searcher is much slower, but delivers + * This class attempts to search for text as it is rendered on the screen. This in in + * contrast to the Program Database Searcher which searches the database. This is + * needed because some information on the screen is rendered "on the fly" and not + * stored in the database. This searcher is much slower, but delivers * results that are in-line with what the user sees. *
- * The search is performed in two steps. First it uses Instruction and Data iterators to
+ * The search is performed in two steps. First it uses Instruction and Data iterators to
* find possible addresses where where information would be rendered. Then for each of those
* addresses, it uses the code browsers rendering engine to produce a textual representation
* for that address. The textual representation also maintains information about the field
* that generated it so that the search can be constrained to specific fields such as the
- * label or comment field.
- *
+ * label or comment field.
+ *
*/
class ListingDisplaySearcher implements Searcher {
@@ -80,7 +80,7 @@ class ListingDisplaySearcher implements Searcher {
/**
* Constructor
- * @param codeViewerService service to get the Layouts
+ * @param tool the tool
* @param program current program
* @param startLocation location from where to begin searching
* @param set address set; may be null
@@ -143,7 +143,7 @@ class ListingDisplaySearcher implements Searcher {
private AddressIterator[] getSearchIterators() {
//
// This code used to get specific iterators for labels, comments, etc, depending
- // on what options were selected (which is the fastest way to search). However,
+ // on what options were selected (which is the fastest way to search). However,
// this approach missed auto comments and structure comments.
//
// The idea now is to get iterators that will return addresses for every defined
@@ -168,16 +168,13 @@ class ListingDisplaySearcher implements Searcher {
iterators.add(listing.getCommentAddressIterator(searchAddresses, options.isForward()));
}
if (options.searchLabels() || all) {
- SymbolIterator labels = program.getSymbolTable().getPrimarySymbolIterator(
- searchAddresses, options.isForward());
+ SymbolIterator labels = program.getSymbolTable()
+ .getPrimarySymbolIterator(searchAddresses, options.isForward());
iterators.add(new LabelSearchAddressIterator(labels));
}
return iterators.toArray(new AddressIterator[iterators.size()]);
}
- /**
- * Get the next location.
- */
ProgramLocation next() {
if (locationList.size() == 0) {
findNext();
@@ -318,8 +315,8 @@ class ListingDisplaySearcher implements Searcher {
}
private void searchForward() {
- for (int i =
- currentFieldIndex; i < currentLayout.getNumFields(); i++, currentFieldIndex++) {
+ for (int i = currentFieldIndex; i < currentLayout
+ .getNumFields(); i++, currentFieldIndex++) {
int matchingFieldCount = findLocations(i);
if (matchingFieldCount != 0) {
currentFieldIndex += matchingFieldCount;
@@ -355,7 +352,7 @@ class ListingDisplaySearcher implements Searcher {
int fieldCount = 1; // we always match on one field, unless it is the Mnemonic/Operand combo
- // if field is the Mnemonic, and instructions or data are
+ // if field is the Mnemonic, and instructions or data are
// being searched, get the next field as well
boolean isMnemonic = fieldName.equals(MnemonicFieldFactory.FIELD_NAME);
boolean isInstructionsOrData =
@@ -422,13 +419,6 @@ class ListingDisplaySearcher implements Searcher {
isInitialized = true;
}
- /**
- * Sets the currentFieldIndex of the field that corresponds to the
- * startLoc program location
- * @param field
- * @param fieldIndex
- * @return true if this field corresponds to the startLoc program location
- */
private boolean getFieldForLocation(ListingField field, int fieldIndex) {
FieldFactory ff = field.getFieldFactory();
FieldLocation floc = ff.getFieldLocation(field, BigInteger.ZERO, fieldIndex, startLocation);
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/quicksearch/ProgramDatabaseSearchIteratorTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/quicksearch/ProgramDatabaseSearchIteratorTest.java
index d43562eb3f..6f3c991190 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/quicksearch/ProgramDatabaseSearchIteratorTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/quicksearch/ProgramDatabaseSearchIteratorTest.java
@@ -43,7 +43,6 @@ import ghidra.program.util.*;
import ghidra.test.*;
import ghidra.util.UserSearchUtils;
import ghidra.util.task.TaskMonitor;
-import junit.framework.TestCase;
public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedIntegrationTest {
@@ -55,10 +54,6 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
private ToyProgramBuilder builder;
private TaskMonitor monitor = TaskMonitor.DUMMY;
- public ProgramDatabaseSearchIteratorTest() {
- super();
- }
-
private void createIMM(long address) throws MemoryAccessException {
builder.addBytesMoveImmediate(address, (short) 5);
builder.disassemble(Long.toHexString(address), 2);
@@ -91,7 +86,7 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
createFallThru(0x1005f50);
createIMM(0x1005f41);
createFallThru(0x1005ff0);
-// LAB_010018b3
+
createIMM(0x10018b3);
builder.createMemoryReference("0x1005f41", "0x10018b3", RefType.COMPUTED_JUMP,
SourceType.ANALYSIS);
@@ -109,9 +104,6 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
env.showTool();
}
- /**
- * @see TestCase#tearDown()
- */
@After
public void tearDown() throws Exception {
env.dispose();
@@ -167,7 +159,6 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
assertNotNull(loc);
assertEquals(getAddr(0x100595f), loc.getAddress());
loc = getNextMatch(searcher);
- System.out.println(loc);
assertEquals(getAddr(0x100595f), loc.getAddress());
loc = getNextMatch(searcher);
assertNotNull(loc);
@@ -230,9 +221,9 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
Pattern pattern = UserSearchUtils.createSearchPattern("immxx", false);
ProgramLocation startLocation = new ProgramLocation(program, program.getMinAddress());
CodeUnitFormat format = new CodeUnitFormat(ShowBlockName.NEVER, ShowNamespace.NEVER);
- ProgramDatabaseFieldSearcher searcher =
- InstructionMnemonicOperandFieldSearcher.createInstructionMnemonicAndOperandFieldSearcher(
- program, startLocation, null, true, pattern, format);
+ ProgramDatabaseFieldSearcher searcher = InstructionMnemonicOperandFieldSearcher
+ .createInstructionMnemonicAndOperandFieldSearcher(program, startLocation, null,
+ true, pattern, format);
currentAddress = searcher.getNextSignificantAddress(null);
assertNull(getNextMatch(searcher));
@@ -244,18 +235,18 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
Pattern pattern = UserSearchUtils.createSearchPattern("imm", true);
ProgramLocation startLocation = new ProgramLocation(program, program.getMinAddress());
- ProgramDatabaseFieldSearcher searcher =
- InstructionMnemonicOperandFieldSearcher.createInstructionMnemonicAndOperandFieldSearcher(
- program, startLocation, null, true, pattern, CodeUnitFormat.DEFAULT);
+ ProgramDatabaseFieldSearcher searcher = InstructionMnemonicOperandFieldSearcher
+ .createInstructionMnemonicAndOperandFieldSearcher(program, startLocation, null,
+ true, pattern, CodeUnitFormat.DEFAULT);
currentAddress = searcher.getNextSignificantAddress(null);
ProgramLocation nextMatch = getNextMatch(searcher);
assertNotNull(nextMatch);
startLocation = new ProgramLocation(program, getAddr(0x1001000));
- searcher =
- InstructionMnemonicOperandFieldSearcher.createInstructionMnemonicAndOperandFieldSearcher(
- program, startLocation, null, true, pattern, CodeUnitFormat.DEFAULT);
+ searcher = InstructionMnemonicOperandFieldSearcher
+ .createInstructionMnemonicAndOperandFieldSearcher(program, startLocation, null,
+ true, pattern, CodeUnitFormat.DEFAULT);
currentAddress = searcher.getNextSignificantAddress(null);
nextMatch = getNextMatch(searcher);
@@ -274,9 +265,9 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
pattern = UserSearchUtils.createSearchPattern("imm", false);
startLocation = new ProgramLocation(program, getAddr(0x1005f53));
- searcher =
- InstructionMnemonicOperandFieldSearcher.createInstructionMnemonicAndOperandFieldSearcher(
- program, startLocation, null, false, pattern, CodeUnitFormat.DEFAULT);
+ searcher = InstructionMnemonicOperandFieldSearcher
+ .createInstructionMnemonicAndOperandFieldSearcher(program, startLocation, null,
+ false, pattern, CodeUnitFormat.DEFAULT);
currentAddress = searcher.getNextSignificantAddress(null);
nextMatch = getNextMatch(searcher);
@@ -285,9 +276,9 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
startLocation = new MnemonicFieldLocation(program,
program.getMinAddress().getNewAddress(0x1005f53), null, null, "imm", 2);
- searcher =
- InstructionMnemonicOperandFieldSearcher.createInstructionMnemonicAndOperandFieldSearcher(
- program, startLocation, null, false, pattern, CodeUnitFormat.DEFAULT);
+ searcher = InstructionMnemonicOperandFieldSearcher
+ .createInstructionMnemonicAndOperandFieldSearcher(program, startLocation, null,
+ false, pattern, CodeUnitFormat.DEFAULT);
currentAddress = searcher.getNextSignificantAddress(null);
nextMatch = getNextMatch(searcher);
@@ -416,7 +407,7 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
addPreComment(0x1001960L, "PreComment: PUSH Hit");
addPostComment(0x1001960L, "Post: PUSH hit");
- // Search for
+ // Search for
SearchOptions options = new SearchOptions("PUSH", true, true, true, true, true, true, true,
true, true, true, false, false);
ProgramLocation startLoc = new ProgramLocation(program, getAddr(0x1001950));
@@ -465,7 +456,7 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
int txId = program.startTransaction("Search Test");
try {
- // add data
+ // add data
program.getListing().createData(getAddr(0x1001955L), s, s.getLength());
}
finally {
@@ -539,8 +530,10 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
TaskMonitor taskMonitor) {
int count = 0;
ArrayList