Skip to content

Ghidra is a software reverse engineering (SRE) framework

Test fixes

dragonmacher7b875023ad36
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindDataTypesByNameAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindDataTypesByNameAction.java
index 3723df0b56..6afa8156a3 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindDataTypesByNameAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindDataTypesByNameAction.java
@@ -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()) {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/DisplayableEol.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/DisplayableEol.java
index a3fee5df3d..10c14fe70a 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/DisplayableEol.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/DisplayableEol.java
@@ -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
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/RefRepeatComment.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/RefRepeatComment.java
index cd42422722..26185d1c91 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/RefRepeatComment.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/RefRepeatComment.java
@@ -75,4 +75,9 @@ public class RefRepeatComment {
return true;
}
+ @Override
+ public String toString() {
+ return Arrays.toString(commentLines);
+ }
+
}
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/codebrowser/CodeBrowserOptionsTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/codebrowser/CodeBrowserOptionsTest.java
index 28b84c3078..9105c35223 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/codebrowser/CodeBrowserOptionsTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/codebrowser/CodeBrowserOptionsTest.java
@@ -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();