Class DBTraceInstructionsView

All Implemented Interfaces:
InternalBaseCodeUnitsView<TraceInstruction>, InternalTraceBaseDefinedUnitsView<TraceInstruction>, TraceBaseCodeUnitsView<TraceInstruction>, TraceBaseDefinedUnitsView<TraceInstruction>, TraceInstructionsView

  • Constructor Details

    • DBTraceInstructionsView

      public DBTraceInstructionsView(DBTraceCodeSpace space)
      Construct the view
      Parameters:
      space - the space, bound to an address space
  • Method Details

    • replaceIfNotNull

      protected static <T> T replaceIfNotNull(T cur, T rep)
    • doSetContext

      protected void doSetContext(TraceAddressSnapRange tasr, Language language, ProcessorContextView context)
      Set the context over the given box

      If the given context matches the language's default at the mininum address of the box, the context is cleared.

      Parameters:
      tasr - the box
      language - the language for the instruction
      context - the desired context
    • doCreate

      protected DBTraceInstruction doCreate(Lifespan lifespan, Address address, InternalTracePlatform platform, InstructionPrototype prototype, ProcessorContextView context, int length) throws CodeUnitInsertionException, AddressOverflowException
      Create an instruction
      Parameters:
      lifespan - the lifespan of the instruction
      address - the minimum address of the instruction
      platform - the platform (language, compiler) for the instruction
      prototype - the instruction's prototype
      context - the initial context for parsing the instruction
      length - instruction byte-length (must be in the range 0..prototype.getLength()). If smaller than the prototype length it must have a value no greater than 7, otherwise an error will be thrown. A value of 0 or greater-than-or-equal the prototype length will be ignored and not impose and override length. The length value must be a multiple of the instruction alignment .
      Returns:
      the newly created instruction.
      Throws:
      CodeUnitInsertionException - thrown if the new Instruction would overlap and existing CodeUnit or the specified length is unsupported.
      IllegalArgumentException - if a negative length is specified.
      AddressOverflowException - if the instruction would fall off the address space
    • create

      public DBTraceInstruction create(Lifespan lifespan, Address address, TracePlatform platform, InstructionPrototype prototype, ProcessorContextView context, int forcedLengthOverride) throws CodeUnitInsertionException
      Description copied from interface: TraceInstructionsView
      Create an instruction
      Specified by:
      create in interface TraceInstructionsView
      Parameters:
      lifespan - the lifespan for the instruction unit
      address - the starting address of the instruction
      platform - the platform
      prototype - the instruction prototype
      context - the input disassembly context for the instruction
      forcedLengthOverride - reduced instruction byte-length (1..7) or 0 to use default length
      Returns:
      the new instruction
      Throws:
      CodeUnitInsertionException - if the instruction cannot be created
    • startCheckingBlock

      protected OverlappingObjectIterator<Instruction,CodeUnit> startCheckingBlock(long startSnap, InstructionBlock block)
      Prepare to check a block for conflicts
      Parameters:
      startSnap - the minimum snap for each instruction
      block - the block of instructions
      Returns:
      an iterator for overlapping object pairs
    • startAddingBlock

      protected DBTraceInstructionsView.InstructionBlockAdder startAddingBlock(Lifespan lifespan, Set<Address> skipDelaySlots, InternalTracePlatform platform, InstructionBlock block, boolean overwrite)
      Start adding the given block to the database

      If this returns non-null, it should be immediately followed by DBTraceInstructionsView.InstructionBlockAdder.doAddInstructions().

      Parameters:
      lifespan - the lifespan of each instruction
      skipDelaySlots - the addresses of delay-slotted instructions to skip
      platform - the instructions' platform (language, compiler)
      block - the block of instructions to add
      overwrite - true to overwrite existing defined units
      Returns:
      the adder, or null
    • isKnown

      protected boolean isKnown(DBTraceMemorySpace ms, long snap, CodeUnit cu)
    • checkInstructionSet

      protected void checkInstructionSet(long startSnap, InstructionSet instructionSet, Set<Address> skipDelaySlots)
      Checks the intended locations for conflicts with existing units.

      This also clears locations where delay slots will be replacing non-delay slots. skipDelaySlots will be populated with any existing delay slot locations which should not be overwritten

      Parameters:
      instructionSet - the instruction set to examine
      skipDelaySlots - an empty mutable set to be populated
    • addInstructionSet

      public AddressSetView addInstructionSet(Lifespan lifespan, TracePlatform platform, InstructionSet instructionSet, boolean overwrite)
      Description copied from interface: TraceInstructionsView
      Create several instructions

      NOTE: This does not throw CodeUnitInsertionException. Conflicts are instead recorded in the instructionSet.

      Specified by:
      addInstructionSet in interface TraceInstructionsView
      Parameters:
      lifespan - the lifespan for all instruction units
      platform - the optional guest platform, null for the host
      instructionSet - the set of instructions to add
      overwrite - true to replace conflicting instructions
      Returns:
      the (host) address set of instructions actually added