Skip to content

Commit 6cca357

Browse files
author
astrelsky
committed
Changed CategoryPath location for build types
1 parent b6f24a7 commit 6cca357

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

src/main/java/ghidra/app/cmd/data/rtti/AbstractCppClassBuilder.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.stream.IntStream;
77

88
import ghidra.app.cmd.data.rtti.gcc.ClassTypeInfoUtils;
9+
import ghidra.app.cmd.data.rtti.gcc.TypeInfoUtils;
910
import ghidra.program.model.data.CategoryPath;
1011
import ghidra.program.model.data.DataType;
1112
import ghidra.program.model.data.DataTypeComponent;
@@ -25,10 +26,10 @@ public abstract class AbstractCppClassBuilder {
2526

2627
protected static final String SUPER = "super_";
2728

28-
private Program program;
29+
private final Program program;
2930
protected Structure struct;
30-
private CategoryPath path;
31-
private ClassTypeInfo type;
31+
private final CategoryPath path;
32+
private final ClassTypeInfo type;
3233

3334
private Map<CompositeDataTypeElementInfo, String> dtComps = Collections.emptyMap();
3435

@@ -38,7 +39,7 @@ protected AbstractCppClassBuilder(ClassTypeInfo type) {
3839
this.program = gc.getSymbol().getProgram();
3940
this.struct = ClassTypeInfoUtils.getPlaceholderStruct(type, program.getDataTypeManager());
4041
this.struct = resolveStruct(struct);
41-
this.path = new CategoryPath(struct.getCategoryPath(), type.getName());
42+
this.path = new CategoryPath(TypeInfoUtils.getCategoryPath(type), type.getName());
4243
}
4344

4445
protected abstract AbstractCppClassBuilder getParentBuilder(ClassTypeInfo parent);
@@ -47,10 +48,6 @@ protected ClassTypeInfo getType() {
4748
return type;
4849
}
4950

50-
protected CategoryPath getPath() {
51-
return path;
52-
}
53-
5451
protected final Program getProgram() {
5552
return program;
5653
}

src/main/java/ghidra/app/cmd/data/rtti/gcc/ClassTypeInfoUtils.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -355,23 +355,10 @@ public static void sortByMostDerived(Program program, List<ClassTypeInfo> classe
355355
* @return the ClassTypeInfo's _vptr DataType
356356
*/
357357
public static DataType getVptrDataType(Program program, ClassTypeInfo type) {
358-
return getVptrDataType(program, type, null);
359-
}
360-
361-
/**
362-
* Gets the DataType representation of the _vptr for the specified ClassTypeInfo.
363-
* @param program the program containing the ClassTypeInfo
364-
* @param type the ClassTypeInfo
365-
* @param path The category path to place the datatype in.
366-
* @return the ClassTypeInfo's _vptr DataType
367-
*/
368-
public static DataType getVptrDataType(Program program, ClassTypeInfo type, CategoryPath path) {
369358
try {
370359
Vtable vtable = type.getVtable();
371-
if (path == null) {
372-
path = TypeInfoUtils.getDataTypePath(type).getCategoryPath();
373-
}
374-
path = new CategoryPath(path, type.getName());
360+
CategoryPath path =
361+
new CategoryPath(TypeInfoUtils.getCategoryPath(type), type.getName());
375362
DataTypeManager dtm = program.getDataTypeManager();
376363
Structure struct = new StructureDataType(path, VtableModel.SYMBOL_NAME, 0, dtm);
377364
Function[][] functionTable = vtable.getFunctionTables();
@@ -406,6 +393,19 @@ public static DataType getVptrDataType(Program program, ClassTypeInfo type, Cate
406393
}
407394
}
408395

396+
/**
397+
* Gets the DataType representation of the _vptr for the specified ClassTypeInfo.
398+
* @param program the program containing the ClassTypeInfo
399+
* @param type the ClassTypeInfo
400+
* @param path The category path to place the datatype in.
401+
* @return the ClassTypeInfo's _vptr DataType
402+
* @deprecated the path parameter is now ignored
403+
*/
404+
@Deprecated(forRemoval=true)
405+
public static DataType getVptrDataType(Program program, ClassTypeInfo type, CategoryPath path) {
406+
return getVptrDataType(program, type);
407+
}
408+
409409
public static Map<ClassTypeInfo, Integer> getBaseOffsets(ClassTypeInfo type) {
410410
if (!type.hasParent()) {
411411
return Collections.emptyMap();

src/main/java/ghidra/app/cmd/data/rtti/gcc/GccCppClassBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected void addVptr(Structure struct) {
3030
if (!Vtable.isValid(getType().getVtable())) {
3131
return;
3232
}
33-
DataType vptr = ClassTypeInfoUtils.getVptrDataType(getProgram(), getType(), getPath());
33+
DataType vptr = ClassTypeInfoUtils.getVptrDataType(getProgram(), getType());
3434
DataTypeComponent comp = struct.getComponentAt(0);
3535
if (comp == null || isUndefined(comp.getDataType())) {
3636
if (vptr != null) {

0 commit comments

Comments
 (0)