Version | Date | Change |
---|---|---|
0.1 | 2011-02-18 | Initial contribution |
Disassembly is the translation of machine language (or memory bytes), into human readable assembly language. The readable assembly language is produced from a specified Instruction Set Architecture (or ISA).
While disassembly is dependent upon a specific processor architecture, the memory from which it is derived is not. So for a given memory context, or buffer, the specified ISA used to disassemble the memory bytes is subjective to the Tool or user.
The service uses standard format for error reports, see Error Report Format.
C • <token> • Disassembly • disassemble • <string: context-id> • <int: start location> • <int: size> • <object: disassembly parameters> •
The command disassembles instruction code from a specified range of memory, in a specified context.
Where context-id is the memory context in which to process the command.
Predefined properties are:
"ISA" : <string>
- The name of the instruction set architecture.
"Simplified" : <boolean>
- If true, simplified mnemonics are specified.
"PseudoInstructions" : <boolean>
- If true, pseudo-instructions are requested.
"OpcodeValue" : <boolean>
- If true, the instruction code byte values are returned.
Reply:
R • <token> • <error report> • <array: disassembly output> • <array: disassembly output> ⇒ <null> ⇒ [ ] ⇒ [ <disassembly line list> ] <disassembly line list> ⇒ <object: disassembly line> ⇒ <disassembly line list>, <object: disassembly line>
<object: disassembly line>
Disassembly line is an object containing properties. Predefined properties are:
"ISA" : <string>
- Instruction Set Architecture of the disassembly line
"Address" : <int>
- Address of the instruction
"Size" : <int>
- Size of the instruction in bytes
"Instruction" : <array>
- Array of the intruction fields
"OpcodeValue" : <string>
- Encoded byte array of the instruction binary representation
<object: Instruction field>
Instruction field is an object containing properties. Predefined properties are:
"Type" : <string>
- The predefined type of the instruction field. Predefined types are:
"Text" : <string>
- Value of the field for "String" and "Register" types.
"Value" : <number>
- Value of the field for "Address," "Displacement," or "Immediate" types.
"AddressSpace" : <context-id>
- Context-ID of the address space used with the "Address" type.
Examples:
The following command requests disassembly at address 0x1000
, for 8 bytes, in memory context "mc1", using a generic PowerPC ISA, and requesting instruction code bytes:
C <token> Disassembly disassemble "mc1" 0x1000 8 {ISA:PPC,OpcodeValue:true}
C • <token> • Disassembly • getCapabilities • <string: context ID> •
The command reports disassembly service capabilities to clients so they can adjust to different implementations of the service. The exact definition of context depends on the target agent and provided topology.
Reply:
R • <token> • <error report> • <service capabilities> • <service capabilities> ⇒ <null> ⇒ <array: capabilities list>
Service capabilities consist of an array of lists of properties. All properties are optional. Tools and targets can define additional properties. Predefined properties are:
"ISA" : <string>
- The name of the supported instruction set architecture
"Simplified" : <boolean>
- If true, simplified mnemonics are supported. These are typical 1:1 correlation of architecture instruction to simplified mnemonic.
"PseudoInstruction" : <boolean>
- If true, pseudo-instructions are supported. These are typically macros, which correlate multiple architecture instructions to one pseudo-instruction.
"OpcodeValue" : <boolean>
- If true, the decoded instruction code bytes are retrievable with the OpcodeValue parameter.
/** * TCF Disassembly service interface. * * @noimplement This interface is not intended to be implemented by clients. */ public interface IDisassembly extends IService { /** * This service name, as it appears on the wire - a TCF name of the service. */ static final String NAME = "Disassembly"; static final String /** The name of the instruction set architecture, String */ CAPABILITY_ISA = "ISA", /** If true, simplified mnemonics are supported or requested, Boolean */ CAPABILITY_SIMPLIFIED = "Simplified", /** If true, pseudo-instructions are supported or requested, Boolean */ CAPABILITY_PSEUDO = "Pseudo", /** If true, instruction code bytes are supported or requested, Boolean */ CAPABILITY_OPCODE = "OpcodeValue"; /** * Retrieve disassembly service capabilities a given context-id. * @param context_id - a context ID, usually one returned by Run Control or Memory services. * @param done - command result call back object. * @return - pending command handle. */ IToken getCapabilities(String context_id, DoneGetCapabilities done); /** * Call back interface for 'getCapabilities' command. */ interface DoneGetCapabilities { /** * Called when capabilities retrieval is done. * @param token - command handle. * @param error - error object or null. * @param capabilities - array of capabilities, see CAPABILITY_* for contents of each array element. */ void doneGetCapabilities(IToken token, Throwable error, Map<String,Object>[] capabilities); } /** * Disassemble instruction code from a specified range of memory addresses, in a specified context. * @param context_id - a context ID, usually one returned by Run Control or Memory services. * @param addr - address of first instruction to disassemble. * @param size - size in bytes of the address range. * @param params - properties to control the disassembly output, an element of capabilities array, see getCapabilities. * @param done - command result call back object. * @return - pending command handle. */ IToken disassemble(String context_id, Number addr, int size, Map<String,Object> params, DoneDisassemble done); /** * Call back interface for 'disassemble' command. */ interface DoneDisassemble { /** * Called when disassembling is done. * @param token - command handle. * @param error - error object or null. * @param disassembly - array of disassembly lines. */ void doneDisassemble(IToken token, Throwable error, IDisassemblyLine[] disassembly); } /** * Interface to represent a single disassembly line. */ interface IDisassemblyLine { /** * @return instruction address. */ Number getAddress(); /** * @return instruction size in bytes. */ int getSize(); /** * @return instruction binary representation. */ byte[] getOpcodeValue(); /** * @return array of instruction fields, each field is a collection of field properties, see FIELD_*. */ Map<String,Object>[] getInstruction(); } /** Instruction field properties */ static final String /** The type of the instruction field. See FTYPE_*, String. */ FIELD_TYPE = "Type", /** Value of the field for "String" and "Register" types, String. */ FIELD_TEXT = "Text", /** Value of the field for "Address", "Displacement", or "Immediate" types, Number. */ FIELD_VALUE = "Value", /** Context ID of the address space used with "Address" types, String. */ FIELD_ADDRESS_SPACE = "AddressSpace"; /** Instruction field types */ static final String FTYPE_STRING = "String", FTYPE_ADDRESS = "Address", FTYPE_DISPLACEMENT = "Displacement", FTYPE_IMMEDIATE = "Immediate"; /** @since 1.7 */ static final String FTYPE_REGISTER = "Register"; /** * @deprecated */ static final String FTYPE_Register = "Register"; }