Package ghidra.app.util.bin.format.golang.rtti

# Class GoFuncData

java.lang.Object
ghidra.app.util.bin.format.golang.rtti.GoFuncData

All Implemented Interfaces:
  `StructureMarkup<GoFuncData>`

public class GoFuncData extends Object implements StructureMarkup<GoFuncData>
A structure that Go generates that contains metadata about a function.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GoFuncData()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `additionalMarkup(MarkupSession session)`
  Called to allow the implementor to perform custom markup of itself.
  `AddressRange`
  `getBody()`
  Returns the address range of this function's body, recovered by examining addresses in the function's pc-to-filename translation table, or if not present, a single address range that contains the function's entry point.
  `Address`
  `getDeferreturnAddress()`
  `String`
  `getDescription()`
  Returns a descriptive string.
  `Set<GoFuncFlag>`
  `getFlags()`
  Returns the `GoFuncFlag` func flags for this function.
  `Address`
  `getFuncAddress()`
  Returns the address of this function.
  `long`
  `getFuncDataValue(GoFuncDataTable tableIndex)`
  Returns a value associated with this function.
  `Function`
  `getFunction()`
  Returns the Ghidra function that corresponds to this Go function.
  `GoModuledata`
  `getModuledata()`
  Returns a reference to the `GoModuledata` that contains this function.
  `String`
  `getName()`
  Returns the name of this function.
  `Address`
  `getNameAddress()`
  Returns the address of this function's name string.
  `int`
  `getPcDataValue(GoPcDataTable tableIndex, long targetPC)`
  Returns a value from the specified pc->value lookup table, for a specific address (that should be within the function's footprint).
  `List<Integer>`
  `getPcDataValues(GoPcDataTable tableIndex)`
  Returns all values for the specified pc->value lookup table for the entire range of the function's footprint.
  `GoSourceFileInfo`
  `getSourceFileInfo()`
  Returns information about the source file that this function was defined in.
  `StructureContext<GoFuncData>`
  `getStructureContext()`
  `String`
  `getStructureLabel()`
  Returns a string that can be used to place a label on the instance.
  `String`
  `getStructureName()`
  Returns the name of the instance, typically retrieved from data found inside the instance.
  `String`
  `getStructureNamespace()`
  Returns the namespace that any labels should be placed in.
  `GoSymbolName`
  `getSymbolName()`
  Returns the name of this function, as a parsed `GoSymbolName` symbol object.
  `boolean`
  `isAsmFunction()`
  Returns true if this function is an ASM function.
  `boolean`
  `isInline()`
  Returns true if this function is inline.
  `void`
  `markupSourceFileInfo()`
  `String`
  `recoverFunctionSignature()`
  Attempts to build a 'function signature' string representing the known information about this function's arguments, using go's built-in stack trace metadata.
  `void`
  `setEntry(long entry)`
  Sets the absolute entry address.
  `void`
  `setEntryoff(long entryoff)`
  Sets the function's entry point via a relative offset value
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface ghidra.app.util.bin.format.golang.structmapping.StructureMarkup

  `getExternalInstancesToMarkup`

- ## Constructor Details

  - ### GoFuncData

    public GoFuncData()

- ## Method Details

  - ### setEntryoff

    public void setEntryoff(long entryoff)
    Sets the function's entry point via a relative offset value

    Called via deserialization for entryoff fieldmapping annotation

    Parameters:
      `entryoff` - relative offset to function

  - ### setEntry

    public void setEntry(long entry)
    Sets the absolute entry address.

    Called via deserialization for entry fieldmapping annotation

    Parameters:
      `entry` - absolute value.

  - ### getFuncAddress

    public Address getFuncAddress()
    Returns the address of this function.
    Returns:
      the address of this function

  - ### getBody

    public AddressRange getBody()
    Returns the address range of this function's body, recovered by examining addresses in the function's pc-to-filename translation table, or if not present, a single address range that contains the function's entry point.
    Returns:
      `AddressRange` representing the function's known footprint

  - ### getFunction

    public Function getFunction()
    Returns the Ghidra function that corresponds to this Go function.
    Returns:
      Ghidra `Function`, or null if there is no Ghidra function at the address

  - ### getDeferreturnAddress

    public Address getDeferreturnAddress()

  - ### getPcDataValue

    public int getPcDataValue(GoPcDataTable tableIndex, long targetPC) throws IOException
    Returns a value from the specified pc->value lookup table, for a specific address (that should be within the function's footprint).
    Parameters:
      `tableIndex` - `GoPcDataTable` enum
      `targetPC` - address (inside the function) to determine the value of
    Returns:
      int value, will be specific to the `table` it comes from, or -1 if the requested table index is not present for this function
    Throws:
      `IOException` - if error reading lookup data

  - ### getPcDataValues

    public List<Integer> getPcDataValues(GoPcDataTable tableIndex) throws IOException
    Returns all values for the specified pc->value lookup table for the entire range of the function's footprint.
    Parameters:
      `tableIndex` - `GoPcDataTable` enum
    Returns:
      list of int values, will be specific to the `table` it comes from, or an empty list if the requested table index is not present for this function
    Throws:
      `IOException` - if error reading lookup data

  - ### getFuncDataValue

    public long getFuncDataValue(GoFuncDataTable tableIndex) throws IOException
    Returns a value associated with this function.
    Parameters:
      `tableIndex` - `GoFuncDataTable` enum
    Returns:
      requested value, or -1 if the requested table index is not present for this function
    Throws:
      `IOException` - if error reading lookup data

  - ### recoverFunctionSignature

    public String recoverFunctionSignature() throws IOException
    Attempts to build a 'function signature' string representing the known information about this function's arguments, using go's built-in stack trace metadata.

    The information that can be recovered about arguments is limited to:

    - the size of the argument
    - general grouping (eg. grouping of arg values as a structure or array)
    Return value information is unknown and always represented as an "undefined" data type.
    Returns:
      pseudo-function signature string, such as "undefined foo( 8, 8 )" which would indicate the function had 2 8-byte arguments
    Throws:
      `IOException` - if error reading lookup data

  - ### getNameAddress

    public Address getNameAddress()
    Returns the address of this function's name string.

    Referenced from nameoff's markup annotation

    Returns:
      `Address`

  - ### getName

    public String getName()
    Returns the name of this function.
    Returns:
      the name of this function

  - ### getSymbolName

    public GoSymbolName getSymbolName()
    Returns the name of this function, as a parsed `GoSymbolName` symbol object.
    Returns:
      the name of this function, as a parsed `GoSymbolName` symbol object

  - ### getDescription

    public String getDescription()
    Returns a descriptive string.

    Referenced from the entry, entryoff field's markup annotation

    Returns:
      String description

  - ### isInline

    public boolean isInline()
    Returns true if this function is inline.
    Returns:
      true if this function is inline

  - ### getFlags

    public Set<GoFuncFlag> getFlags()
    Returns the `GoFuncFlag` func flags for this function.
    Returns:
      the `GoFuncFlag` func flags for this function

  - ### isAsmFunction

    public boolean isAsmFunction()
    Returns true if this function is an ASM function.
    Returns:
      true if this function is an ASM function

  - ### getSourceFileInfo

    public GoSourceFileInfo getSourceFileInfo() throws IOException
    Returns information about the source file that this function was defined in.
    Returns:
      `GoSourceFileInfo`, or null if no source file info present
    Throws:
      `IOException` - if error reading lookup data

  - ### markupSourceFileInfo

    public void markupSourceFileInfo()

  - ### getModuledata

    public GoModuledata getModuledata()
    Returns a reference to the `GoModuledata` that contains this function.
    Returns:
      a reference to the `GoModuledata` that contains this function

  - ### getStructureContext

    public StructureContext<GoFuncData> getStructureContext()
    Specified by:
      `getStructureContext` in interface `StructureMarkup<GoFuncData>`

  - ### 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<GoFuncData>`
    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<GoFuncData>`
    Returns:
      name of namespace to place the label for this structure mapped type, or null
    Throws:
      `IOException` - if error generating namespace name

  - ### 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<GoFuncData>`
    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

  - ### 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<GoFuncData>`
    Parameters:
      `session` - state and methods to assist marking up the program
    Throws:
      `IOException` - if error during markup
      `CancelledException` - if cancelled

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`