mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Merge remote-tracking branch 'origin/GP-752-dragonmacher-auto-comments-option'
This commit is contained in:
commit
fdf2df7981
4 changed files with 112 additions and 26 deletions
|
@ -36,7 +36,6 @@ import ghidra.program.util.*;
|
||||||
*/
|
*/
|
||||||
public class DisplayableEol {
|
public class DisplayableEol {
|
||||||
|
|
||||||
private static final String VAR_ARGS = "...";
|
|
||||||
private static final String POINTER_ARROW = "-> ";
|
private static final String POINTER_ARROW = "-> ";
|
||||||
|
|
||||||
public static final int MY_EOLS = 0;
|
public static final int MY_EOLS = 0;
|
||||||
|
@ -48,19 +47,16 @@ public class DisplayableEol {
|
||||||
private boolean alwaysShowRepeatable = false;
|
private boolean alwaysShowRepeatable = false;
|
||||||
private boolean alwaysShowRefRepeats = false;
|
private boolean alwaysShowRefRepeats = false;
|
||||||
private boolean alwaysShowAutomatic = false;
|
private boolean alwaysShowAutomatic = false;
|
||||||
|
private boolean showAutomaticFunctions;
|
||||||
private boolean operandsFollowPointerRefs = false;
|
private boolean operandsFollowPointerRefs = false;
|
||||||
private int maxDisplayLines;
|
private int maxDisplayLines;
|
||||||
private int totalCommentsFound;
|
private int totalCommentsFound;
|
||||||
|
|
||||||
private boolean useAbbreviatedAutomatic;
|
private boolean useAbbreviatedAutomatic;
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new DisplayableEol.
|
|
||||||
* @param cu code unit that may have end of line or repeatable comments.
|
|
||||||
*/
|
|
||||||
public DisplayableEol(CodeUnit cu, boolean alwaysShowRepeatable, boolean alwaysShowRefRepeats,
|
public DisplayableEol(CodeUnit cu, boolean alwaysShowRepeatable, boolean alwaysShowRefRepeats,
|
||||||
boolean alwaysShowAutomatic, boolean operandsFollowPointerRefs, int maxDisplayLines,
|
boolean alwaysShowAutomatic, boolean operandsFollowPointerRefs, int maxDisplayLines,
|
||||||
boolean useAbbreviatedAutomatic) {
|
boolean useAbbreviatedAutomatic, boolean showAutomaticFunctions) {
|
||||||
this.codeUnit = cu;
|
this.codeUnit = cu;
|
||||||
this.alwaysShowRepeatable = alwaysShowRepeatable;
|
this.alwaysShowRepeatable = alwaysShowRepeatable;
|
||||||
this.alwaysShowRefRepeats = alwaysShowRefRepeats;
|
this.alwaysShowRefRepeats = alwaysShowRefRepeats;
|
||||||
|
@ -68,6 +64,7 @@ public class DisplayableEol {
|
||||||
this.operandsFollowPointerRefs = operandsFollowPointerRefs;
|
this.operandsFollowPointerRefs = operandsFollowPointerRefs;
|
||||||
this.maxDisplayLines = maxDisplayLines;
|
this.maxDisplayLines = maxDisplayLines;
|
||||||
this.useAbbreviatedAutomatic = useAbbreviatedAutomatic;
|
this.useAbbreviatedAutomatic = useAbbreviatedAutomatic;
|
||||||
|
this.showAutomaticFunctions = showAutomaticFunctions;
|
||||||
|
|
||||||
initComments();
|
initComments();
|
||||||
}
|
}
|
||||||
|
@ -118,7 +115,8 @@ public class DisplayableEol {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the associated code unit has an end of line comment.
|
* Return whether the associated code unit has an end of line comment
|
||||||
|
* @return whether the associated code unit has an end of line comment
|
||||||
*/
|
*/
|
||||||
public boolean hasEOL() {
|
public boolean hasEOL() {
|
||||||
return (displayCommentArrays[MY_EOLS] != null) &&
|
return (displayCommentArrays[MY_EOLS] != null) &&
|
||||||
|
@ -126,7 +124,8 @@ public class DisplayableEol {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the associated code unit has a repeatable comment.
|
* Return whether the associated code unit has a repeatable comment
|
||||||
|
* @return whether the associated code unit has a repeatable comment
|
||||||
*/
|
*/
|
||||||
public boolean hasRepeatable() {
|
public boolean hasRepeatable() {
|
||||||
return (displayCommentArrays[MY_REPEATABLES] != null) &&
|
return (displayCommentArrays[MY_REPEATABLES] != null) &&
|
||||||
|
@ -135,7 +134,9 @@ public class DisplayableEol {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether any memory reference from this code unit has a repeatable
|
* Return whether any memory reference from this code unit has a repeatable
|
||||||
* comment at the reference's to address.
|
* comment at the reference's to address
|
||||||
|
* @return whether any memory reference from this code unit has a repeatable
|
||||||
|
* comment at the reference's to address
|
||||||
*/
|
*/
|
||||||
public boolean hasReferencedRepeatable() {
|
public boolean hasReferencedRepeatable() {
|
||||||
return (displayCommentArrays[REF_REPEATABLES] != null) &&
|
return (displayCommentArrays[REF_REPEATABLES] != null) &&
|
||||||
|
@ -143,10 +144,10 @@ public class DisplayableEol {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether this code unit has an automatic comment.
|
* Return whether this code unit has an automatic comment. For example, a memory reference
|
||||||
* (i.e. any memory reference from this code unit has a
|
* from this code unit has a function defined at the reference's to address, or if the to
|
||||||
* function defined at the reference's to address, or if the to
|
* address is a pointer.
|
||||||
* address is a pointer.)
|
* @return whether this code unit has an automatic comment
|
||||||
*/
|
*/
|
||||||
public boolean hasAutomatic() {
|
public boolean hasAutomatic() {
|
||||||
return (displayCommentArrays[MY_AUTOMATIC] != null) &&
|
return (displayCommentArrays[MY_AUTOMATIC] != null) &&
|
||||||
|
@ -367,6 +368,10 @@ public class DisplayableEol {
|
||||||
private boolean handleDirectFlow(Set<String> set, Reference reference, Program program,
|
private boolean handleDirectFlow(Set<String> set, Reference reference, Program program,
|
||||||
Address toAddr) {
|
Address toAddr) {
|
||||||
|
|
||||||
|
if (!showAutomaticFunctions) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
RefType type = reference.getReferenceType();
|
RefType type = reference.getReferenceType();
|
||||||
if (!type.isFlow()) {
|
if (!type.isFlow()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -537,7 +542,8 @@ public class DisplayableEol {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all the comments (End of Line, Repeatable, Referenced Repeatables, and Referenced Data).
|
* Return all the comments
|
||||||
|
* @return the comments
|
||||||
*/
|
*/
|
||||||
public String[] getComments() {
|
public String[] getComments() {
|
||||||
ArrayList<String> list = new ArrayList<>();
|
ArrayList<String> list = new ArrayList<>();
|
||||||
|
|
|
@ -290,7 +290,7 @@ class ProgramTextWriter {
|
||||||
|
|
||||||
if (options.isShowComments()) {
|
if (options.isShowComments()) {
|
||||||
DisplayableEol displayableEol = new DisplayableEol(currentCodeUnit, false, false,
|
DisplayableEol displayableEol = new DisplayableEol(currentCodeUnit, false, false,
|
||||||
false, true, 6 /* arbitrary! */, true);
|
false, true, 6 /* arbitrary! */, true, true);
|
||||||
String[] eol = displayableEol.getComments();
|
String[] eol = displayableEol.getComments();
|
||||||
if (eol != null && eol.length > 0) {
|
if (eol != null && eol.length > 0) {
|
||||||
len = options.getAddrWidth() + options.getBytesWidth() +
|
len = options.getAddrWidth() + options.getBytesWidth() +
|
||||||
|
@ -618,7 +618,9 @@ class ProgramTextWriter {
|
||||||
|
|
||||||
if (options.isHTML()) {
|
if (options.isHTML()) {
|
||||||
Reference ref =
|
Reference ref =
|
||||||
cu.getProgram().getReferenceManager().getPrimaryReferenceFrom(cuAddress,
|
cu.getProgram()
|
||||||
|
.getReferenceManager()
|
||||||
|
.getPrimaryReferenceFrom(cuAddress,
|
||||||
i);
|
i);
|
||||||
addReferenceLinkedText(ref, opReps[i], true);
|
addReferenceLinkedText(ref, opReps[i], true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,8 @@ public class EolCommentFieldFactory extends FieldFactory {
|
||||||
GROUP_TITLE + Options.DELIMITER + "Always Show the Automatic Comment";
|
GROUP_TITLE + Options.DELIMITER + "Always Show the Automatic Comment";
|
||||||
public static final String USE_ABBREVIATED_AUTOMITIC_COMMENT_MSG =
|
public static final String USE_ABBREVIATED_AUTOMITIC_COMMENT_MSG =
|
||||||
GROUP_TITLE + Options.DELIMITER + "Use Abbreviated Automatic Comments";
|
GROUP_TITLE + Options.DELIMITER + "Use Abbreviated Automatic Comments";
|
||||||
|
public static final String SHOW_FUNCTION_AUTOMITIC_COMMENT_MSG =
|
||||||
|
GROUP_TITLE + Options.DELIMITER + "Show Function Reference Automatic Comments";
|
||||||
public final static String ENABLE_PREPEND_REF_ADDRESS_MSG =
|
public final static String ENABLE_PREPEND_REF_ADDRESS_MSG =
|
||||||
GROUP_TITLE + Options.DELIMITER + "Prepend the Address to Each Referenced Comment";
|
GROUP_TITLE + Options.DELIMITER + "Prepend the Address to Each Referenced Comment";
|
||||||
public static final Color DEFAULT_COLOR = Color.BLUE;
|
public static final Color DEFAULT_COLOR = Color.BLUE;
|
||||||
|
@ -69,6 +71,7 @@ public class EolCommentFieldFactory extends FieldFactory {
|
||||||
private boolean alwaysShowRefRepeatables;
|
private boolean alwaysShowRefRepeatables;
|
||||||
private boolean alwaysShowAutomatic;
|
private boolean alwaysShowAutomatic;
|
||||||
private boolean useAbbreviatedAutomatic;
|
private boolean useAbbreviatedAutomatic;
|
||||||
|
private boolean showAutomaticFunctions;
|
||||||
private boolean prependRefAddress;
|
private boolean prependRefAddress;
|
||||||
private Color repeatableCommentColor;
|
private Color repeatableCommentColor;
|
||||||
private Color automaticCommentColor;
|
private Color automaticCommentColor;
|
||||||
|
@ -92,7 +95,7 @@ public class EolCommentFieldFactory extends FieldFactory {
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param model the model that the field belongs to.
|
* @param model the model that the field belongs to.
|
||||||
* @param hsProvider the HightLightStringProvider.
|
* @param hlProvider the HightLightStringProvider.
|
||||||
* @param displayOptions the Options for display properties.
|
* @param displayOptions the Options for display properties.
|
||||||
* @param fieldOptions the Options for field specific properties.
|
* @param fieldOptions the Options for field specific properties.
|
||||||
*/
|
*/
|
||||||
|
@ -126,6 +129,9 @@ public class EolCommentFieldFactory extends FieldFactory {
|
||||||
"aren't any EOL or repeatable comments.");
|
"aren't any EOL or repeatable comments.");
|
||||||
fieldOptions.registerOption(USE_ABBREVIATED_AUTOMITIC_COMMENT_MSG, true, hl,
|
fieldOptions.registerOption(USE_ABBREVIATED_AUTOMITIC_COMMENT_MSG, true, hl,
|
||||||
"When showing automatic comments, show the smallest amount of information possible");
|
"When showing automatic comments, show the smallest amount of information possible");
|
||||||
|
fieldOptions.registerOption(SHOW_FUNCTION_AUTOMITIC_COMMENT_MSG, true, hl,
|
||||||
|
"When showing automatic comments, show direct function references");
|
||||||
|
|
||||||
fieldOptions.registerOption(ENABLE_PREPEND_REF_ADDRESS_MSG, false, hl,
|
fieldOptions.registerOption(ENABLE_PREPEND_REF_ADDRESS_MSG, false, hl,
|
||||||
"Displays the address before each referenced repeatable comment.");
|
"Displays the address before each referenced repeatable comment.");
|
||||||
|
|
||||||
|
@ -153,6 +159,9 @@ public class EolCommentFieldFactory extends FieldFactory {
|
||||||
alwaysShowAutomatic = fieldOptions.getBoolean(ENABLE_ALWAYS_SHOW_AUTOMATIC_MSG, false);
|
alwaysShowAutomatic = fieldOptions.getBoolean(ENABLE_ALWAYS_SHOW_AUTOMATIC_MSG, false);
|
||||||
useAbbreviatedAutomatic =
|
useAbbreviatedAutomatic =
|
||||||
fieldOptions.getBoolean(USE_ABBREVIATED_AUTOMITIC_COMMENT_MSG, true);
|
fieldOptions.getBoolean(USE_ABBREVIATED_AUTOMITIC_COMMENT_MSG, true);
|
||||||
|
showAutomaticFunctions =
|
||||||
|
fieldOptions.getBoolean(SHOW_FUNCTION_AUTOMITIC_COMMENT_MSG, true);
|
||||||
|
|
||||||
prependRefAddress = fieldOptions.getBoolean(ENABLE_PREPEND_REF_ADDRESS_MSG, false);
|
prependRefAddress = fieldOptions.getBoolean(ENABLE_PREPEND_REF_ADDRESS_MSG, false);
|
||||||
|
|
||||||
fieldOptions.getOptions(GROUP_TITLE).setOptionsHelpLocation(hl);
|
fieldOptions.getOptions(GROUP_TITLE).setOptionsHelpLocation(hl);
|
||||||
|
@ -300,7 +309,7 @@ public class EolCommentFieldFactory extends FieldFactory {
|
||||||
DisplayableEol displayableEol =
|
DisplayableEol displayableEol =
|
||||||
new DisplayableEol(cu, alwaysShowRepeatable, alwaysShowRefRepeatables,
|
new DisplayableEol(cu, alwaysShowRepeatable, alwaysShowRefRepeatables,
|
||||||
alwaysShowAutomatic, codeUnitFormatOptions.followReferencedPointers(),
|
alwaysShowAutomatic, codeUnitFormatOptions.followReferencedPointers(),
|
||||||
maxDisplayLines, useAbbreviatedAutomatic);
|
maxDisplayLines, useAbbreviatedAutomatic, showAutomaticFunctions);
|
||||||
ArrayList<FieldElement> elementList = new ArrayList<>();
|
ArrayList<FieldElement> elementList = new ArrayList<>();
|
||||||
|
|
||||||
// This Code Unit's End of Line Comment
|
// This Code Unit's End of Line Comment
|
||||||
|
@ -500,7 +509,7 @@ public class EolCommentFieldFactory extends FieldFactory {
|
||||||
DisplayableEol displayableEol =
|
DisplayableEol displayableEol =
|
||||||
new DisplayableEol(cu, alwaysShowRepeatable, alwaysShowRefRepeatables,
|
new DisplayableEol(cu, alwaysShowRepeatable, alwaysShowRefRepeatables,
|
||||||
alwaysShowAutomatic, codeUnitFormatOptions.followReferencedPointers(),
|
alwaysShowAutomatic, codeUnitFormatOptions.followReferencedPointers(),
|
||||||
maxDisplayLines, useAbbreviatedAutomatic);
|
maxDisplayLines, useAbbreviatedAutomatic, showAutomaticFunctions);
|
||||||
|
|
||||||
// Hold position in connected tool if navigating within semicolon.
|
// Hold position in connected tool if navigating within semicolon.
|
||||||
int numLeadColumns = 0;
|
int numLeadColumns = 0;
|
||||||
|
@ -537,7 +546,7 @@ public class EolCommentFieldFactory extends FieldFactory {
|
||||||
DisplayableEol displayableEol =
|
DisplayableEol displayableEol =
|
||||||
new DisplayableEol((CodeUnit) obj, alwaysShowRepeatable, alwaysShowRefRepeatables,
|
new DisplayableEol((CodeUnit) obj, alwaysShowRepeatable, alwaysShowRefRepeatables,
|
||||||
alwaysShowAutomatic, codeUnitFormatOptions.followReferencedPointers(),
|
alwaysShowAutomatic, codeUnitFormatOptions.followReferencedPointers(),
|
||||||
maxDisplayLines, useAbbreviatedAutomatic);
|
maxDisplayLines, useAbbreviatedAutomatic, showAutomaticFunctions);
|
||||||
|
|
||||||
ListingTextField btf = (ListingTextField) bf;
|
ListingTextField btf = (ListingTextField) bf;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.app.plugin.core.comments;
|
package ghidra.app.plugin.core.comments;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.address.AddressFactory;
|
import ghidra.program.model.address.AddressFactory;
|
||||||
import ghidra.program.model.listing.CodeUnit;
|
import ghidra.program.model.listing.CodeUnit;
|
||||||
import ghidra.program.model.listing.Listing;
|
import ghidra.program.model.listing.Listing;
|
||||||
|
import ghidra.program.model.symbol.RefType;
|
||||||
import ghidra.program.model.symbol.SourceType;
|
import ghidra.program.model.symbol.SourceType;
|
||||||
import ghidra.test.AbstractGhidraHeadlessIntegrationTest;
|
import ghidra.test.AbstractGhidraHeadlessIntegrationTest;
|
||||||
import ghidra.util.exception.RollbackException;
|
import ghidra.util.exception.RollbackException;
|
||||||
|
@ -60,6 +61,9 @@ public class DisplayableEolTest extends AbstractGenericTest {
|
||||||
// testReferenceToOffcutStringData_UseAbbreviatedCommentOption()
|
// testReferenceToOffcutStringData_UseAbbreviatedCommentOption()
|
||||||
builder.createEncodedString("1001234", "one.two", StandardCharsets.US_ASCII, false);
|
builder.createEncodedString("1001234", "one.two", StandardCharsets.US_ASCII, false);
|
||||||
|
|
||||||
|
// testReferenceToFunction()
|
||||||
|
builder.createFunction("0x1001050");
|
||||||
|
|
||||||
program = builder.getProgram();
|
program = builder.getProgram();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +72,8 @@ public class DisplayableEolTest extends AbstractGenericTest {
|
||||||
|
|
||||||
Listing listing = program.getListing();
|
Listing listing = program.getListing();
|
||||||
CodeUnit cu = listing.getCodeUnitAt(addr("0x110"));
|
CodeUnit cu = listing.getCodeUnitAt(addr("0x110"));
|
||||||
DisplayableEol displayableEol = new DisplayableEol(cu, true, true, true, false, 5, true);
|
DisplayableEol displayableEol =
|
||||||
|
new DisplayableEol(cu, true, true, true, false, 5, true, true);
|
||||||
|
|
||||||
String[] comments = displayableEol.getAutomaticComment();
|
String[] comments = displayableEol.getAutomaticComment();
|
||||||
assertEquals(1, comments.length);
|
assertEquals(1, comments.length);
|
||||||
|
@ -84,7 +89,8 @@ public class DisplayableEolTest extends AbstractGenericTest {
|
||||||
|
|
||||||
Listing listing = program.getListing();
|
Listing listing = program.getListing();
|
||||||
CodeUnit cu = listing.getCodeUnitAt(addr("0x1001000"));
|
CodeUnit cu = listing.getCodeUnitAt(addr("0x1001000"));
|
||||||
DisplayableEol displayableEol = new DisplayableEol(cu, true, true, true, false, 5, true);
|
DisplayableEol displayableEol =
|
||||||
|
new DisplayableEol(cu, true, true, true, false, 5, true, true);
|
||||||
|
|
||||||
String[] comments = displayableEol.getAutomaticComment();
|
String[] comments = displayableEol.getAutomaticComment();
|
||||||
assertEquals(1, comments.length);
|
assertEquals(1, comments.length);
|
||||||
|
@ -107,7 +113,31 @@ public class DisplayableEolTest extends AbstractGenericTest {
|
||||||
boolean useAbbreviatedComments = false;
|
boolean useAbbreviatedComments = false;
|
||||||
|
|
||||||
DisplayableEol displayableEol =
|
DisplayableEol displayableEol =
|
||||||
new DisplayableEol(cu, true, true, true, false, 5, useAbbreviatedComments);
|
new DisplayableEol(cu, true, true, true, false, 5, useAbbreviatedComments, true);
|
||||||
|
|
||||||
|
String[] comments = displayableEol.getAutomaticComment();
|
||||||
|
assertEquals(1, comments.length);
|
||||||
|
assertEquals("= \"one.two\"", comments[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReferenceToFunction_ShowAutomaticFunctionsOff() throws Exception {
|
||||||
|
|
||||||
|
Address dataStartAddress = addr("0x1001234");
|
||||||
|
Address offcutAddress = dataStartAddress.add(2);
|
||||||
|
Command cmd =
|
||||||
|
new AddMemRefCmd(addr("0x1001000"), offcutAddress, SourceType.USER_DEFINED, 0, true);
|
||||||
|
applyCmd(cmd);
|
||||||
|
|
||||||
|
Listing listing = program.getListing();
|
||||||
|
CodeUnit cu = listing.getCodeUnitAt(addr("0x1001000"));
|
||||||
|
|
||||||
|
// with this at false, all of the string will be rendered
|
||||||
|
boolean useAbbreviatedComments = false;
|
||||||
|
boolean showAutoFunctions = false;
|
||||||
|
DisplayableEol displayableEol =
|
||||||
|
new DisplayableEol(cu, true, true, true, false, 5, useAbbreviatedComments,
|
||||||
|
showAutoFunctions);
|
||||||
|
|
||||||
String[] comments = displayableEol.getAutomaticComment();
|
String[] comments = displayableEol.getAutomaticComment();
|
||||||
assertEquals(1, comments.length);
|
assertEquals(1, comments.length);
|
||||||
|
@ -133,13 +163,52 @@ public class DisplayableEolTest extends AbstractGenericTest {
|
||||||
boolean useAbbreviatedComments = true;
|
boolean useAbbreviatedComments = true;
|
||||||
|
|
||||||
DisplayableEol displayableEol =
|
DisplayableEol displayableEol =
|
||||||
new DisplayableEol(cu, true, true, true, false, 5, useAbbreviatedComments);
|
new DisplayableEol(cu, true, true, true, false, 5, useAbbreviatedComments, true);
|
||||||
|
|
||||||
String[] comments = displayableEol.getAutomaticComment();
|
String[] comments = displayableEol.getAutomaticComment();
|
||||||
assertEquals(1, comments.length);
|
assertEquals(1, comments.length);
|
||||||
assertEquals("= \"two\"", comments[0]);// full string is one.two
|
assertEquals("= \"two\"", comments[0]);// full string is one.two
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReferenceToFunction_ShowAutomaticFunctions() throws Exception {
|
||||||
|
|
||||||
|
Address from = addr("0x1001000");
|
||||||
|
Address toFunction = addr("0x1001050");
|
||||||
|
|
||||||
|
applyCmd(new AddMemRefCmd(from, toFunction, RefType.UNCONDITIONAL_CALL, SourceType.ANALYSIS,
|
||||||
|
0, true));
|
||||||
|
|
||||||
|
Listing listing = program.getListing();
|
||||||
|
CodeUnit cu = listing.getCodeUnitAt(from);
|
||||||
|
boolean showAutoFunctions = true;
|
||||||
|
DisplayableEol displayableEol =
|
||||||
|
new DisplayableEol(cu, true, true, true, false, 5, false, showAutoFunctions);
|
||||||
|
|
||||||
|
String[] comments = displayableEol.getAutomaticComment();
|
||||||
|
assertEquals(1, comments.length);
|
||||||
|
assertEquals("undefined FUN_01001050()", comments[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReferenceToFunction_DontShowAutomaticFunctions() throws Exception {
|
||||||
|
|
||||||
|
Address from = addr("0x1001000");
|
||||||
|
Address toFunction = addr("0x1001050");
|
||||||
|
|
||||||
|
applyCmd(new AddMemRefCmd(from, toFunction, RefType.UNCONDITIONAL_CALL, SourceType.ANALYSIS,
|
||||||
|
0, true));
|
||||||
|
|
||||||
|
Listing listing = program.getListing();
|
||||||
|
CodeUnit cu = listing.getCodeUnitAt(from);
|
||||||
|
boolean showAutoFunctions = false;
|
||||||
|
DisplayableEol displayableEol =
|
||||||
|
new DisplayableEol(cu, true, true, true, false, 5, false, showAutoFunctions);
|
||||||
|
|
||||||
|
String[] comments = displayableEol.getAutomaticComment();
|
||||||
|
assertEquals(0, comments.length);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean applyCmd(Command cmd) throws RollbackException {
|
public boolean applyCmd(Command cmd) throws RollbackException {
|
||||||
return AbstractGhidraHeadlessIntegrationTest.applyCmd(program, cmd);
|
return AbstractGhidraHeadlessIntegrationTest.applyCmd(program, cmd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue