Record Class GoSymbolName

java.lang.Object
java.lang.Record
ghidra.app.util.bin.format.golang.rtti.GoSymbolName
Record Components:
symbolName - full name of the golang symbol
packagePath - portion the symbol name that is the packagePath (path+packagename), or null
packageName - portion of the symbol name that is the package name, or null
receiverString - portion of the symbol name that is the receiver string (only found when the receiver is in the form of "(*typename)"), or null
genericInfo - portion of the symbol name found inside of a generics "[blah]"
baseName - symbol base name
prefix - portion of the symbol name that was prepended to the main symbol info
symtype - GoSymbolNameType enum specifying what kind of object this name is referencing

public record GoSymbolName(String symbolName, String packagePath, String packageName, String receiverString, String genericInfo, String baseName, String prefix, GoSymbolNameType symtype) extends Record
Represents a Golang symbol name.

Handles formats such as:

"package/domain.name/packagename.(*ReceiverTypeName).Functionname" or "package/domain.name/packagename.(*ReceiverTypeName[genericinfo { method(); fieldname fieldtype; }]).Functionname" or "package/domain.name/packagename.Functionname[genericinfo]" or "type:.eq.[39]package/domain.name/packagename.Functionname"

  • Constructor Details

    • GoSymbolName

      public GoSymbolName(String symbolName, String packagePath, String packageName, String receiverString, String genericInfo, String baseName, String prefix, GoSymbolNameType symtype)
      Creates an instance of a GoSymbolName record class.
      Parameters:
      symbolName - the value for the symbolName record component
      packagePath - the value for the packagePath record component
      packageName - the value for the packageName record component
      receiverString - the value for the receiverString record component
      genericInfo - the value for the genericInfo record component
      baseName - the value for the baseName record component
      prefix - the value for the prefix record component
      symtype - the value for the symtype record component
  • Method Details

    • fixGolangSpecialSymbolnameChars

      public static String fixGolangSpecialSymbolnameChars(String s)
      Fixes the specified string if it contains any of the golang special symbolname characters: middle-dot and the weird slash.
      Parameters:
      s - string to fix
      Returns:
      original string, or fixed version
    • parseTypeName

      public static GoSymbolName parseTypeName(String s, String packagePath)
    • parse

      public static GoSymbolName parse(String s)
    • from

      public static GoSymbolName from(String packageName, String symbolName)
      Constructs a minimal GoSymbolName instance from the supplied values.
      Parameters:
      packageName - package name, does not handle package paths, eg. "runtime"
      symbolName - full symbol name, eg. "runtime.foo"
      Returns:
      new GoSymbolName instance
    • fromPackagePath

      public static GoSymbolName fromPackagePath(String packagePath)
      Constructs a GoSymbolName instance that only has a package path / package name.
      Parameters:
      packagePath - package path to parse
      Returns:
      GoSymbolName that only has a package path and package name value
    • isMethod

      public boolean isMethod()
    • hasGenerics

      public boolean hasGenerics()
    • isUnparsed

      public boolean isUnparsed()
    • isAnonType

      public boolean isAnonType()
    • getPackagePath

      public String getPackagePath()
      Returns the portion the symbol name that is the packagePath (path+packagename), or null
      Returns:
      the portion the symbol name that is the packagePath (path+packagename), or null
    • getPackageName

      public String getPackageName()
      Returns portion of the symbol name that is the package name, or null
      Returns:
      portion of the symbol name that is the package name, or null
    • hasReceiver

      public boolean hasReceiver()
    • getReceiverString

      public String getReceiverString()
      Returns portion of the symbol name that is the receiver string, or null
      Returns:
      portion of the symbol name that is the receiver string, or null
    • getReceiverString

      public String getReceiverString(String modifiedGenerics)
    • getReceiverTypeName

      public GoSymbolName getReceiverTypeName()
    • getReceiverTypeName

      public GoSymbolName getReceiverTypeName(String modifiedGenerics)
    • getShapelessGenericsString

      public String getShapelessGenericsString()
    • getStrippedReceiverString

      public String getStrippedReceiverString()
    • getGenericsString

      public String getGenericsString()
    • getGenericParts

      public List<String> getGenericParts()
    • getStrippedSymbolString

      public String getStrippedSymbolString()
    • asNonPtrReceiverSymbolName

      public GoSymbolName asNonPtrReceiverSymbolName()
      Returns a new GoSymbolName instance with the current instance's information (which should be without receiver info) re-interpreted to be a non-pointer receiver symbol.

      Example, symbol "package.name1.name2" would normally be parsed as a non-receiver symbol with a complex basename of "name1.name2", and this method will return a version that is equivalent of "package.(name1).name2".

      Returns:
      new GoSymbolName
    • isNonPtrReceiverCandidate

      public boolean isNonPtrReceiverCandidate()
    • asString

      public String asString()
      Returns the full name of the golang symbol
      Returns:
      full name of the golang symbol
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • getBaseName

      public String getBaseName()
    • getBaseTypeName

      public String getBaseTypeName()
    • getNameType

      public GoSymbolNameType getNameType()
    • getPrefix

      public String getPrefix()
    • getTypePrefixSubKeyword

      public String getTypePrefixSubKeyword()
    • getTruncatedPackagePath

      public String getTruncatedPackagePath()
      Returns the portion of the package path before the package name, eg. "internal/sys" would become "internal/".
      Returns:
      package path, without the trailing package name, or empty string if there is no path portion of the string
    • getSymbolNamespace

      public Namespace getSymbolNamespace(Program program)
      Returns a Ghidra Namespace based on the golang package path.
      Parameters:
      program - Program that will contain the namespace
      Returns:
      Namespace cooresponding to the golang package path, or the program's root namespace if no package path information is present
    • getFunction

      public Function getFunction(Program program)
      Returns the matching Ghidra function (based on namespace and symbol name).
      Parameters:
      program - Program containing the function
      Returns:
      Ghidra Function
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • symbolName

      public String symbolName()
      Returns the value of the symbolName record component.
      Returns:
      the value of the symbolName record component
    • packagePath

      public String packagePath()
      Returns the value of the packagePath record component.
      Returns:
      the value of the packagePath record component
    • packageName

      public String packageName()
      Returns the value of the packageName record component.
      Returns:
      the value of the packageName record component
    • receiverString

      public String receiverString()
      Returns the value of the receiverString record component.
      Returns:
      the value of the receiverString record component
    • genericInfo

      public String genericInfo()
      Returns the value of the genericInfo record component.
      Returns:
      the value of the genericInfo record component
    • baseName

      public String baseName()
      Returns the value of the baseName record component.
      Returns:
      the value of the baseName record component
    • prefix

      public String prefix()
      Returns the value of the prefix record component.
      Returns:
      the value of the prefix record component
    • symtype

      public GoSymbolNameType symtype()
      Returns the value of the symtype record component.
      Returns:
      the value of the symtype record component