Package ghidra.app.util.bin.format.dwarf

# Class StringTable

java.lang.Object
ghidra.app.util.bin.format.dwarf.StringTable

public class StringTable extends Object
Represents a DWARF string table, backed by a memory section like .debug_str.

Strings are read from the section the first time requested, and then cached in a weak lookup table.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected WeakValueHashMap<Long,String>`
  `cache`
  `protected BinaryReader`
  `reader`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StringTable(BinaryReader reader, Charset charset)`
  Creates a StringTable

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clear()`
  `String`
  `getStringAtOffset(long offset)`
  Returns the string found at `offset`, or throws an `IOException` if the offset is out of bounds.
  `boolean`
  `isValid(long offset)`
  Returns true if the specified offset is a valid offset for this string table.
  `static StringTable`
  `of(BinaryReader reader, Charset charset)`
  Creates a StringTable instance, if the supplied BinaryReader is non-null.

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

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

- ## Field Details

  - ### reader

    protected BinaryReader reader

  - ### cache

    protected WeakValueHashMap<Long,String> cache

- ## Constructor Details

  - ### StringTable

    public StringTable(BinaryReader reader, Charset charset)
    Creates a StringTable
    Parameters:
      `reader` - `BinaryReader` .debug_str or .debug_line_str
      `charset` - `Charset` of strings in table

- ## Method Details

  - ### of

    public static StringTable of(BinaryReader reader, Charset charset)
    Creates a StringTable instance, if the supplied BinaryReader is non-null.
    Parameters:
      `reader` - BinaryReader
      `charset` - `Charset` of strings in table
    Returns:
      new instance, or null if reader is null

  - ### isValid

    public boolean isValid(long offset)
    Returns true if the specified offset is a valid offset for this string table.
    Parameters:
      `offset` - location of possible string
    Returns:
      boolean true if location is valid

  - ### clear

    public void clear()

  - ### getStringAtOffset

    public String getStringAtOffset(long offset) throws IOException
    Returns the string found at `offset`, or throws an `IOException` if the offset is out of bounds.
    Parameters:
      `offset` - location of string
    Returns:
      a string, never null
    Throws:
      `IOException` - if not valid location