Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-596 - Function Tags - review fixes GP-596 - Function Tags - updated function tags to show tagged External Functions

emteere8a07e62879a4
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/AllFunctionsPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/AllFunctionsPanel.java
index 6144f912c4..4f5bdaac2a 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/AllFunctionsPanel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/AllFunctionsPanel.java
@@ -16,8 +16,7 @@
package ghidra.app.plugin.core.function.tags;
import java.awt.BorderLayout;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
import java.util.stream.Collectors;
import javax.swing.*;
@@ -100,13 +99,19 @@ public class AllFunctionsPanel extends JPanel {
* @param tags the selected tags
*/
public void setSelectedTags(Set<FunctionTag> tags) {
+
+ Set<FunctionTag> currentTags = model.getTags();
+ if (Objects.equals(tags, currentTags)) {
+ return;
+ }
+
String tagNames = tags.stream()
.map(t -> t.getName())
.collect(Collectors.joining(" or "))
.toString();
titleLabel.setText("Functions With Tag: " + tagNames);
- model.setSelectedTags(tags);
+ model.setTags(tags);
}
/**
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTableModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTableModel.java
index b008b5e65e..a11389affb 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTableModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/tags/FunctionTableModel.java
@@ -87,16 +87,27 @@ class FunctionTableModel extends AddressBasedTableModel<Function> {
// Loop over all functions in the program, filtering out those that do not
// do not contain at least one of the tags in the provided set.
FunctionIterator iter = program.getFunctionManager().getFunctions(true);
- monitor.initialize(program.getFunctionManager().getFunctionCount());
+ int realFunctionCount = program.getFunctionManager().getFunctionCount();
+ monitor.initialize(realFunctionCount);
while (iter.hasNext()) {
- monitor.incrementProgress(1);
monitor.checkCanceled();
+ monitor.incrementProgress(1);
Function f = iter.next();
boolean hasTag = f.getTags().stream().anyMatch(t -> tags.contains(t));
if (hasTag) {
accumulator.add(f);
}
}
+
+ FunctionIterator externals = program.getFunctionManager().getExternalFunctions();
+ for (Function f : externals) {
+ monitor.checkCanceled();
+ monitor.incrementProgress(1);
+ boolean hasTag = f.getTags().stream().anyMatch(t -> tags.contains(t));
+ if (hasTag) {
+ accumulator.add(f);
+ }
+ }
}
/**
@@ -105,11 +116,19 @@ class FunctionTableModel extends AddressBasedTableModel<Function> {
*
* @param tags the selected tags
*/
- public void setSelectedTags(Set<FunctionTag> tags) {
+ public void setTags(Set<FunctionTag> tags) {
this.tags = tags;
reload();
}
+ /**
+ * Returns the tags being used by this model
+ * @return the tags
+ */
+ public Set<FunctionTag> getTags() {
+ return tags;
+ }
+
/**
* Returns the list of functions in the table
*