diff --git a/Ghidra/Features/Base/src/main/help/help/topics/FunctionTagPlugin/images/FullWindow.png b/Ghidra/Features/Base/src/main/help/help/topics/FunctionTagPlugin/images/FullWindow.png index f869f9ae6f..3c8d624e37 100644 Binary files a/Ghidra/Features/Base/src/main/help/help/topics/FunctionTagPlugin/images/FullWindow.png and b/Ghidra/Features/Base/src/main/help/help/topics/FunctionTagPlugin/images/FullWindow.png differ diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/AddFunctionTagCmd.java b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/AddFunctionTagCmd.java index 6b844208af..da8dc86e4c 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/AddFunctionTagCmd.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/AddFunctionTagCmd.java @@ -18,14 +18,13 @@ package ghidra.app.cmd.function; import ghidra.framework.cmd.Command; import ghidra.framework.model.DomainObject; import ghidra.program.database.ProgramDB; -import ghidra.program.database.function.FunctionManagerDB; import ghidra.program.model.address.Address; import ghidra.program.model.listing.Function; +import ghidra.program.model.listing.FunctionManager; /** * Command for assigning a tag to a function. Executing this will pop up a dialog - * allowing the user to assign tags to a function. - * + * allowing the user to assign tags to a function. */ public class AddFunctionTagCmd implements Command { @@ -34,7 +33,7 @@ public class AddFunctionTagCmd implements Command { private String errorMsg = ""; /** - * Constructor. + * Constructor * * @param tagName the name of the tag to add * @param entryPoint the function address @@ -44,15 +43,11 @@ public class AddFunctionTagCmd implements Command { this.entryPoint = entryPoint; } - /****************************************************************************** - * PUBLIC METHODS - ******************************************************************************/ - @Override public boolean applyTo(DomainObject obj) { ProgramDB program = (ProgramDB) obj; - FunctionManagerDB functionManagerDB = (FunctionManagerDB) program.getFunctionManager(); - Function function = functionManagerDB.getFunctionAt(entryPoint); + FunctionManager functionManager = program.getFunctionManager(); + Function function = functionManager.getFunctionAt(entryPoint); if (function == null) { errorMsg = "Function not found at: " + entryPoint.toString(); diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/ChangeFunctionTagCmd.java b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/ChangeFunctionTagCmd.java index dd519a737f..3d83657344 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/ChangeFunctionTagCmd.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/ChangeFunctionTagCmd.java @@ -18,26 +18,24 @@ package ghidra.app.cmd.function; import ghidra.framework.cmd.Command; import ghidra.framework.model.DomainObject; import ghidra.program.database.ProgramDB; -import ghidra.program.database.function.FunctionManagerDB; -import ghidra.program.model.listing.FunctionTag; -import ghidra.program.model.listing.FunctionTagManager; +import ghidra.program.model.listing.*; /** - * Updates the name or comment field for a given function tag. + * Updates the name or comment field for a given function tag */ public class ChangeFunctionTagCmd implements Command { private final int field; private final String tagName; private final String newVal; - + private String errorMsg = ""; public static final int TAG_NAME_CHANGED = 0; public static final int TAG_COMMENT_CHANGED = 1; /** - * Constructor. + * Constructor * * @param tagName the name of the tag to change * @param newVal the new value to set @@ -52,16 +50,12 @@ public class ChangeFunctionTagCmd implements Command { this.field = field; } - /****************************************************************************** - * PUBLIC METHODS - ******************************************************************************/ - @Override public boolean applyTo(DomainObject obj) { ProgramDB program = (ProgramDB) obj; - FunctionManagerDB functionManagerDB = (FunctionManagerDB) program.getFunctionManager(); - FunctionTagManager functionTagManager = functionManagerDB.getFunctionTagManager(); - FunctionTag tag = functionTagManager.getFunctionTag(tagName); + FunctionManager functionManager = program.getFunctionManager(); + FunctionTagManager tagManager = functionManager.getFunctionTagManager(); + FunctionTag tag = tagManager.getFunctionTag(tagName); if (tag == null) { errorMsg = "Function Tag not found: " + tagName; diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateFunctionTagCmd.java b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateFunctionTagCmd.java index 9c6b133400..76fde6867b 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateFunctionTagCmd.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateFunctionTagCmd.java @@ -18,12 +18,11 @@ package ghidra.app.cmd.function; import ghidra.framework.cmd.Command; import ghidra.framework.model.DomainObject; import ghidra.program.database.ProgramDB; -import ghidra.program.database.function.FunctionManagerDB; +import ghidra.program.model.listing.FunctionManager; import ghidra.program.model.listing.FunctionTagManager; /** - * Command for assigning a tag to a function. - * + * Command for assigning a tag to a function */ public class CreateFunctionTagCmd implements Command { @@ -31,7 +30,7 @@ public class CreateFunctionTagCmd implements Command { private String comment; /** - * Constructor. + * Constructor * * @param name the name of the new tag */ @@ -41,7 +40,7 @@ public class CreateFunctionTagCmd implements Command { } /** - * Constructor. + * Constructor * * @param name the name of the new tag * @param comment the tag comment @@ -51,16 +50,12 @@ public class CreateFunctionTagCmd implements Command { this.comment = comment; } - /****************************************************************************** - * PUBLIC METHODS - ******************************************************************************/ - @Override public boolean applyTo(DomainObject obj) { ProgramDB program = (ProgramDB) obj; - FunctionManagerDB functionManagerDB = (FunctionManagerDB) program.getFunctionManager(); - FunctionTagManager functionTagManager = functionManagerDB.getFunctionTagManager(); - functionTagManager.createFunctionTag(name, comment); + FunctionManager functionManager = program.getFunctionManager(); + FunctionTagManager tagManager = functionManager.getFunctionTagManager(); + tagManager.createFunctionTag(name, comment); return true; } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/DeleteFunctionTagCmd.java b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/DeleteFunctionTagCmd.java index b6ac6efc2a..df09d1ac26 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/DeleteFunctionTagCmd.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/DeleteFunctionTagCmd.java @@ -18,19 +18,19 @@ package ghidra.app.cmd.function; import ghidra.framework.cmd.BackgroundCommand; import ghidra.framework.model.DomainObject; import ghidra.program.database.ProgramDB; -import ghidra.program.database.function.FunctionManagerDB; +import ghidra.program.model.listing.FunctionManager; import ghidra.program.model.listing.FunctionTag; import ghidra.util.task.TaskMonitor; /** - * Command for deleting a tag from the system. + * Command for deleting a tag from the system */ public class DeleteFunctionTagCmd extends BackgroundCommand { private String tagName; /** - * Constructor. + * Constructor * * @param tagName the name of the tag to delete */ @@ -38,21 +38,15 @@ public class DeleteFunctionTagCmd extends BackgroundCommand { this.tagName = tagName; } - /****************************************************************************** - * PUBLIC METHODS - ******************************************************************************/ - @Override public boolean applyTo(DomainObject obj, TaskMonitor monitor) { ProgramDB program = (ProgramDB) obj; - FunctionManagerDB functionManager = (FunctionManagerDB) program.getFunctionManager(); + FunctionManager functionManager = program.getFunctionManager(); FunctionTag tag = functionManager.getFunctionTagManager().getFunctionTag(tagName); - if (tag != null) { tag.delete(); } - return true; } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/RemoveFunctionTagCmd.java b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/RemoveFunctionTagCmd.java index fce2a58ad7..2b42e078d7 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/RemoveFunctionTagCmd.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/RemoveFunctionTagCmd.java @@ -18,13 +18,12 @@ package ghidra.app.cmd.function; import ghidra.framework.cmd.Command; import ghidra.framework.model.DomainObject; import ghidra.program.database.ProgramDB; -import ghidra.program.database.function.FunctionManagerDB; import ghidra.program.model.address.Address; import ghidra.program.model.listing.Function; +import ghidra.program.model.listing.FunctionManager; /** - * Command for removing a tag from a function. - * + * Command for removing a tag from a function */ public class RemoveFunctionTagCmd implements Command { @@ -32,6 +31,8 @@ public class RemoveFunctionTagCmd implements Command { private String tagName; /** + * Constructor + * * @param tagName the name of the tag to remove * @param entryPoint the address of the function */ @@ -40,19 +41,12 @@ public class RemoveFunctionTagCmd implements Command { this.entryPoint = entryPoint; } - /****************************************************************************** - * PUBLIC METHODS - ******************************************************************************/ - @Override public boolean applyTo(DomainObject obj) { ProgramDB program = (ProgramDB) obj; - FunctionManagerDB functionManagerDB = (FunctionManagerDB) program.getFunctionManager(); - Function function = functionManagerDB.getFunctionAt(entryPoint); + FunctionManager functionManager = program.getFunctionManager(); + Function function = functionManager.getFunctionAt(entryPoint); function.removeTag(tagName); - - // The remove function does not return a success/fail statutus, so just return - // and move on. return true; } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTagButtonPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTagButtonPanel.java index 3aa0b5e103..a0e17897cc 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTagButtonPanel.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTagButtonPanel.java @@ -24,7 +24,7 @@ import resources.Icons; import resources.ResourceManager; /** - * Provides buttons to be used with the {@link FunctionTagsComponentProvider}. + * Provides buttons to be used with the {@link FunctionTagProvider}. * These buttons allow users to add or remove tags from functions, or delete * tags altogether. *
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTagPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTagPlugin.java index 77a372364e..77842e29c8 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTagPlugin.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTagPlugin.java @@ -26,7 +26,7 @@ import ghidra.program.util.ProgramLocation; /** * Plugin for managing function tags. This works with the associated - * {@link FunctionTagsComponentProvider} to allow users to view and + * {@link FunctionTagProvider} to allow users to view and * edit function tags both globally and for individual functions. * */ @@ -40,18 +40,18 @@ import ghidra.program.util.ProgramLocation; ) //@formatter:on public class FunctionTagPlugin extends ProgramPlugin { - + public final static String FUNCTION_TAG_MENU_SUBGROUP = "TagFunction"; // Action visible when right-clicking on a function in the listing. private EditFunctionTagsAction editFunctionTagsAction; // The display object for this plugin. - private FunctionTagsComponentProvider provider; + private FunctionTagProvider provider; public FunctionTagPlugin(PluginTool tool) { super(tool, true, false); - provider = new FunctionTagsComponentProvider(this, getCurrentProgram()); + provider = new FunctionTagProvider(this, getCurrentProgram()); createActions(); } @@ -64,7 +64,7 @@ public class FunctionTagPlugin extends ProgramPlugin { * * @return the component provider */ - public FunctionTagsComponentProvider getProvider() { + public FunctionTagProvider getProvider() { return provider; } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTagsComponentProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTagProvider.java similarity index 64% rename from Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTagsComponentProvider.java rename to Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTagProvider.java index 08b2e6a389..9fec84ac4e 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTagsComponentProvider.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTagProvider.java @@ -16,24 +16,29 @@ package ghidra.app.plugin.core.function.tags; import java.awt.*; -import java.util.ArrayList; +import java.util.*; import java.util.List; -import java.util.Set; import javax.swing.*; +import javax.swing.border.BevelBorder; +import javax.swing.border.Border; + +import org.apache.commons.lang3.StringUtils; import docking.widgets.label.GLabel; import docking.widgets.textfield.HintTextField; import ghidra.app.cmd.function.CreateFunctionTagCmd; import ghidra.app.context.ProgramActionContext; import ghidra.framework.cmd.Command; -import ghidra.framework.model.DomainObjectChangedEvent; -import ghidra.framework.model.DomainObjectListener; +import ghidra.framework.model.*; import ghidra.framework.plugintool.ComponentProviderAdapter; +import ghidra.program.database.function.FunctionManagerDB; import ghidra.program.model.address.Address; import ghidra.program.model.listing.*; import ghidra.program.util.*; import ghidra.util.*; +import ghidra.util.task.SwingUpdateManager; +import resources.ResourceManager; /** * Displays all the function tags in the database and identifies which ones have @@ -44,13 +49,13 @@ import ghidra.util.*; *
NOTE: The storage and source are ignored if the function does not have custom storage enabled. - * @param type - * @param storage + * + *
NOTE: The storage and source are ignored if the function does not have custom storage
+ * enabled.
+ *
+ * @param type the data type
+ * @param storage the storage
* @param source source to be combined with the overall signature source.
- * @throws InvalidInputException if data type is not a fixed length or storage is improperly sized
+ * @throws InvalidInputException if data type is not a fixed length or storage is improperly
+ * sized
*/
public void setReturn(DataType type, VariableStorage storage, SourceType source)
throws InvalidInputException;
@@ -216,21 +218,22 @@ public interface Function extends Namespace {
/**
* Get the function's signature.
- *
WARNING! It is important to note that the calling convention may not be properly retained
- * by the returned signature object if a non-generic calling convention is used by this function as
- * defined by the program's compiler specification.
+ *
WARNING! It is important to note that the calling convention may not be properly
+ * retained by the returned signature object if a non-generic calling convention is used by
+ * this function as defined by the program's compiler specification.
+ *
* @param formalSignature if true only original raw types will be retained and
* auto-params discarded (e.g., this, __return_storage_ptr__, etc.) within the returned
* signature. If false, the effective signature will be returned where forced indirect
* and auto-params are reflected in the signature. This option has no affect if the specified
* function has custom storage enabled.
- *
* @return the function's signature
*/
public FunctionSignature getSignature(boolean formalSignature);
/**
* Return a string representation of the function signature
+ *
* @param formalSignature if true only original raw return/parameter types will be retained and
* auto-params discarded (e.g., this, __return_storage_ptr__, etc.) within the returned
* signature. If false, the effective signature will be returned where forced indirect
@@ -238,6 +241,7 @@ public interface Function extends Namespace {
* function has custom storage enabled.
* @param includeCallingConvention if true prototype will include call convention
* declaration if known.
+ * @return the prototype
*/
public String getPrototypeString(boolean formalSignature, boolean includeCallingConvention);
@@ -464,6 +468,7 @@ public interface Function extends Namespace {
* @param fromOrdinal from ordinal position using the current numbering
* @param toOrdinal the final position of the specified parameter
* @return parameter which was moved
+ * @throws InvalidInputException if either ordinal is invalid
* @deprecated The use of this method is discouraged. The function signature should generally be
* adjusted with a single call to {@link #updateFunction(String, Variable, List, FunctionUpdateType, boolean, SourceType)}
*/
@@ -520,7 +525,7 @@ public interface Function extends Namespace {
/**
* Returns an array of all local and parameter variables
- * @return
+ * @return the variables
*/
public Variable[] getAllVariables();
@@ -533,6 +538,7 @@ public interface Function extends Namespace {
* @return the Variable added to the program.
* @throws DuplicateNameException if another local variable or parameter already
* has that name.
+ * @throws InvalidInputException if there is an error or conflict when resolving the variable
*/
public Variable addLocalVariable(Variable var, SourceType source)
throws DuplicateNameException, InvalidInputException;
@@ -553,14 +559,16 @@ public interface Function extends Namespace {
public void setBody(AddressSetView newBody) throws OverlappingFunctionException;
/**
- * Returns true if this function has a variable argument list (VarArgs).
+ * Returns true if this function has a variable argument list (VarArgs)
+ * @return true if this function has a variable argument list (VarArgs)
*/
public boolean hasVarArgs();
/**
- * Set whether parameters can be passed as a VarArg (variable argument list).
+ * Set whether parameters can be passed as a VarArg (variable argument list)
*
- * @param hasVarArgs true if this function has a variable argument list (ie printf(fmt, ...)).
+ * @param hasVarArgs true if this function has a variable argument list
+ * (e.g., printf(fmt, ...)).
*/
public void setVarArgs(boolean hasVarArgs);
@@ -595,7 +603,7 @@ public interface Function extends Namespace {
/**
* Set whether or not this function uses custom variable storage
- * @param hasCustomVariableStorage
+ * @param hasCustomVariableStorage true if this function uses custom storage
*/
public void setCustomVariableStorage(boolean hasCustomVariableStorage);
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/FunctionManager.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/FunctionManager.java
index 6414529a08..be598d8661 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/FunctionManager.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/FunctionManager.java
@@ -15,22 +15,29 @@
*/
package ghidra.program.model.listing;
-import java.io.IOException;
import java.util.Iterator;
import java.util.List;
-import ghidra.program.database.ProgramDB;
+import ghidra.program.database.ManagerDB;
import ghidra.program.database.function.OverlappingFunctionException;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.lang.PrototypeModel;
import ghidra.program.model.symbol.Namespace;
import ghidra.program.model.symbol.SourceType;
-import ghidra.util.exception.*;
+import ghidra.util.exception.CancelledException;
+import ghidra.util.exception.InvalidInputException;
import ghidra.util.task.TaskMonitor;
-public interface FunctionManager {
+/**
+ * The manager for functions
+ */
+public interface FunctionManager extends ManagerDB {
+ /**
+ * Returns this manager's program
+ * @return the program
+ */
public Program getProgram();
/**
@@ -50,8 +57,8 @@ public interface FunctionManager {
public PrototypeModel getDefaultCallingConvention();
/**
- * Gets the prototype model of the calling convention with the specified name in this program.
- *
+ * Gets the prototype model of the calling convention with the specified name in this program
+ * @param name the calling convention name
* @return the named function calling convention prototype model or null.
*/
public PrototypeModel getCallingConvention(String name);
@@ -113,25 +120,28 @@ public interface FunctionManager {
throws OverlappingFunctionException;
/**
- * Returns the total number of functions in the program including external functions.
+ * Returns the total number of functions in the program including external functions
+ * @return the count
*/
public int getFunctionCount();
/**
- * Remove a function defined at entryPoint.
+ * Remove a function defined at entryPoint
+ * @param entryPoint the entry point
+ * @return true if the function was removed
*/
public boolean removeFunction(Address entryPoint);
/**
- * Get the function at entryPoint.
- *
- * @return null if there is no function at entryPoint.
+ * Get the function at entryPoint
+ * @param entryPoint the entry point
+ * @return null if there is no function at entryPoint
*/
public Function getFunctionAt(Address entryPoint);
/**
- * Get the function which resides at the specified address or is referenced from the specified
- * address.
+ * Get the function which resides at the specified address or is referenced from the specified
+ * address
*
* @param address function address or address of pointer to a function.
* @return referenced function or null
@@ -147,19 +157,18 @@ public interface FunctionManager {
public Function getFunctionContaining(Address addr);
/**
- * Returns an iterator over all non-external functions in address (entry point) order.
- *
+ * Returns an iterator over all non-external functions in address (entry point) order
* @param forward true means to iterate in ascending address order
+ * @return the iterator
*/
public FunctionIterator getFunctions(boolean forward);
/**
* Get an iterator over non-external functions starting at an address and ordered by entry
- * address.
+ * address
*
* @param start starting address
* @param forward true means to iterate in ascending address order
- *
* @return an iterator over functions.
*/
public FunctionIterator getFunctions(Address start, boolean forward);
@@ -176,9 +185,10 @@ public interface FunctionManager {
/**
* Returns an iterator over all REAL functions in address (entry point) order (real functions
- * have instructions, and aren't stubs).
+ * have instructions, and aren't stubs)
*
* @param forward true means to iterate in ascending address order
+ * @return the iterator
*/
public FunctionIterator getFunctionsNoStubs(boolean forward);
@@ -220,39 +230,6 @@ public interface FunctionManager {
*/
public boolean isInFunction(Address addr);
- /**
- * @see ghidra.program.database.ManagerDB#moveAddressRange(ghidra.program.model.address.Address,
- * ghidra.program.model.address.Address, long, ghidra.util.task.TaskMonitor)
- */
- public void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor)
- throws CancelledException;
-
- /**
- * @see ghidra.program.database.ManagerDB#deleteAddressRange(ghidra.program.model.address.Address,
- * ghidra.program.model.address.Address, ghidra.util.task.TaskMonitor)
- */
- public void deleteAddressRange(Address startAddr, Address endAddr, TaskMonitor monitor)
- throws CancelledException;
-
- /**
- * @see ghidra.program.database.ManagerDB#setProgram(ghidra.program.database.ProgramDB)
- */
- public void setProgram(ProgramDB program);
-
- /**
- * @param currentRevision TODO
- * @see ghidra.program.database.ManagerDB#programReady(int, int, ghidra.util.task.TaskMonitor)
- */
- public void programReady(int openMode, int currentRevision, TaskMonitor monitor)
- throws IOException, CancelledException;
-
- /*
- * (non-Javadoc)
- *
- * @see ghidra.program.database.ManagerDB#invalidateCache(boolean)
- */
- public void invalidateCache(boolean all);
-
/**
* Return an iterator over functions that overlap the given address set.
*
@@ -268,10 +245,10 @@ public interface FunctionManager {
* function. While this does not account for the actual instruction flow, it is hopefully
* accurate enough for most situations.
*
- * @param instrAddr
- * @param storageAddr
+ * @param instrAddr the instruction address
+ * @param storageAddr the storage address
* @param size varnode size in bytes (1 is assumed if value <= 0)
- * @param isRead
+ * @param isRead true if the reference is a read reference
* @return referenced variable or null if one not found
*/
public Variable getReferencedVariable(Address instrAddr, Address storageAddr, int size,
@@ -284,4 +261,30 @@ public interface FunctionManager {
*/
public Function getFunction(long key);
+ /**
+ * Returns the function tag manager
+ * @return the function tag manager
+ */
+ public FunctionTagManager getFunctionTagManager();
+
+ /**
+ * Clears all data caches
+ * @param all if false, some managers may not need to update their cache if they can
+ * tell that its not necessary. If this flag is true, then all managers should clear
+ * their cache no matter what.
+ */
+ @Override
+ public void invalidateCache(boolean all); // note: redeclared to not throw an exception
+
+ /**
+ * Move all objects within an address range to a new location
+ * @param fromAddr the first address of the range to be moved
+ * @param toAddr the address where to the range is to be moved
+ * @param length the number of addresses to move
+ * @param monitor the task monitor to use in any upgrade operations
+ * @throws CancelledException if the user cancelled the operation via the task monitor
+ */
+ @Override
+ void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor)
+ throws CancelledException; // note: redeclared to not throw an AddressOverflowException
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/FunctionTagManager.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/FunctionTagManager.java
index c824c4a29f..6add062838 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/FunctionTagManager.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/FunctionTagManager.java
@@ -18,39 +18,39 @@ package ghidra.program.model.listing;
import java.util.List;
/**
- * Interface for managing function tags. Tags are simple objects consisting of
- * a name and an optional comment, which can be applied to functions in Ghidra.
+ * Interface for managing function tags. Tags are simple objects consisting of a name and an
+ * optional comment, which can be applied to functions.
*
- * @see ghidra.program.database.function.FunctionTagAdapter FunctionTagAdapter
- * @see ghidra.program.database.function.FunctionTagMappingAdapter FunctionTagMappingAdapter
+ * See ghidra.program.database.function.FunctionTagAdapter
+ * See ghidra.program.database.function.FunctionTagMappingAdapter
*/
public interface FunctionTagManager {
/**
- * Returns the function tag with the given name.
+ * Returns the function tag with the given name
*
* @param name the tag name
* @return the function tag, or null if not found
*/
- FunctionTag getFunctionTag(String name);
+ public FunctionTag getFunctionTag(String name);
/**
- * Returns the function tag with the given database id.
+ * Returns the function tag with the given database id
*
* @param id the tags database id
* @return the function tag, or null if not found
*/
- FunctionTag getFunctionTag(long id);
+ public FunctionTag getFunctionTag(long id);
/**
- * Returns all function tags in the database.
+ * Returns all function tags in the database
*
* @return list of function tags
*/
- List extends FunctionTag> getAllFunctionTags();
+ public List extends FunctionTag> getAllFunctionTags();
/**
- * Returns true if the given tag is assigned to a function.
+ * Returns true if the given tag is assigned to a function
*
* @param name the tag name
* @return true if assigned to a function
@@ -65,13 +65,12 @@ public interface FunctionTagManager {
* @param comment the comment associated with the tag (optional)
* @return the new function tag
*/
- FunctionTag createFunctionTag(String name, String comment);
+ public FunctionTag createFunctionTag(String name, String comment);
/**
- * Sets the program on this manager to allow the manager to persist changes
- * and notify subscribers.
- *
- * @param program the program
+ * Returns the number of times the given tag has been applied to a function
+ * @param tag the tag
+ * @return the count
*/
- void setProgram(Program program);
+ public int getUseCount(FunctionTag tag);
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/model/FunctionManagerTestDouble.java b/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/model/FunctionManagerTestDouble.java
index e4d918be73..e82f26d818 100644
--- a/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/model/FunctionManagerTestDouble.java
+++ b/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/model/FunctionManagerTestDouble.java
@@ -187,4 +187,8 @@ public class FunctionManagerTestDouble implements FunctionManager {
throw new UnsupportedOperationException();
}
+ @Override
+ public FunctionTagManager getFunctionTagManager() {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/FunctionTagPluginScreenShots.java b/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/FunctionTagPluginScreenShots.java
index 7bf45555ba..a1f332cf48 100644
--- a/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/FunctionTagPluginScreenShots.java
+++ b/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/FunctionTagPluginScreenShots.java
@@ -32,58 +32,47 @@ import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.FunctionIterator;
import ghidra.program.util.ProgramLocation;
import ghidra.util.Swing;
-import ghidra.util.exception.UsrException;
public class FunctionTagPluginScreenShots extends GhidraScreenShotGenerator {
@Test
public void testFullWindow() {
- showProvider(FunctionTagsComponentProvider.class);
+ showProvider(FunctionTagProvider.class);
waitForSwing();
addTableData();
- captureIsolatedProvider(FunctionTagsComponentProvider.class, 950, 400);
+ captureIsolatedProvider(FunctionTagProvider.class, 950, 400);
}
@Test
public void testInputField() {
- showProvider(FunctionTagsComponentProvider.class);
+ showProvider(FunctionTagProvider.class);
waitForSwing();
- FunctionTagsComponentProvider provider = getProvider(FunctionTagsComponentProvider.class);
- final JPanel inputPanel = (JPanel) getInstanceField("inputPanel", provider);
+ FunctionTagProvider provider = getProvider(FunctionTagProvider.class);
+ final JPanel inputPanel = provider.getInputPanel();
captureComponent(inputPanel);
}
- @Test
- public void testFilterField() {
- showProvider(FunctionTagsComponentProvider.class);
- waitForSwing();
- FunctionTagsComponentProvider provider = getProvider(FunctionTagsComponentProvider.class);
- final JPanel filterPanel = (JPanel) getInstanceField("filterPanel", provider);
- captureComponent(filterPanel);
- }
-
/**
* For this test the item in row 1 of the available tags table must be an editable
* item. If not, edit the function_tags.xml file to remove all items and re-run this.
*/
@Test
public void testEditTag() {
- showProvider(FunctionTagsComponentProvider.class);
+ showProvider(FunctionTagProvider.class);
waitForSwing();
addTableData();
- FunctionTagsComponentProvider provider = getProvider(FunctionTagsComponentProvider.class);
- SourceTagsPanel sourcePanel = (SourceTagsPanel) getInstanceField("sourcePanel", provider);
- FunctionTagTable table = (FunctionTagTable) getInstanceField("table", sourcePanel);
+ FunctionTagProvider provider = getProvider(FunctionTagProvider.class);
+ SourceTagsPanel sourcePanel = provider.getSourcePanel();
+ FunctionTagTable table = sourcePanel.getTable();
Rectangle bounds = table.getCellRect(7, 0, false); // Cell 7 is an editable item
doubleClick(table, bounds.x, bounds.y);
- InputDialog warningDialog = waitForDialogComponent(InputDialog.class);
-
- captureDialog(warningDialog);
+ InputDialog editDialog = waitForDialogComponent(InputDialog.class);
+ captureDialog(editDialog);
}
- /**
+ /*
* Captures the warning dialog when trying to delete a tag. Note that this assumes the
* tag in row 1 is NOT read-only. If that's the not the case, modify the function_tags.xml
* file to remove any tags that may be interfering with this.
@@ -91,12 +80,12 @@ public class FunctionTagPluginScreenShots extends GhidraScreenShotGenerator {
* @throws UsrException
*/
@Test
- public void testDeleteWarning() throws UsrException {
- showProvider(FunctionTagsComponentProvider.class);
+ public void testDeleteWarning() {
+ showProvider(FunctionTagProvider.class);
waitForSwing();
addTableData();
- FunctionTagsComponentProvider provider = getProvider(FunctionTagsComponentProvider.class);
+ FunctionTagProvider provider = getProvider(FunctionTagProvider.class);
SourceTagsPanel sourcePanel = (SourceTagsPanel) getInstanceField("sourcePanel", provider);
FunctionTagTable table = (FunctionTagTable) getInstanceField("table", sourcePanel);
table.setRowSelectionInterval(7, 7);
@@ -107,20 +96,20 @@ public class FunctionTagPluginScreenShots extends GhidraScreenShotGenerator {
captureDialog(warningDialog);
}
- /**
+ /*
* Captures the read-only warning when trying to edit a tag
*
* @throws UsrException
*/
@Test
- public void testEditNotAllowedWarning() throws UsrException {
- showProvider(FunctionTagsComponentProvider.class);
+ public void testEditNotAllowedWarning() {
+ showProvider(FunctionTagProvider.class);
waitForSwing();
addTableData();
- FunctionTagsComponentProvider provider = getProvider(FunctionTagsComponentProvider.class);
- SourceTagsPanel sourcePanel = (SourceTagsPanel) getInstanceField("sourcePanel", provider);
- FunctionTagTable table = (FunctionTagTable) getInstanceField("table", sourcePanel);
+ FunctionTagProvider provider = getProvider(FunctionTagProvider.class);
+ SourceTagsPanel sourcePanel = provider.getSourcePanel();
+ FunctionTagTable table = sourcePanel.getTable();
doubleClickItem(table, "LIBRARY"); // pick a known read-only tag
OptionDialog warningDialog = waitForDialogComponent(OptionDialog.class);
@@ -151,7 +140,7 @@ public class FunctionTagPluginScreenShots extends GhidraScreenShotGenerator {
private void addTableData() {
- FunctionTagsComponentProvider provider = getProvider(FunctionTagsComponentProvider.class);
+ FunctionTagProvider provider = getProvider(FunctionTagProvider.class);
Swing.runNow(() -> {
provider.programActivated(program);
@@ -171,7 +160,7 @@ public class FunctionTagPluginScreenShots extends GhidraScreenShotGenerator {
*
* @param provider the component provider
*/
- private void navigateToFunction(FunctionTagsComponentProvider provider) {
+ private void navigateToFunction(FunctionTagProvider provider) {
FunctionIterator iter = program.getFunctionManager().getFunctions(true);
while (iter.hasNext()) {
Function func = iter.next();