mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Test fixes
This commit is contained in:
parent
4b01baeebe
commit
7b875023ad
4 changed files with 33 additions and 25 deletions
|
@ -47,7 +47,7 @@ public class FindDataTypesByNameAction extends DockingAction {
|
|||
public void actionPerformed(ActionContext context) {
|
||||
|
||||
InputDialog inputDialog =
|
||||
new InputDialog("Find Data Types", "Please enter the search string: ");
|
||||
new InputDialog(NAME, "Please enter the search string: ");
|
||||
PluginTool tool = plugin.getTool();
|
||||
tool.showDialog(inputDialog);
|
||||
if (inputDialog.isCanceled()) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import ghidra.program.model.mem.*;
|
|||
import ghidra.program.model.scalar.Scalar;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.program.util.*;
|
||||
import ghidra.util.StringUtilities;
|
||||
|
||||
/**
|
||||
* Utility class with methods to get comment information that can be displayed in the
|
||||
|
@ -520,26 +521,7 @@ public class DisplayableEol {
|
|||
}
|
||||
|
||||
Address address = memRefs[i].getToAddress();
|
||||
String repeatableComment = listing.getComment(CodeUnit.REPEATABLE_COMMENT, address);
|
||||
if (repeatableComment != null) {
|
||||
set.add(new RefRepeatComment(address, new String[] { repeatableComment }));
|
||||
}
|
||||
|
||||
CodeUnit cu = listing.getCodeUnitAt(address);
|
||||
if (cu == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] comment = new String[0];
|
||||
Function func = listing.getFunctionAt(address);
|
||||
if (func != null) {
|
||||
comment = func.getRepeatableCommentAsArray();
|
||||
}
|
||||
|
||||
if (comment.length == 0) {
|
||||
comment = cu.getCommentAsArray(CodeUnit.REPEATABLE_COMMENT);
|
||||
}
|
||||
|
||||
String[] comment = getComment(listing, address);
|
||||
if (comment != null && comment.length > 0) {
|
||||
set.add(new RefRepeatComment(address, comment));
|
||||
totalCommentsFound++;
|
||||
|
@ -549,6 +531,27 @@ public class DisplayableEol {
|
|||
return set.toArray(new RefRepeatComment[set.size()]);
|
||||
}
|
||||
|
||||
private String[] getComment(Listing listing, Address address) {
|
||||
|
||||
// prefer listing comments first since there may not be a code unit at this address
|
||||
String repeatableComment = listing.getComment(CodeUnit.REPEATABLE_COMMENT, address);
|
||||
if (repeatableComment != null) {
|
||||
return StringUtilities.toLines(repeatableComment);
|
||||
}
|
||||
|
||||
CodeUnit cu = listing.getCodeUnitAt(address);
|
||||
if (cu == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Function func = listing.getFunctionAt(address);
|
||||
if (func != null) {
|
||||
return func.getRepeatableCommentAsArray();
|
||||
}
|
||||
|
||||
return cu.getCommentAsArray(CodeUnit.REPEATABLE_COMMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all the comments
|
||||
* @return the comments
|
||||
|
|
|
@ -75,4 +75,9 @@ public class RefRepeatComment {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Arrays.toString(commentLines);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
|
|||
assertEquals(options1, options2);
|
||||
|
||||
options1.setString("foo", "foo1");
|
||||
assertTrue(!options1.equals(options2));
|
||||
assertFalse(options1.equals(options2));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -699,7 +699,7 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
|
|||
cb.updateNow();
|
||||
btf = (ListingTextField) cb.getCurrentField();
|
||||
assertEquals(12, getNumberOfLines(btf));
|
||||
assertTrue(!"; ".equals(btf.getFieldElement(1, 0).getText()));
|
||||
assertFalse("; ".equals(btf.getFieldElement(1, 0).getText()));
|
||||
assertEquals("01003fa1", btf.getFieldElement(11, 4).getText());
|
||||
assertEquals("Mem ref line1.", btf.getFieldElement(11, 11).getText());
|
||||
|
||||
|
@ -707,7 +707,7 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
|
|||
cb.updateNow();
|
||||
btf = (ListingTextField) cb.getCurrentField();
|
||||
assertEquals(11, getNumberOfLines(btf));
|
||||
assertTrue(!"; ".equals(btf.getFieldElement(1, 0).getText()));
|
||||
assertFalse("; ".equals(btf.getFieldElement(1, 0).getText()));
|
||||
|
||||
cb.goToField(callAddress, "EOL Comment", 9, 4);
|
||||
btf = (ListingTextField) cb.getCurrentField();
|
||||
|
@ -730,7 +730,7 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
|
|||
cb.updateNow();
|
||||
waitForPostedSwingRunnables();
|
||||
|
||||
assertTrue(!cb.goToField(addr("0x10048a3"), "Label", 0, 0));
|
||||
assertFalse(cb.goToField(addr("0x10048a3"), "Label", 0, 0));
|
||||
options.setBoolean(names.get(0), true);
|
||||
cb.updateNow();
|
||||
waitForPostedSwingRunnables();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue