Class DBTraceGuestPlatform

All Implemented Interfaces:
ProgramArchitecture, InternalTracePlatform, TraceGuestPlatform, TracePlatform

public class DBTraceGuestPlatform extends DBAnnotatedObject implements TraceGuestPlatform, InternalTracePlatform
  • Field Details

  • Constructor Details

  • Method Details

    • fresh

      protected void fresh(boolean created) throws IOException
      Description copied from class: DBAnnotatedObject
      Extension point: Called when the object's fields are populated.

      This provides an opportunity for the object to initialize any non-database-backed fields that depend on the database-backed fields. Note that its use may indicate a situation better solved by a custom DBCachedObjectStoreFactory.DBFieldCodec. If both the database-backed and non-database-backed fields are used frequently, then a codec may not be indicated. If the database-backed fields are only used in this method or to encode another frequently-used field, then a codec is likely better.

      For a new object, the database-backed fields remain at their initial values. They will be saved after this method returns, so they may be further initialized with custom logic.

      For an object loaded from the database, the database-backed fields are already populated from the record when this method is called. They are not automatically saved after this method returns. This method should not further initialize database-backed fields in this case.

      Overrides:
      fresh in class DBAnnotatedObject
      Parameters:
      created - true when object is being created, or false when it is being loaded.
      Throws:
      IOException - if further initialization fails.
    • loadDataTypeManager

      protected void loadDataTypeManager(OpenMode openMode, TaskMonitor monitor) throws CancelledException, VersionException, IOException
      Throws:
      CancelledException
      VersionException
      IOException
    • getTrace

      public Trace getTrace()
      Description copied from interface: TracePlatform
      Get the trace
      Specified by:
      getTrace in interface TracePlatform
      Returns:
      the trace
    • getIntKey

      public int getIntKey()
      Description copied from interface: InternalTracePlatform
      Get the entry's key in the table as an integer
      Specified by:
      getIntKey in interface InternalTracePlatform
      Returns:
      the key
    • isGuest

      public boolean isGuest()
      Description copied from interface: TracePlatform
      Check if this is a guest platform
      Specified by:
      isGuest in interface TracePlatform
      Returns:
      true for guest, false for host
    • deleteMappedRange

      protected void deleteMappedRange(DBTraceGuestPlatformMappedRange range, TaskMonitor monitor) throws CancelledException
      Throws:
      CancelledException
    • getLanguageEntry

      public DBTraceGuestPlatform.DBTraceGuestLanguage getLanguageEntry()
      Specified by:
      getLanguageEntry in interface InternalTracePlatform
    • getLanguage

      public Language getLanguage()
      Description copied from interface: TracePlatform
      Get the language of the guest platform
      Specified by:
      getLanguage in interface ProgramArchitecture
      Specified by:
      getLanguage in interface TracePlatform
      Returns:
      the language
    • getCompilerSpec

      public CompilerSpec getCompilerSpec()
      Description copied from interface: TracePlatform
      Get the compiler of the guest platform
      Specified by:
      getCompilerSpec in interface ProgramArchitecture
      Specified by:
      getCompilerSpec in interface TracePlatform
      Returns:
      the compiler specification
    • getDataTypeManager

      public TraceBasedDataTypeManager getDataTypeManager()
      Description copied from interface: TracePlatform
      Get the data type manager for this platform.
      Specified by:
      getDataTypeManager in interface TracePlatform
      Returns:
      the data type manager
    • delete

      public void delete(TaskMonitor monitor) throws CancelledException
      Description copied from interface: TraceGuestPlatform
      Remove the mapped language, including all code units of the language
      Specified by:
      delete in interface TraceGuestPlatform
      Parameters:
      monitor - to monitor task progress
      Throws:
      CancelledException - if the task is cancelled by the monitor
    • addMappedRange

      public DBTraceGuestPlatformMappedRange addMappedRange(Address hostStart, Address guestStart, long length) throws AddressOverflowException
      Description copied from interface: TraceGuestPlatform
      Add an address mapping from host to guest
      Specified by:
      addMappedRange in interface TraceGuestPlatform
      Parameters:
      hostStart - the starting host address (mapped to guestStart)
      guestStart - the starting guest address (mapped to hostStart)
      length - the length of the range to map
      Returns:
      the mapped range
      Throws:
      AddressOverflowException - if length is too long for either start
    • computeNextRegisterMin

      protected Address computeNextRegisterMin()
    • addMappedRegisterRange

      public TraceGuestPlatformMappedRange addMappedRegisterRange() throws AddressOverflowException
      Description copied from interface: TraceGuestPlatform
      Add an address mapping from host register space to guest register space

      In guest space, the mapping is placed at 0 and has length large enough to accommodate all registers in the guest language. In host space, the mapping is placed after every other register mapping for every platform.

      Specified by:
      addMappedRegisterRange in interface TraceGuestPlatform
      Returns:
      the mapped range
      Throws:
      AddressOverflowException - if host register space was exhausted
    • getHostAddressSet

      public AddressSetView getHostAddressSet()
      Description copied from interface: TracePlatform
      Get the addresses in the host which are mapped to somewhere in the guest
      Specified by:
      getHostAddressSet in interface TracePlatform
      Returns:
      the address set
    • getGuestAddressSet

      public AddressSetView getGuestAddressSet()
      Description copied from interface: TracePlatform
      Get the addresses in the guest which are mapped to somehere in the host
      Specified by:
      getGuestAddressSet in interface TracePlatform
      Returns:
      the address set
    • mapHostToGuest

      public Address mapHostToGuest(Address hostAddress)
      Description copied from interface: TracePlatform
      Translate an address from host to guest
      Specified by:
      mapHostToGuest in interface TracePlatform
      Parameters:
      hostAddress - the host address
      Returns:
      the guest address
    • mapHostToGuest

      public AddressRange mapHostToGuest(AddressRange hostRange)
      Description copied from interface: TracePlatform
      Translate a range from host to guest

      The entire range must be mapped to a single range.

      Specified by:
      mapHostToGuest in interface TracePlatform
      Parameters:
      hostRange - the host range
      Returns:
      the guest range
    • mapHostToGuest

      public AddressSetView mapHostToGuest(AddressSetView hostSet)
      Description copied from interface: TracePlatform
      Translate a set from host to guest

      Only those ranges (or parts of ranges) that mapped are included.

      Specified by:
      mapHostToGuest in interface TracePlatform
      Parameters:
      hostSet - the host set
      Returns:
      the guest set
    • mapGuestToHost

      public Address mapGuestToHost(Address guestAddress)
      Description copied from interface: TracePlatform
      Translate an address from guest to host
      Specified by:
      mapGuestToHost in interface TracePlatform
      Parameters:
      guestAddress - the guest address
      Returns:
      the host address
    • mapGuestToHost

      public AddressRange mapGuestToHost(AddressRange guestRange)
      Description copied from interface: TracePlatform
      Translate a range from guest to host

      The entire range must be mapped to a single range.

      Specified by:
      mapGuestToHost in interface TracePlatform
      Parameters:
      guestRange - the guest range
      Returns:
      the host range
    • mapGuestToHost

      public AddressSetView mapGuestToHost(AddressSetView guestSet)
      Description copied from interface: TracePlatform
      Translate a set from guest to host

      Only those ranges (or parts of ranges) that mapped are included.

      Specified by:
      mapGuestToHost in interface TracePlatform
      Parameters:
      guestSet - the guest set
      Returns:
      the host set
    • mapGuestToHost

      public Address mapGuestToHost(Address guestMin, Address guestMax)
      Map an address only if the entire range is contained in a single mapped range
      Parameters:
      guestMin - the min address of the range to map
      guestMax - the max address of the range to check
      Returns:
      the mapped min address
    • getMappedMemBuffer

      public MemBuffer getMappedMemBuffer(long snap, Address guestAddress)
      Description copied from interface: TracePlatform
      Get a memory buffer, which presents the host bytes in the guest address space

      This, with pseudo-disassembly, is the primary mechanism for adding instructions in the guest language.

      Specified by:
      getMappedMemBuffer in interface TracePlatform
      Parameters:
      snap - the snap, up to which the most recent memory changes are presented
      guestAddress - the starting address in the guest space
      Returns:
      the mapped memory buffer
    • mapGuestInstructionAddressesToHost

      public InstructionSet mapGuestInstructionAddressesToHost(InstructionSet instructionSet)
      Description copied from interface: TracePlatform
      Copy the given instruction set, but with addresses mapped from the guest space to the host space

      Instructions which do not map are silently ignored. If concerned, the caller ought to examine the resulting instruction set and/or the resulting address set after it is added to the trace. A single instruction cannot span two mapped ranges, even if the comprised bytes are consecutive in the guest space. Mapping such an instruction back into the host space would cause the instruction to be split in the middle, which is not possible. Thus, such instructions are silently ignored.

      Specified by:
      mapGuestInstructionAddressesToHost in interface TracePlatform
      Parameters:
      instructionSet - the instruction set in the guest space
      Returns:
      the instruction set in the host space