Package ghidra.test
Class ToyProgramBuilder
- java.lang.Object
-
- ghidra.program.database.ProgramBuilder
-
- ghidra.test.ToyProgramBuilder
-
public class ToyProgramBuilder extends ProgramBuilder
-
-
Field Summary
-
Fields inherited from class ghidra.program.database.ProgramBuilder
_8051, _AARCH64, _ARM, _MIPS, _MIPS_6432, _PPC_32, _PPC_6432, _SPARC64, _TOY, _TOY_BE, _TOY_BE_POSITIVE, _TOY_LANGUAGE_PREFIX, _TOY_LE, _TOY_WORDSIZE2_BE, _TOY_WORDSIZE2_LE, _TOY64_BE, _TOY64_LE, _X64, _X86, _X86_16_REAL_MODE
-
-
Constructor Summary
Constructors Constructor Description ToyProgramBuilder(java.lang.String name, boolean bigEndian)Construct toy program builder using toy language "builder" variant.ToyProgramBuilder(java.lang.String name, boolean bigEndian, boolean wordAligned, java.lang.Object consumer)Construct toy program builder using toy language "builder" variant.ToyProgramBuilder(java.lang.String name, boolean bigEndian, java.lang.Object consumer)Construct toy program builder using toy language "builder" variant.ToyProgramBuilder(java.lang.String name, java.lang.String languageName, java.lang.Object consumer)Construct toy program builder using specified toy language
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBytesBadInstruction(long offset)Add BAD instruction (consumes 2-bytes).voidaddBytesBadInstruction(java.lang.String addr)Add BAD instruction (consumes 2-bytes).voidaddBytesBranch(long offset, long dest)Add branch (consumes 2-bytes)voidaddBytesBranch(java.lang.String addr, java.lang.String destAddr)Add branch (consumes 2-bytes)voidaddBytesBranchConditional(long offset, long dest)Add branch (consumes 2-bytes)voidaddBytesBranchConditional(java.lang.String addr, java.lang.String destAddr)Add branch (consumes 2-bytes)voidaddBytesBranchWithDelaySlot(long offset, long dest)Add branch w/ delay slot (consumes 4-bytes)voidaddBytesBranchWithDelaySlot(java.lang.String addr, java.lang.String destAddr)Add branch w/ delay slot (consumes 4-bytes)voidaddBytesCall(long offset, long dest)Add call (consumes 2-bytes)voidaddBytesCall(java.lang.String addr, java.lang.String destAddr)Add call (consumes 2-bytes)voidaddBytesCallWithDelaySlot(long offset, long dest)Add call w/ delayslot (consumes 4-bytes)voidaddBytesCallWithDelaySlot(java.lang.String addr, java.lang.String destAddr)Add call w/ delayslot (consumes 4-bytes)voidaddBytesCopInstruction(long offset)Add COP instruction for exercising nfctx context (consumes 2-bytes).voidaddBytesCopInstruction(java.lang.String addr)Add COP instruction for exercising nfctx context (consumes 2-bytes).voidaddBytesFallthrough(long offset)Add simple fall-through (consumes 2-bytes)voidaddBytesFallthrough(java.lang.String addr)Add simple fall-through (consumes 2-bytes)voidaddBytesFallthroughSetFlowContext(long offset, int ctxVal)Add simple fall-through which sets flowing context value on next instruction (consumes 2-bytes)voidaddBytesFallthroughSetFlowContext(java.lang.String addr, int ctxVal)Add simple fall-through which sets flowing context value on next instruction (consumes 2-bytes)voidaddBytesFallthroughSetNoFlowContext(long offset, int ctxVal)Add simple fall-through which sets noflow context value on next instruction (consumes 2-bytes)voidaddBytesFallthroughSetNoFlowContext(long offset, int ctxVal, long target)Add simple fall-through which sets noflow context value on target address (consumes 2-bytes)voidaddBytesFallthroughSetNoFlowContext(java.lang.String addr, int ctxVal)Add simple fall-through which sets noflow context value on next instruction (consumes 2-bytes)voidaddBytesFallthroughSetNoFlowContext(java.lang.String addr, int ctxVal, java.lang.String targetAddr)Add simple fall-through which sets noflow context value on target address (consumes 2-bytes)voidaddBytesLoad(long offset, int srcRegIndex, int destRegIndex)Add load indirect (consumes 2-bytes)voidaddBytesLoad(java.lang.String addr, int srcRegIndex, int destRegIndex)Add load indirect (consumes 2-bytes)voidaddBytesMoveImmediate(long offset, short imm)Add move immediate instruction (consumes 2-bytes)voidaddBytesMoveImmediate(java.lang.String addr, short imm)Add move immediate instruction (consumes 2-bytes)voidaddBytesNOP(long offset, int length)Add NOP instruction bytes of specified byte lengthvoidaddBytesNOP(java.lang.String addr, int length)Add NOP instruction bytes of specified byte lengthvoidaddBytesReturn(long offset)Add terminal/return (consumes 2-bytes)voidaddBytesReturn(java.lang.String addr)Add terminal/return (consumes 2-bytes)voidaddBytesStore(long offset, int srcRegIndex, int destRegIndex)Add store indirect (consumes 2-bytes)voidaddBytesStore(java.lang.String addr, int srcRegIndex, int destRegIndex)Add store indirect (consumes 2-bytes)voidcreateCallInstruction(java.lang.String address, java.lang.String callAddress)voidcreateConditionalJmpInstruction(java.lang.String address, java.lang.String destAddress)voidcreateJmpInstruction(java.lang.String address, java.lang.String destAddress)voidcreateJmpWithDelaySlot(java.lang.String address, java.lang.String destAddress)voidcreateNOPInstruction(java.lang.String address, int size)voidcreateReturnInstruction(java.lang.String address)AddressgetAddress(long offset)Get address in default ram spacejava.util.List<Address>getDefinedInstructionAddress()Get locations where instruction bytes have been addedvoidresetDefinedInstructionAddresses()Reset/clear the list of defined instruction addresses-
Methods inherited from class ghidra.program.database.ProgramBuilder
addCategory, addDataType, addFunctionVariable, addr, addr, analyze, applyDataType, applyDataType, applyStringDataType, bindExternalLibrary, clearCodeUnits, createBookmark, createClassNamespace, createComment, createEmptyFunction, createEmptyFunction, createEmptyFunction, createEmptyFunction, createEmptyFunction, createEncodedString, createEntryPoint, createEquate, createExternalFunction, createExternalFunction, createExternalLibraries, createExternalReference, createExternalReference, createExternalReference, createFragment, createFunction, createFunctionComment, createLabel, createLabel, createLibrary, createLibrary, createLocalVariable, createMemory, createMemory, createMemory, createMemoryCallReference, createMemoryJumpReference, createMemoryReadReference, createMemoryReference, createMemoryReference, createNamespace, createNamespace, createNamespace, createOffsetMemReference, createOverlayMemory, createProgramTree, createRegisterReference, createRegisterReference, createStackReference, createString, createString, createUninitializedMemory, deleteReference, disassemble, disassemble, disassemble, disassemble, disassembleArm, dispose, endTransaction, getCompilerSpec, getLanguage, getNamespace, getNamespace, getOrCreateModule, getProgram, getRegister, setAnalysisEnabled, setAnalyzed, setBytes, setBytes, setBytes, setBytes, setChanged, setExecute, setFallthrough, setIntProperty, setName, setObjectProperty, setProperty, setRead, setRecordChanges, setRegisterValue, setStringProperty, setWrite, startTransaction, withTransaction
-
-
-
-
Constructor Detail
-
ToyProgramBuilder
public ToyProgramBuilder(java.lang.String name, java.lang.String languageName, java.lang.Object consumer) throws java.lang.ExceptionConstruct toy program builder using specified toy language- Parameters:
name- program namelanguageName- toy language ID (note: only builder variant supports all instructions)consumer- program consumer (if null this builder will be used as consumer and must be disposed to release program)- Throws:
java.lang.Exception
-
ToyProgramBuilder
public ToyProgramBuilder(java.lang.String name, boolean bigEndian) throws java.lang.ExceptionConstruct toy program builder using toy language "builder" variant. This builder will be the program consumer and must be disposed- Parameters:
name- program namebigEndian- language endianess- Throws:
java.lang.Exception
-
ToyProgramBuilder
public ToyProgramBuilder(java.lang.String name, boolean bigEndian, java.lang.Object consumer) throws java.lang.ExceptionConstruct toy program builder using toy language "builder" variant. This builder will be the program consumer and must be disposed- Parameters:
name- program namebigEndian- language endianessconsumer- program consumer (if null this builder will be used as consumer and must be disposed to release program)- Throws:
java.lang.Exception
-
ToyProgramBuilder
public ToyProgramBuilder(java.lang.String name, boolean bigEndian, boolean wordAligned, java.lang.Object consumer) throws java.lang.ExceptionConstruct toy program builder using toy language "builder" variant. This builder will be the program consumer and must be disposed- Parameters:
name- program namebigEndian- language endianessconsumer- program consumer (if null this builder will be used as consumer and must be disposed to release program)- Throws:
java.lang.Exception
-
-
Method Detail
-
getAddress
public Address getAddress(long offset)
Get address in default ram space- Parameters:
offset- address offset- Returns:
- address
-
getDefinedInstructionAddress
public java.util.List<Address> getDefinedInstructionAddress()
Get locations where instruction bytes have been added- Returns:
- instruction start locations
-
resetDefinedInstructionAddresses
public void resetDefinedInstructionAddresses()
Reset/clear the list of defined instruction addresses
-
addBytesNOP
public void addBytesNOP(long offset, int length) throws MemoryAccessExceptionAdd NOP instruction bytes of specified byte length- Parameters:
offset- instruction address offsetlength- length of NOP instruction in bytes- Throws:
MemoryAccessException
-
addBytesNOP
public void addBytesNOP(java.lang.String addr, int length) throws MemoryAccessExceptionAdd NOP instruction bytes of specified byte length- Parameters:
addr- instruction addresslength- length of NOP instruction in bytes- Throws:
MemoryAccessException
-
addBytesFallthrough
public void addBytesFallthrough(long offset) throws MemoryAccessExceptionAdd simple fall-through (consumes 2-bytes)- Parameters:
offset- instruction address offset- Throws:
MemoryAccessException
-
addBytesFallthrough
public void addBytesFallthrough(java.lang.String addr) throws MemoryAccessExceptionAdd simple fall-through (consumes 2-bytes)- Parameters:
addr- instruction address- Throws:
MemoryAccessException
-
addBytesStore
public void addBytesStore(long offset, int srcRegIndex, int destRegIndex) throws MemoryAccessExceptionAdd store indirect (consumes 2-bytes)- Parameters:
offset- instruction address offsetsrcRegIndex- source register index (0..15)destRegIndex- destination register index (contained indirect memory address) (0..15)- Throws:
MemoryAccessException
-
addBytesStore
public void addBytesStore(java.lang.String addr, int srcRegIndex, int destRegIndex) throws MemoryAccessExceptionAdd store indirect (consumes 2-bytes)- Parameters:
addr- instruction addresssrcRegIndex- source register index (0..15)destRegIndex- destination register index (contained indirect memory address) (0..15)- Throws:
MemoryAccessException
-
addBytesLoad
public void addBytesLoad(long offset, int srcRegIndex, int destRegIndex) throws MemoryAccessExceptionAdd load indirect (consumes 2-bytes)- Parameters:
offset- instruction address offsetsrcRegIndex- source register index (contained indirect memory address) (0..15)destRegIndex- destination register index (0..15)- Throws:
MemoryAccessException
-
addBytesLoad
public void addBytesLoad(java.lang.String addr, int srcRegIndex, int destRegIndex) throws MemoryAccessExceptionAdd load indirect (consumes 2-bytes)- Parameters:
addr- instruction addresssrcRegIndex- source register index (contained indirect memory address) (0..15)destRegIndex- destination register index (0..15)- Throws:
MemoryAccessException
-
addBytesMoveImmediate
public void addBytesMoveImmediate(long offset, short imm) throws MemoryAccessExceptionAdd move immediate instruction (consumes 2-bytes)- Parameters:
addr- instruction addressimm- immediate byte value- Throws:
MemoryAccessException
-
addBytesMoveImmediate
public void addBytesMoveImmediate(java.lang.String addr, short imm) throws MemoryAccessExceptionAdd move immediate instruction (consumes 2-bytes)- Parameters:
addr- instruction addressimm- immediate byte value- Throws:
MemoryAccessException
-
addBytesFallthroughSetNoFlowContext
public void addBytesFallthroughSetNoFlowContext(long offset, int ctxVal) throws MemoryAccessExceptionAdd simple fall-through which sets noflow context value on next instruction (consumes 2-bytes)- Parameters:
offset- instruction address offsetctxVal- context value (0-15)- Throws:
MemoryAccessException
-
addBytesFallthroughSetNoFlowContext
public void addBytesFallthroughSetNoFlowContext(java.lang.String addr, int ctxVal) throws MemoryAccessExceptionAdd simple fall-through which sets noflow context value on next instruction (consumes 2-bytes)- Parameters:
addr- instruction addressctxVal- context value (0-15)- Throws:
MemoryAccessException
-
addBytesFallthroughSetNoFlowContext
public void addBytesFallthroughSetNoFlowContext(long offset, int ctxVal, long target) throws MemoryAccessExceptionAdd simple fall-through which sets noflow context value on target address (consumes 2-bytes)- Parameters:
offset- instruction address offsetctxVal- context value (0-15)target- context target address offset- Throws:
MemoryAccessException
-
addBytesFallthroughSetNoFlowContext
public void addBytesFallthroughSetNoFlowContext(java.lang.String addr, int ctxVal, java.lang.String targetAddr) throws MemoryAccessExceptionAdd simple fall-through which sets noflow context value on target address (consumes 2-bytes)- Parameters:
addr- instruction addressctxVal- context value (0-15)targetAddr- context target address- Throws:
MemoryAccessException
-
addBytesFallthroughSetFlowContext
public void addBytesFallthroughSetFlowContext(long offset, int ctxVal) throws MemoryAccessExceptionAdd simple fall-through which sets flowing context value on next instruction (consumes 2-bytes)- Parameters:
offset- instruction address offsetctxVal- context value (0-15)- Throws:
MemoryAccessException
-
addBytesFallthroughSetFlowContext
public void addBytesFallthroughSetFlowContext(java.lang.String addr, int ctxVal) throws MemoryAccessExceptionAdd simple fall-through which sets flowing context value on next instruction (consumes 2-bytes)- Parameters:
addr- instruction addressctxVal- context value (0-15)- Throws:
MemoryAccessException
-
addBytesCall
public void addBytesCall(long offset, long dest) throws MemoryAccessExceptionAdd call (consumes 2-bytes)- Parameters:
offset- instruction address offsetdest- call destination offset- Throws:
MemoryAccessException
-
addBytesCall
public void addBytesCall(java.lang.String addr, java.lang.String destAddr) throws MemoryAccessExceptionAdd call (consumes 2-bytes)- Parameters:
addr- instruction addressdest- call destination address- Throws:
MemoryAccessException
-
addBytesCallWithDelaySlot
public void addBytesCallWithDelaySlot(long offset, long dest) throws MemoryAccessExceptionAdd call w/ delayslot (consumes 4-bytes)- Parameters:
offset- instruction address offsetdest- call destination offset- Throws:
MemoryAccessException
-
addBytesCallWithDelaySlot
public void addBytesCallWithDelaySlot(java.lang.String addr, java.lang.String destAddr) throws MemoryAccessExceptionAdd call w/ delayslot (consumes 4-bytes)- Parameters:
addr- instruction addressdest- call destination address- Throws:
MemoryAccessException
-
addBytesReturn
public void addBytesReturn(long offset) throws MemoryAccessExceptionAdd terminal/return (consumes 2-bytes)- Parameters:
offset- instruction address offset- Throws:
MemoryAccessException
-
addBytesReturn
public void addBytesReturn(java.lang.String addr) throws MemoryAccessExceptionAdd terminal/return (consumes 2-bytes)- Parameters:
addr- instruction address- Throws:
MemoryAccessException
-
addBytesBranch
public void addBytesBranch(long offset, long dest) throws MemoryAccessExceptionAdd branch (consumes 2-bytes)- Parameters:
offset- address offsetdest- call destination offset- Throws:
MemoryAccessException
-
addBytesBranch
public void addBytesBranch(java.lang.String addr, java.lang.String destAddr) throws MemoryAccessExceptionAdd branch (consumes 2-bytes)- Parameters:
addr- instruction address offsetdestAddr- call destination address- Throws:
MemoryAccessException
-
addBytesBranchConditional
public void addBytesBranchConditional(long offset, long dest) throws MemoryAccessExceptionAdd branch (consumes 2-bytes)- Parameters:
offset- instruction address offsetdest- call destination offset- Throws:
MemoryAccessException
-
addBytesBranchConditional
public void addBytesBranchConditional(java.lang.String addr, java.lang.String destAddr) throws MemoryAccessExceptionAdd branch (consumes 2-bytes)- Parameters:
addr- instruction addressdestAddr- call destination address- Throws:
MemoryAccessException
-
addBytesBranchWithDelaySlot
public void addBytesBranchWithDelaySlot(long offset, long dest) throws MemoryAccessExceptionAdd branch w/ delay slot (consumes 4-bytes)- Parameters:
offset- instruction address offsetdest- call destination offset- Throws:
MemoryAccessException
-
addBytesBranchWithDelaySlot
public void addBytesBranchWithDelaySlot(java.lang.String addr, java.lang.String destAddr) throws MemoryAccessExceptionAdd branch w/ delay slot (consumes 4-bytes)- Parameters:
addr- instruction addressdestAddr- call destination address- Throws:
MemoryAccessException
-
addBytesCopInstruction
public void addBytesCopInstruction(long offset) throws MemoryAccessExceptionAdd COP instruction for exercising nfctx context (consumes 2-bytes). Location will not be added to defined instruction address list.- Parameters:
offset- instruction address offset- Throws:
MemoryAccessException
-
addBytesCopInstruction
public void addBytesCopInstruction(java.lang.String addr) throws MemoryAccessExceptionAdd COP instruction for exercising nfctx context (consumes 2-bytes). Location will not be added to defined instruction address list.- Parameters:
addr- instruction address- Throws:
MemoryAccessException
-
addBytesBadInstruction
public void addBytesBadInstruction(long offset) throws MemoryAccessExceptionAdd BAD instruction (consumes 2-bytes). Location will not be added to defined instruction address list.- Parameters:
offset- bad instruction address offset- Throws:
MemoryAccessException
-
addBytesBadInstruction
public void addBytesBadInstruction(java.lang.String addr) throws MemoryAccessExceptionAdd BAD instruction (consumes 2-bytes). Location will not be added to defined instruction address list.- Parameters:
addr- bad instruction address- Throws:
MemoryAccessException
-
createNOPInstruction
public void createNOPInstruction(java.lang.String address, int size) throws java.lang.Exception- Throws:
java.lang.Exception
-
createCallInstruction
public void createCallInstruction(java.lang.String address, java.lang.String callAddress) throws java.lang.Exception- Throws:
java.lang.Exception
-
createReturnInstruction
public void createReturnInstruction(java.lang.String address) throws java.lang.Exception- Throws:
java.lang.Exception
-
createJmpInstruction
public void createJmpInstruction(java.lang.String address, java.lang.String destAddress) throws java.lang.Exception- Throws:
java.lang.Exception
-
createConditionalJmpInstruction
public void createConditionalJmpInstruction(java.lang.String address, java.lang.String destAddress) throws java.lang.Exception- Throws:
java.lang.Exception
-
createJmpWithDelaySlot
public void createJmpWithDelaySlot(java.lang.String address, java.lang.String destAddress) throws java.lang.Exception- Throws:
java.lang.Exception
-
-