java.lang.Object
ghidra.app.util.bin.format.golang.rtti.types.GoType
All Implemented Interfaces:
StructureMarkup<GoType>, StructureVerifier
Direct Known Subclasses:
GoArrayType, GoChanType, GoFuncType, GoInterfaceType, GoMapType, GoPlainType, GoPointerType, GoSliceType, GoStructType, GoTypeBridge

public abstract class GoType extends Object implements StructureMarkup<GoType>, StructureVerifier
Common abstract base class for GoType classes
  • Field Details

  • Constructor Details

    • GoType

      public GoType()
  • Method Details

    • getSpecializedTypeClass

      public static Class<? extends GoType> getSpecializedTypeClass(GoRttiMapper programContext, long offset) throws IOException
      Returns the specific GoType derived class that will handle the go type located at the specified offset.
      Parameters:
      programContext - program-level mapper context
      offset - absolute location of go type struct
      Returns:
      GoType class that will best handle the type struct
      Throws:
      IOException - if error reading
    • getBaseType

      protected GoBaseType getBaseType()
    • getTypeOffset

      public long getTypeOffset()
      Returns the starting offset of this type, used as an identifier.
      Returns:
      starting offset of this type
    • getName

      public String getName()
      Returns the name of this type.
      Returns:
      name of this type
    • getSymbolName

      public GoSymbolName getSymbolName()
    • getFullyQualifiedName

      public String getFullyQualifiedName()
    • getPackagePathString

      public String getPackagePathString()
      Returns the package path of this type.
      Returns:
      package path of this type
    • getDebugId

      public String getDebugId()
    • getOffsetEndOfFullType

      protected long getOffsetEndOfFullType()
    • getEndOfTypeInfo

      public long getEndOfTypeInfo() throws IOException
      Returns the location of where this type object, and any known associated optional structures ends.
      Returns:
      index location of end of this type object
      Throws:
      IOException - if error reading
    • getUncommonType

      public GoUncommonType getUncommonType() throws IOException
      Throws:
      IOException
    • getMethodInfoList

      public List<GoMethod.GoMethodInfo> getMethodInfoList() throws IOException
      Returns a list of all methods defined on this type. Methods that specify both a "tfn" address as well as a "ifn" address will be represented twice.
      Returns:
      list of MethodInfo's
      Throws:
      IOException - if error reading
    • getStructureContext

      public StructureContext<GoType> getStructureContext()
      Specified by:
      getStructureContext in interface StructureMarkup<GoType>
    • getStructureLabel

      public String getStructureLabel() throws IOException
      Description copied from interface: StructureMarkup
      Returns a string that can be used to place a label on the instance.

      This default implementation will query the StructureMarkup.getStructureName() method, and if it provides a value, will produce a string that looks like "name___mappingstructname", where "mappingstructname" will be the structureName value in the @StructureMapping annotation.

      Specified by:
      getStructureLabel in interface StructureMarkup<GoType>
      Returns:
      string to be used as a label, or null if there is not a valid label for the instance
      Throws:
      IOException - if error getting label
    • getStructureName

      public String getStructureName() throws IOException
      Description copied from interface: StructureMarkup
      Returns the name of the instance, typically retrieved from data found inside the instance.
      Specified by:
      getStructureName in interface StructureMarkup<GoType>
      Returns:
      string name, or null if this instance does not have a name
      Throws:
      IOException - if error getting name
    • getStructureNamespace

      public String getStructureNamespace() throws IOException
      Description copied from interface: StructureMarkup
      Returns the namespace that any labels should be placed in.
      Specified by:
      getStructureNamespace in interface StructureMarkup<GoType>
      Returns:
      name of namespace to place the label for this structure mapped type, or null
      Throws:
      IOException - if error generating namespace name
    • additionalMarkup

      public void additionalMarkup(MarkupSession session) throws IOException, CancelledException
      Description copied from interface: StructureMarkup
      Called to allow the implementor to perform custom markup of itself.
      Specified by:
      additionalMarkup in interface StructureMarkup<GoType>
      Parameters:
      session - state and methods to assist marking up the program
      Throws:
      IOException - if error during markup
      CancelledException - if cancelled
    • getImplementsInterfaceString

      protected String getImplementsInterfaceString()
    • getMethodListString

      protected String getMethodListString() throws IOException
      Throws:
      IOException
    • getMethodPrototypeString

      public String getMethodPrototypeString(String methodName, GoFuncType funcdefType)
    • getMethodPrototypeString

      public String getMethodPrototypeString(String recvStr, String methodName, GoFuncType funcdefType)
    • getTypeDeclString

      protected String getTypeDeclString() throws IOException
      Returns a descriptive string that defines the declaration of this type.

      This method should be overloaded by more specific types.

      Returns:
      descriptive string
      Throws:
      IOException - if error reading data
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • recoverDataType

      public DataType recoverDataType(GoTypeManager goTypes) throws IOException
      Converts a golang RTTI type structure into a Ghidra data type.

      This default implementation just creates an opaque blob of the appropriate size

      Parameters:
      goTypes - GoTypeManager
      Returns:
      DataType that represents the golang type
      Throws:
      IOException - if error getting name of the type
    • discoverGoTypes

      public boolean discoverGoTypes(Set<Long> discoveredTypes) throws IOException
      Iterates this type, and any types this type refers to, while registering the types with the GoRttiMapper context.

      This method should be overloaded by derived type classes to add any additional types referenced by the derived type.

      Parameters:
      discoveredTypes - set of already iterated types
      Returns:
      boolean boolean flag, if false the type has already been discovered, if true the type was encountered for the first time
      Throws:
      IOException - if error reading type info
    • isValid

      public boolean isValid()
      Specified by:
      isValid in interface StructureVerifier