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

public record GoSymbolName(String symbolName, String packagePath, String packageName, String receiverString) extends Record
Represents a Golang symbol name.
  • Constructor Details

    • GoSymbolName

      public GoSymbolName(String symbolName, String packagePath, String packageName, String receiverString)
      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
  • 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
    • parse

      public static GoSymbolName parse(String s)
      Parses a golang symbol string and returns a GoSymbolName instance.
      Parameters:
      s - string to parse
      Returns:
      new GoSymbolName instance, never null
    • 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
    • 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
    • getRecieverString

      public String getRecieverString()
      Returns portion of the symbol name that is the receiver string (only found when the receiver is in the form of "(*typename)"), or null
      Returns:
      portion of the symbol name that is the receiver string (only found when the receiver is in the form of "(*typename)"), or null
    • getSymbolName

      public String getSymbolName()
      Returns the full name of the golang symbol
      Returns:
      full name of the golang symbol
    • 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
    • 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
    • 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