Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-2217 corrected datatype preview issues for composites and function definitions.

ghidra1ed685f66b0a3
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/html/CompositeDataTypeHTMLRepresentation.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/html/CompositeDataTypeHTMLRepresentation.java
index 2346a9b91a..745b7fded1 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/html/CompositeDataTypeHTMLRepresentation.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/html/CompositeDataTypeHTMLRepresentation.java
@@ -125,13 +125,11 @@ public class CompositeDataTypeHTMLRepresentation extends HTMLDataTypeRepresentat
DataType dataType = dataTypeComponent.getDataType();
String type = "<unknown type>";
- DataType locatableType = null;
if (dataType != null) {
type = dataType.getDisplayName();
- locatableType = getLocatableDataType(dataType);
}
- list.add(new DataTypeLine(fieldName, type, comment, locatableType));
+ list.add(new DataTypeLine(fieldName, type, comment, dataType));
if (count++ >= MAX_COMPONENT_COUNT) {
// Prevent a ridiculous number of components from consuming all memory.
list.add(
@@ -344,7 +342,7 @@ public class CompositeDataTypeHTMLRepresentation extends HTMLDataTypeRepresentat
String type = truncateAsNecessary(line.getType());
type = friendlyEncodeHTML(type);
- return wrapStringInColor(type, line.getTypeColor());
+ return wrapStringInColor(type, color);
}
// overridden to return truncated text by default
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/html/FunctionDataTypeHTMLRepresentation.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/html/FunctionDataTypeHTMLRepresentation.java
index fac622d5db..c927613963 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/html/FunctionDataTypeHTMLRepresentation.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/html/FunctionDataTypeHTMLRepresentation.java
@@ -15,11 +15,13 @@
*/
package ghidra.app.util.html;
+import static ghidra.util.HTMLUtilities.*;
+
+import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import ghidra.app.util.ToolTipUtils;
-import ghidra.app.util.datatype.DataTypeUrl;
import ghidra.app.util.html.diff.DataTypeDiff;
import ghidra.app.util.html.diff.DataTypeDiffBuilder;
import ghidra.program.model.data.*;
@@ -130,9 +132,8 @@ public class FunctionDataTypeHTMLRepresentation extends HTMLDataTypeRepresentati
String displayName = dataType.getDisplayName();
String name = var.getName();
- DataType locatableType = getLocatableDataType(dataType);
lines.add(new VariableTextLine(HTMLUtilities.friendlyEncodeHTML(displayName),
- HTMLUtilities.friendlyEncodeHTML(name), locatableType));
+ HTMLUtilities.friendlyEncodeHTML(name), dataType));
}
return lines;
@@ -242,23 +243,15 @@ public class FunctionDataTypeHTMLRepresentation extends HTMLDataTypeRepresentati
private static String generateTypeText(VariableTextLine line, boolean trim) {
- String type = line.getVariableType();
- if (trim) {
- type = StringUtilities.trimMiddle(type, ToolTipUtils.LINE_LENGTH);
- }
- type = wrapStringInColor(type, line.getVariableTypeColor());
-
- if (!line.hasUniversalId()) {
- return type;
+ Color color = line.getVariableTypeColor();
+ DataType dt = line.getDataType();
+ if (dt != null) {
+ return generateTypeName(dt, color, trim);
}
- //
- // Markup the name with info for later hyperlink capability, as needed by the client
- //
- DataType dataType = line.getDataType();
- DataTypeUrl url = new DataTypeUrl(dataType);
- String wrapped = HTMLUtilities.wrapWithLinkPlaceholder(type, url.toString());
- return wrapped;
+ String type = truncateAsNecessary(line.getVariableType());
+ type = friendlyEncodeHTML(type);
+ return wrapStringInColor(type, color);
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/html/HTMLDataTypeRepresentation.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/html/HTMLDataTypeRepresentation.java
index 2638be1951..2c2c0143bb 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/html/HTMLDataTypeRepresentation.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/html/HTMLDataTypeRepresentation.java
@@ -288,31 +288,6 @@ public abstract class HTMLDataTypeRepresentation {
return newList;
}
- /* Returns a data type that can later be located */
- protected static DataType getLocatableDataType(DataType type) {
-
- if (type instanceof DefaultDataType) {
- return null; // special case; for some reason this type has a universal ID
- }
-
- UniversalID id = type.getUniversalID();
- if (id == null) {
- type = DataTypeUtils.getNamedBaseDataType(type);
- id = type.getUniversalID();
- }
-
- if (id == null) {
- return null;
- }
-
- DataTypeManager manager = type.getDataTypeManager();
- if (manager == null) {
- return null;
- }
-
- return type;
- }
-
protected String originalHTMLData;
/** Default constructor for those who promise to later set the HTML text */