Package ghidra.test
Class ToyProgramBuilder
java.lang.Object
ghidra.program.database.ProgramBuilder
ghidra.test.ToyProgramBuilder
-
Nested Class Summary
Nested classes/interfaces inherited from class ghidra.program.database.ProgramBuilder
ProgramBuilder.ExceptionalSupplier<R,E extends Exception> -
Field Summary
Fields inherited from class ghidra.program.database.ProgramBuilder
_8051, _AARCH64, _ARM, _MIPS, _MIPS_6432, _PPC_32, _PPC_64, _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
ConstructorsConstructorDescriptionToyProgramBuilder(String name, boolean bigEndian) Construct toy program builder using toy language "builder" variant.ToyProgramBuilder(String name, boolean bigEndian, boolean wordAligned, Object consumer) Construct toy program builder using toy language "builder" variant.ToyProgramBuilder(String name, boolean bigEndian, Object consumer) Construct toy program builder using toy language "builder" variant.ToyProgramBuilder(String name, String languageName, Object consumer) Construct toy program builder using specified toy language -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBytesBadInstruction(long offset) Add BAD instruction (consumes 2-bytes).voidaddBytesBadInstruction(String addr) Add BAD instruction (consumes 2-bytes).voidaddBytesBranch(long offset, long dest) Add branch (consumes 2-bytes)voidaddBytesBranch(String addr, String destAddr) Add branch (consumes 2-bytes)voidaddBytesBranchConditional(long offset, long dest) Add branch (consumes 2-bytes)voidaddBytesBranchConditional(String addr, String destAddr) Add branch (consumes 2-bytes)voidaddBytesBranchWithDelaySlot(long offset, long dest) Add branch w/ delay slot (consumes 4-bytes)voidaddBytesBranchWithDelaySlot(String addr, String destAddr) Add branch w/ delay slot (consumes 4-bytes)voidaddBytesCall(long offset, long dest) Add call (consumes 2-bytes)voidaddBytesCall(String offset, long dest) Add call (consumes 2-bytes)voidaddBytesCall(String addr, String destAddr) Add call (consumes 2-bytes)voidaddBytesCallWithDelaySlot(long offset, long dest) Add call w/ delayslot (consumes 4-bytes)voidaddBytesCallWithDelaySlot(String addr, String destAddr) Add call w/ delayslot (consumes 4-bytes)voidaddBytesCopInstruction(long offset) Add COP instruction for exercising nfctx context (consumes 2-bytes).voidaddBytesCopInstruction(String addr) Add COP instruction for exercising nfctx context (consumes 2-bytes).voidaddBytesFallthrough(long offset) Add simple fall-through (consumes 2-bytes)voidaddBytesFallthrough(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(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(String addr, int ctxVal) Add simple fall-through which sets noflow context value on next instruction (consumes 2-bytes)voidaddBytesFallthroughSetNoFlowContext(String addr, int ctxVal, 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(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(String addr, short imm) Add move immediate instruction (consumes 2-bytes)voidaddBytesNOP(long offset, int length) Add NOP instruction bytes of specified byte lengthvoidaddBytesNOP(String addr, int length) Add NOP instruction bytes of specified byte lengthvoidaddBytesReturn(long offset) Add terminal/return (consumes 2-bytes)voidaddBytesReturn(String addr) Add terminal/return (consumes 2-bytes)voidaddBytesSkipConditional(long offset) Add conditional skip (consumes 2-bytes)voidAdd conditional skip (consumes 2-bytes)voidaddBytesStore(long offset, int srcRegIndex, int destRegIndex) Add store indirect (consumes 2-bytes)voidaddBytesStore(String addr, int srcRegIndex, int destRegIndex) Add store indirect (consumes 2-bytes)voidcreateCallInstruction(String address, String callAddress) voidcreateConditionalJmpInstruction(String address, String destAddress) voidcreateJmpInstruction(String address, String destAddress) voidcreateJmpWithDelaySlot(String address, String destAddress) voidcreateNOPInstruction(String address, int size) voidcreateReturnInstruction(String address) getAddress(long offset) Get address in default ram spaceGet locations where instruction bytes have been addedvoidReset/clear the list of defined instruction addressesMethods inherited from class ghidra.program.database.ProgramBuilder
addCategory, addDataType, addFunctionVariable, addr, addr, analyze, applyDataType, applyDataType, applyFixedLengthDataType, applyStringDataType, bindExternalLibrary, clearCodeUnits, createBookmark, createClassNamespace, createComment, createComment, createEmptyFunction, createEmptyFunction, createEmptyFunction, createEmptyFunction, createEmptyFunction, createEncodedString, createEntryPoint, createEquate, createExternalFunction, createExternalFunction, createExternalLibraries, createExternalReference, createExternalReference, createExternalReference, createFileBytes, createFragment, createFunction, createFunctionComment, createLabel, createLabel, createLibrary, createLibrary, createLocalVariable, createMemory, createMemory, createMemory, createMemory, createMemoryCallReference, createMemoryJumpReference, createMemoryReadReference, createMemoryReference, createMemoryReference, createNamespace, createNamespace, createNamespace, createOffsetMemReference, createOverlayMemory, createProgramTree, createRegisterReference, createRegisterReference, createStackReference, createString, createString, createUninitializedMemory, deleteFunction, deleteReference, disassemble, disassemble, disassemble, disassemble, disassembleArm, dispose, endTransaction, 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, tx, tx, withTransaction
-
Constructor Details
-
ToyProgramBuilder
Construct 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:
Exception
-
ToyProgramBuilder
Construct toy program builder using toy language "builder" variant. This builder will be the program consumer and must be disposed- Parameters:
name- program namebigEndian- language endianness- Throws:
Exception
-
ToyProgramBuilder
Construct toy program builder using toy language "builder" variant. This builder will be the program consumer and must be disposed- Parameters:
name- program namebigEndian- language endiannessconsumer- program consumer (if null this builder will be used as consumer and must be disposed to release program)- Throws:
Exception
-
ToyProgramBuilder
public ToyProgramBuilder(String name, boolean bigEndian, boolean wordAligned, Object consumer) throws Exception Construct toy program builder using toy language "builder" variant. This builder will be the program consumer and must be disposed- Parameters:
name- program namebigEndian- language endiannessconsumer- program consumer (if null this builder will be used as consumer and must be disposed to release program)- Throws:
Exception
-
-
Method Details
-
getAddress
Get address in default ram space- Parameters:
offset- address offset- Returns:
- the 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
Add NOP instruction bytes of specified byte length- Parameters:
offset- instruction address offsetlength- length of NOP instruction in bytes- Throws:
MemoryAccessException
-
addBytesNOP
Add NOP instruction bytes of specified byte length- Parameters:
addr- instruction addresslength- length of NOP instruction in bytes- Throws:
MemoryAccessException
-
addBytesFallthrough
Add simple fall-through (consumes 2-bytes)- Parameters:
offset- instruction address offset- Throws:
MemoryAccessException
-
addBytesFallthrough
Add simple fall-through (consumes 2-bytes)- Parameters:
addr- instruction address- Throws:
MemoryAccessException
-
addBytesStore
public void addBytesStore(long offset, int srcRegIndex, int destRegIndex) throws MemoryAccessException Add 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(String addr, int srcRegIndex, int destRegIndex) throws MemoryAccessException Add 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 MemoryAccessException Add 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(String addr, int srcRegIndex, int destRegIndex) throws MemoryAccessException Add 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
Add move immediate instruction (consumes 2-bytes)- Parameters:
offset- instruction offsetimm- immediate byte value- Throws:
MemoryAccessException
-
addBytesMoveImmediate
Add move immediate instruction (consumes 2-bytes)- Parameters:
addr- instruction addressimm- immediate byte value- Throws:
MemoryAccessException
-
addBytesFallthroughSetNoFlowContext
public void addBytesFallthroughSetNoFlowContext(long offset, int ctxVal) throws MemoryAccessException Add 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(String addr, int ctxVal) throws MemoryAccessException Add 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 MemoryAccessException Add 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(String addr, int ctxVal, String targetAddr) throws MemoryAccessException Add 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
Add 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
Add 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
Add call (consumes 2-bytes)- Parameters:
offset- instruction address offsetdest- call destination offset- Throws:
MemoryAccessException
-
addBytesCall
Add call (consumes 2-bytes)- Parameters:
offset- instruction address offsetdest- call destination offset- Throws:
MemoryAccessException
-
addBytesCall
Add call (consumes 2-bytes)- Parameters:
addr- instruction addressdestAddr- call destination address- Throws:
MemoryAccessException
-
addBytesCallWithDelaySlot
Add call w/ delayslot (consumes 4-bytes)- Parameters:
offset- instruction address offsetdest- call destination offset- Throws:
MemoryAccessException
-
addBytesCallWithDelaySlot
Add call w/ delayslot (consumes 4-bytes)- Parameters:
addr- instruction addressdestAddr- call destination address- Throws:
MemoryAccessException
-
addBytesReturn
Add terminal/return (consumes 2-bytes)- Parameters:
offset- instruction address offset- Throws:
MemoryAccessException
-
addBytesReturn
Add terminal/return (consumes 2-bytes)- Parameters:
addr- instruction address- Throws:
MemoryAccessException
-
addBytesBranch
Add branch (consumes 2-bytes)- Parameters:
offset- address offsetdest- call destination offset- Throws:
MemoryAccessException
-
addBytesBranch
Add branch (consumes 2-bytes)- Parameters:
addr- instruction address offsetdestAddr- call destination address- Throws:
MemoryAccessException
-
addBytesBranchConditional
Add branch (consumes 2-bytes)- Parameters:
offset- instruction address offsetdest- call destination offset- Throws:
MemoryAccessException
-
addBytesBranchConditional
Add branch (consumes 2-bytes)- Parameters:
addr- instruction addressdestAddr- call destination address- Throws:
MemoryAccessException
-
addBytesSkipConditional
Add conditional skip (consumes 2-bytes)- Parameters:
offset- instruction address offset- Throws:
MemoryAccessException
-
addBytesSkipConditional
Add conditional skip (consumes 2-bytes)- Parameters:
addr- instruction address- Throws:
MemoryAccessException
-
addBytesBranchWithDelaySlot
Add branch w/ delay slot (consumes 4-bytes)- Parameters:
offset- instruction address offsetdest- call destination offset- Throws:
MemoryAccessException
-
addBytesBranchWithDelaySlot
Add branch w/ delay slot (consumes 4-bytes)- Parameters:
addr- instruction addressdestAddr- call destination address- Throws:
MemoryAccessException
-
addBytesCopInstruction
Add 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
Add 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
Add BAD instruction (consumes 2-bytes). Location will not be added to defined instruction address list.- Parameters:
offset- bad instruction address offset- Throws:
MemoryAccessException
-
addBytesBadInstruction
Add BAD instruction (consumes 2-bytes). Location will not be added to defined instruction address list.- Parameters:
addr- bad instruction address- Throws:
MemoryAccessException
-
createNOPInstruction
- Throws:
Exception
-
createCallInstruction
- Throws:
Exception
-
createReturnInstruction
- Throws:
Exception
-
createJmpInstruction
- Throws:
Exception
-
createConditionalJmpInstruction
- Throws:
Exception
-
createJmpWithDelaySlot
- Throws:
Exception
-