Class DescriptionTable

java.lang.Object
ghidra.features.bsim.query.client.tables.SQLComplexTable
ghidra.features.bsim.query.client.tables.DescriptionTable

public class DescriptionTable extends SQLComplexTable
This is the SQL table "desctable", which holds one row for each function ingested into the database. A row (DescriptionRow) consists of basic meta-data about the function: name, address, executable
  • Constructor Details

    • DescriptionTable

      public DescriptionTable(ExeTable exeTable)
  • Method Details

    • close

      public void close()
      Overrides:
      close in class SQLComplexTable
    • create

      public void create(Statement st) throws SQLException
      Description copied from class: SQLComplexTable
      Creates the db table.
      Specified by:
      create in class SQLComplexTable
      Parameters:
      st - the query statement
      Throws:
      SQLException - if there is a problem
    • drop

      public void drop(Statement st) throws SQLException
      Description copied from class: SQLComplexTable
      Drops the current table. NOTE: If explicitly created index tables exist they should be removed first or this method override.
      Overrides:
      drop in class SQLComplexTable
      Parameters:
      st - the query statement
      Throws:
      SQLException - if there is a problem with the execute update command
    • querySingleDescriptionId

      public FunctionDescription querySingleDescriptionId(DescriptionManager descManager, long rowId) throws SQLException, LSHException
      Given the row id of the function within desctable, extract the FunctionDescription object
      Parameters:
      descManager - is the container which will hold the object
      rowId - is the row id of the function within desctable
      Returns:
      the FunctionDescription
      Throws:
      SQLException - if there is a problem creating or executing the query
      LSHException - if there is a problem parsing the result set
    • convertDescriptionRows

      public void convertDescriptionRows(List<FunctionDescription> descList, List<DescriptionTable.DescriptionRow> rowList, ExecutableRecord executable, DescriptionManager descManager, SignatureRecord sigRecord)
      Given rows from desctable describing functions of a single executable, build the list of corresponding FunctionDescription objects
      Parameters:
      descList - is resulting list of FunctionDescriptions
      rowList - is the list of DescriptionRows
      executable - is the ExecutableRecord of the single executable
      descManager - is the container to hold the new FunctionDescriptions
      sigRecord - is a single SignatureRecord to associate with any new FunctionDescription (can be null)
    • convertDescriptionRow

      public static FunctionDescription convertDescriptionRow(DescriptionTable.DescriptionRow descRow, ExecutableRecord exeRecord, DescriptionManager descManager, SignatureRecord sigRecord)
      Given a function's raw meta-data from a desctable row (DescriptionRow), build the corresponding high-level FunctionDescription
      Parameters:
      descRow - is the function's row meta-data
      exeRecord - is the ExecutableRecord for executable containing the function
      descManager - is the container that will hold the new FunctionDescription
      sigRecord - is SignatureRecord associated with the function (may be null)
      Returns:
      the new FunctionDescription
    • extractDescriptionRow

      public static void extractDescriptionRow(ResultSet resultSet, DescriptionTable.DescriptionRow descRow) throws SQLException
      Extract column meta-data of a desctable row from the SQL result set
      Parameters:
      resultSet - is the low-level result set (returned by an SQL query)
      descRow - is the DescriptionRow
      Throws:
      SQLException - if there is a problem parsing the result set
    • extractDescriptionRows

      public List<DescriptionTable.DescriptionRow> extractDescriptionRows(ResultSet resultSet, int maxRows) throws SQLException
      Extract a list of desctable rows from the SQL result set Only build up to -max- DescriptionRow objects, but still run through all rows in the set.
      Parameters:
      resultSet - is the ResultSet to run through
      maxRows - is the maximum number of DescriptionRows to build
      Returns:
      a list of the new DescriptionRows
      Throws:
      SQLException - if there is a problem parsing the result set
    • insert

      public long insert(Object... arguments) throws SQLException
      Assuming all the necessary ids have been filled in, store the function as a row in desctable
      Specified by:
      insert in class SQLComplexTable
      Parameters:
      arguments - must be a single FunctionDescription
      Returns:
      to be defined by the implementor
      Throws:
      SQLException - if there is a problem creating or executing the query
    • queryVectorIdMatch

      public List<DescriptionTable.DescriptionRow> queryVectorIdMatch(long vectorId, int maxRows) throws SQLException
      Return function DescriptionRow objects that have a matching vector id
      Parameters:
      vectorId - is the row id of the feature vector we want to match
      maxRows - is the maximum number of function rows to return
      Returns:
      list of resulting DescriptionRows
      Throws:
      SQLException - if there is a problem creating or executing the query
    • queryVectorIdMatchFilter

      public List<DescriptionTable.DescriptionRow> queryVectorIdMatchFilter(long vectorId, String tableClause, String whereClause, int maxRows) throws SQLException
      Return function DescriptionRow objects that have a matching vector id and that also pass additional filters. The filters must be encoded as a "WHERE" clause of an SQL "SELECT" statement on desctable. Additional tables joined to desctable to satisfy the filter must be encoded as a "FROM" clause of the "SELECT".
      Parameters:
      vectorId - is the row id of the feature vector (vectortable) we want to match on
      tableClause - is the additional "FROM" clause needed for the filter
      whereClause - is the "WHERE" clause needed for the filter
      maxRows - is the maximum number of rows to return
      Returns:
      a list of resulting DescriptionRows
      Throws:
      SQLException - if there is an error creating or executing the query
    • queryFuncName

      public List<DescriptionTable.DescriptionRow> queryFuncName(long executableId, String functionName, int maxRows) throws SQLException
      Return DescriptionRow objects that match a given -functionName- and the row id within exetable of a specific executable
      Parameters:
      executableId - is the row id of the executable to match
      functionName - is the name of the function to match
      maxRows - is the maximum number of functions to return
      Returns:
      linked of DescriptionRow objects
      Throws:
      SQLException - if there is an error creating or executing the query
    • queryFuncNameAddr

      public DescriptionTable.DescriptionRow queryFuncNameAddr(long executableId, String functionName, long functionAddress) throws SQLException
      Query the description table for the row describing a single function. A function is uniquely identified by: its name, address, and the executable it is in
      Parameters:
      executableId - is the row id (of exetable) of the executable containing the function
      functionName - is the name of the function
      functionAddress - is the address of the function
      Returns:
      the corresponding row of the table, or null
      Throws:
      SQLException - if there is an error creating or executing the query