Ghidra is a software reverse engineering (SRE) framework
GP-2308 - Function Call Graph - Added an option to disable name truncation.
dragonmacher87856369399f
diff --git a/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/graph/FcgVertex.java b/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/graph/FcgVertex.javaindex 0a19e65b75..a93e17bba4 100644--- a/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/graph/FcgVertex.java+++ b/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/graph/FcgVertex.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -28,6 +28,7 @@ import javax.swing.border.LineBorder;import docking.widgets.EmptyBorderButton;import docking.widgets.label.GDLabel;+import functioncalls.plugin.FcgOptions;import generic.theme.GColor;import generic.theme.GThemeDefaults.Colors.Palette;import generic.theme.Gui;@@ -94,6 +95,7 @@ public class FcgVertex extends AbstractVisualVertex implements VertexShapeProvidprivate Paint outPaint;private FcgLevel level;+ private FcgOptions options;/*** Constructor@@ -101,11 +103,13 @@ public class FcgVertex extends AbstractVisualVertex implements VertexShapeProvid* @param function the function represented by this vertex* @param level the level of this vertex* @param expansionListener the listener for expanding connections to this vertex+ * @param options the tool options*/public FcgVertex(Function function, FcgLevel level,- FcgVertexExpansionListener expansionListener) {+ FcgVertexExpansionListener expansionListener, FcgOptions options) {this.function = function;this.level = level;+ this.options = options;Objects.requireNonNull(expansionListener);toggleInsButton.addActionListener(e -> {@@ -154,8 +158,13 @@ public class FcgVertex extends AbstractVisualVertex implements VertexShapeProvidcreatePaints();// init the components- String truncated = StringUtilities.trimMiddle(getName(), MAX_NAME_LENGTH);- nameLabel.setText(truncated);+ boolean truncate = options.useTruncatedFunctionNames();+ String name = getName();+ if (truncate) {+ name = StringUtilities.trimMiddle(getName(), MAX_NAME_LENGTH);+ }++ nameLabel.setText(name);buildVertexShape();// calculate the needed sizediff --git a/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/plugin/FcgOptions.java b/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/plugin/FcgOptions.javanew file mode 100644index 0000000000..b92cca19dd--- /dev/null+++ b/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/plugin/FcgOptions.java@@ -0,0 +1,51 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package functioncalls.plugin;++import ghidra.framework.options.Options;+import ghidra.graph.viewer.options.VisualGraphOptions;+import ghidra.util.HelpLocation;++public class FcgOptions extends VisualGraphOptions {++ public static final String FUNCTION_NAME_TRUNCATION_KEY = "Truncate Function Name";+ public static final String FUNCTDION_NAME_TRUNCTION_DESCRIPTION =+ "Long function names will be truncated";++ private boolean useTruncatedFunctionNames = true;++ public boolean useTruncatedFunctionNames() {+ return useTruncatedFunctionNames;+ }++ public void setUseTruncatedFunctionNames(boolean b) {+ this.useTruncatedFunctionNames = b;+ }++ @Override+ public void registerOptions(Options options, HelpLocation help) {+ super.registerOptions(options, help);++ options.registerOption(FUNCTION_NAME_TRUNCATION_KEY, useTruncatedFunctionNames(), help,+ FUNCTDION_NAME_TRUNCTION_DESCRIPTION);+ }++ @Override+ public void loadOptions(Options options) {+ useTruncatedFunctionNames =+ options.getBoolean(FUNCTION_NAME_TRUNCATION_KEY, useTruncatedFunctionNames);+ }+}diff --git a/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/plugin/FcgProvider.java b/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/plugin/FcgProvider.javaindex 6fdaa11ffe..6abd443815 100644--- a/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/plugin/FcgProvider.java+++ b/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/plugin/FcgProvider.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -240,7 +240,9 @@ public class FcgProvidersetLayout(graph);FcgLevel source = FcgLevel.sourceLevel();- FcgVertex sourceVertex = new FcgVertex(graphData.getFunction(), source, expansionListener);+ FcgOptions options = plugin.getOptions();+ FcgVertex sourceVertex =+ new FcgVertex(graphData.getFunction(), source, expansionListener, options);graph.setSource(sourceVertex);trackFunctionEdges(sourceVertex);@@ -264,7 +266,8 @@ public class FcgProviderreturn v;}- v = new FcgVertex(f, level, expansionListener);+ FcgOptions options = plugin.getOptions();+ v = new FcgVertex(f, level, expansionListener, options);trackFunctionEdges(v);return v;}diff --git a/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/plugin/FunctionCallGraphPlugin.java b/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/plugin/FunctionCallGraphPlugin.javaindex 3e95ee994e..85afabc6e8 100644--- a/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/plugin/FunctionCallGraphPlugin.java+++ b/Ghidra/Features/GraphFunctionCalls/src/main/java/functioncalls/plugin/FunctionCallGraphPlugin.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -26,11 +26,10 @@ import ghidra.framework.options.*;import ghidra.framework.plugintool.PluginInfo;import ghidra.framework.plugintool.PluginTool;import ghidra.framework.plugintool.util.PluginStatus;-import ghidra.graph.viewer.options.VisualGraphOptions;import ghidra.program.model.address.Address;import ghidra.program.util.ProgramLocation;import ghidra.util.HelpLocation;-import ghidra.util.SystemUtilities;+import ghidra.util.Swing;import ghidra.util.bean.opteditor.OptionsVetoException;import ghidra.util.task.SwingUpdateManager;@@ -55,7 +54,7 @@ public class FunctionCallGraphPlugin extends ProgramPlugin implements OptionsChaFunctionCallGraphPlugin.class.getSimpleName());private FcgProvider provider;- private VisualGraphOptions vgOptions = new VisualGraphOptions();+ private FcgOptions fcgOptions = new FcgOptions();// enough time for users to click around without the graph starting its workprivate static final int MIN_UPDATE_DELAY = 750;@@ -83,8 +82,8 @@ public class FunctionCallGraphPlugin extends ProgramPlugin implements OptionsChaHelpLocation help = new HelpLocation(getName(), "Options");Options callGraphOptions = options.getOptions(NAME);- vgOptions.registerOptions(callGraphOptions, help);- vgOptions.loadOptions(callGraphOptions);+ fcgOptions.registerOptions(callGraphOptions, help);+ fcgOptions.loadOptions(callGraphOptions);provider.optionsChanged();}@@ -93,7 +92,7 @@ public class FunctionCallGraphPlugin extends ProgramPlugin implements OptionsChaObject newValue) throws OptionsVetoException {Options callGraphOptions = options.getOptions(NAME);- vgOptions.loadOptions(callGraphOptions);+ fcgOptions.loadOptions(callGraphOptions);provider.optionsChanged();}@@ -128,7 +127,7 @@ public class FunctionCallGraphPlugin extends ProgramPlugin implements OptionsCha}// do later so the current event processing can finish- SystemUtilities.runSwingLater(() -> {+ Swing.runLater(() -> {goTo.goTo(location);});}@@ -168,7 +167,7 @@ public class FunctionCallGraphPlugin extends ProgramPlugin implements OptionsChareturn currentLocation;}- VisualGraphOptions getOptions() {- return vgOptions;+ FcgOptions getOptions() {+ return fcgOptions;}}