diff --git a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/ScriptPathsPropertyEditor.java b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/ScriptPathsPropertyEditor.java index fe12aae268a..fa2a3c21fc4 100644 --- a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/ScriptPathsPropertyEditor.java +++ b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/ScriptPathsPropertyEditor.java @@ -79,17 +79,17 @@ protected void savePaths(String[] paths) { @Override protected PathnameTablePanel newPathnameTablePanel() { - PathnameTablePanel tablePanel = new ScriptPathsPanel(this::reset); - tablePanel.setFileChooserProperties(getTitle(), "DebuggerLaunchScriptDirectory", + PathnameTablePanel panel = new ScriptPathsPanel(loadPaths(), this::reset); + panel.setFileChooserProperties(getTitle(), "DebuggerLaunchScriptDirectory", GhidraFileChooserMode.DIRECTORIES_ONLY, true, null); - return tablePanel; + return panel; } } protected class ScriptPathsPanel extends PathnameTablePanel { - public ScriptPathsPanel(Callback resetCallback) { + public ScriptPathsPanel(String[] paths, Callback resetCallback) { // disable edits, top/bottom irrelevant, unordered - super(null, resetCallback, false, false, false); + super(paths, resetCallback, false, false, false); } @Override diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/LibraryPathsDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/LibraryPathsDialog.java index c8796122013..b9c713fe3fb 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/LibraryPathsDialog.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/LibraryPathsDialog.java @@ -43,11 +43,11 @@ protected void savePaths(String[] paths) { @Override protected PathnameTablePanel newPathnameTablePanel() { // disable edits, add to top, ordered - PathnameTablePanel tablePanel = - new PathnameTablePanel(null, this::reset, false, true, true); - tablePanel.setFileChooserProperties("Select Directory or Filesystem", + PathnameTablePanel panel = + new PathnameTablePanel(loadPaths(), this::reset, false, true, true); + panel.setFileChooserProperties("Select Directory or Filesystem", "LibrarySearchDirectory", GhidraFileChooserMode.FILES_AND_DIRECTORIES, false, null); - return tablePanel; + return panel; } @Override diff --git a/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DecompilerDataTypeReferenceFinder.java b/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DecompilerDataTypeReferenceFinder.java index e06a7475d57..b3de9e39ed0 100644 --- a/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DecompilerDataTypeReferenceFinder.java +++ b/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DecompilerDataTypeReferenceFinder.java @@ -129,6 +129,20 @@ private Set filterFunctions(Program program, DataType dt, TaskMonitor callers.addAll(callingFunctions); } + results.addAll(callers); + + // Add any callers to external function that use any form of the data type + it = listing.getExternalFunctions(); + callers = new HashSet<>(); + for (Function f : it) { + monitor.checkCancelled(); + + if (usesAnyType(f, types)) { + Set callingFunctions = f.getCallingFunctions(monitor); + callers.addAll(callingFunctions); + } + } + results.addAll(callers); return results; diff --git a/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/VariableAccessDR.java b/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/VariableAccessDR.java index c7b7981f9f9..cb62fd64d2c 100644 --- a/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/VariableAccessDR.java +++ b/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/VariableAccessDR.java @@ -188,11 +188,11 @@ private DecompilerVariable getMatchingVarialbe(DataType dt, DecompilerVariable v // the thing that contains it. So, if you have: // foo.bar // then the 'bar' field will have a data type of Foo. Unfortunately, this is not always - // the case. For now, when the variable is global, we need to check the field. Sad face + // the case. For now, if there is a high variable, we need to check the field. Sad face // emoji. // HighVariable highVariable = var.variable.getHighVariable(); - if (highVariable instanceof HighGlobal) { + if (highVariable != null) { if (matchesParentType(potentialField, dt)) { DtrfDbg.println(this, indent + "MATCHED on parent type: " + dt); return potentialField; diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/onetomany/VTMatchOneToManyTableProvider.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/onetomany/VTMatchOneToManyTableProvider.java index a3019f2a23e..256d94cb983 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/onetomany/VTMatchOneToManyTableProvider.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/onetomany/VTMatchOneToManyTableProvider.java @@ -15,30 +15,15 @@ */ package ghidra.feature.vt.gui.provider.onetomany; -import java.awt.Adjustable; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Rectangle; +import java.awt.*; import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.HashSet; +import java.util.*; import java.util.List; -import java.util.Set; - -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollBar; -import javax.swing.JTable; -import javax.swing.JToggleButton; -import javax.swing.ListSelectionModel; + +import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; +import javax.swing.table.*; import docking.ActionContext; import docking.action.builder.ActionBuilder; @@ -50,30 +35,17 @@ import generic.theme.GIcon; import ghidra.app.services.FunctionComparisonService; import ghidra.feature.vt.api.impl.VTEvent; -import ghidra.feature.vt.api.main.VTMarkupItem; -import ghidra.feature.vt.api.main.VTMatch; -import ghidra.feature.vt.api.main.VTSession; -import ghidra.feature.vt.gui.actions.AcceptMatchAction; -import ghidra.feature.vt.gui.actions.ClearMatchAction; -import ghidra.feature.vt.gui.actions.SetVTMatchFromOneToManyAction; -import ghidra.feature.vt.gui.filters.Filter; +import ghidra.feature.vt.api.main.*; +import ghidra.feature.vt.gui.actions.*; +import ghidra.feature.vt.gui.filters.*; import ghidra.feature.vt.gui.filters.Filter.FilterEditingStatus; -import ghidra.feature.vt.gui.filters.FilterDialogModel; -import ghidra.feature.vt.gui.filters.FilterStatusListener; -import ghidra.feature.vt.gui.plugin.VTController; -import ghidra.feature.vt.gui.plugin.VTControllerListener; -import ghidra.feature.vt.gui.plugin.VTPlugin; -import ghidra.feature.vt.gui.plugin.VTSubToolManager; -import ghidra.feature.vt.gui.plugin.VTSubToolManagerListener; +import ghidra.feature.vt.gui.plugin.*; import ghidra.feature.vt.gui.provider.markuptable.DisplayableListingAddress; import ghidra.feature.vt.gui.provider.matchtable.MatchTableRenderer; import ghidra.feature.vt.gui.util.AbstractVTMatchTableModel.StatusTableColumn; import ghidra.feature.vt.gui.util.MatchInfo; import ghidra.feature.vt.gui.util.MatchStatusRenderer; -import ghidra.framework.model.DomainObjectChangeRecord; -import ghidra.framework.model.DomainObjectChangedEvent; -import ghidra.framework.model.DomainObjectEvent; -import ghidra.framework.model.EventType; +import ghidra.framework.model.*; import ghidra.framework.options.Options; import ghidra.framework.plugintool.ComponentProviderAdapter; import ghidra.framework.plugintool.PluginTool; @@ -184,6 +156,8 @@ private boolean isValidFunctionComparison(VTMatchOneToManyContext context) { private void compareFunctions(VTMatchOneToManyContext c) { List selectedMatches = c.getSelectedMatches(); + Set leftFunctions = new HashSet<>(); + Set rightFunctions = new HashSet<>(); for (VTMatch match : selectedMatches) { MatchInfo matchInfo = controller.getMatchInfo(match); @@ -196,10 +170,16 @@ private void compareFunctions(VTMatchOneToManyContext c) { leftFunction = matchInfo.getDestinationFunction(); rightFunction = matchInfo.getSourceFunction(); } + leftFunctions.add(leftFunction); + rightFunctions.add(rightFunction); - FunctionComparisonService service = tool.getService(FunctionComparisonService.class); - service.compareFunctions(leftFunction, rightFunction); } + // NOTE: in this case the left functions will always be the same function (ie the one in the + // current codebrowser) so leftFunctions will be size one. The rightFunctions will be one or + // more since the src/dst match tables contain all possible matches to the current listing + // function. + FunctionComparisonService service = tool.getService(FunctionComparisonService.class); + service.compareFunctions(leftFunctions, rightFunctions); } @Override diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/pathmanager/AbstractPathsDialog.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/pathmanager/AbstractPathsDialog.java index e84f294cd2f..78780035d19 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/pathmanager/AbstractPathsDialog.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/pathmanager/AbstractPathsDialog.java @@ -15,8 +15,6 @@ */ package docking.widgets.pathmanager; -import javax.swing.JComponent; - import docking.DialogComponentProvider; public abstract class AbstractPathsDialog extends DialogComponentProvider { @@ -26,7 +24,7 @@ public abstract class AbstractPathsDialog extends DialogComponentProvider { protected AbstractPathsDialog(String title) { super(title); tablePanel = newPathnameTablePanel(); - addWorkPanel(buildWorkPanel()); + addWorkPanel(tablePanel); addOKButton(); addCancelButton(); setPreferredSize(600, 400); @@ -44,11 +42,6 @@ protected void reset() { tablePanel.setPaths(paths); } - protected JComponent buildWorkPanel() { - reset(); - return tablePanel; - } - @Override protected void okCallback() { String[] paths = tablePanel.getPaths();