cpu_instruction_query interface can be used in functions
of the following types:
cpu_instruction_cb_tcpu_cached_instruction_cb_tcpu_instruction_decoder_cb_t
where an instruction_handle_t pointer is available. The
handle is only valid in the callback. The interface is used to request
information about the instruction being executed by the processor
cpu.
SIM_INTERFACE(cpu_instruction_query) {
logical_address_t (*logical_address)(
conf_object_t *cpu, instruction_handle_t *handle);
physical_address_t (*physical_address)(
conf_object_t *cpu, instruction_handle_t *handle);
cpu_bytes_t (*get_instruction_bytes)(
conf_object_t *cpu, instruction_handle_t *handle);
bool (*is_existing_instruction)(
conf_object_t *cpu, instruction_handle_t *handle);
};
#define CPU_INSTRUCTION_QUERY_INTERFACE "cpu_instruction_query"
The logical_address and physical_address is used to get the different addresses of the instruction being executed.
Note that if the instruction crosses a page boundary the last part of the
instruction will have a different mapping for the physical address than
returned by physical_address. To get hold of the physical address
on the second page, use the logical_to_physical method of the
processor_info(_v2) and provide the logical address of the
first byte on the second page.
The get_instruction_bytes method is used to read the instruction bytes. The returned data is of a cpu_bytes_t type that contains the data and the size. The data member is only available during the execution of the callback. The data cannot be changed. Corresponding type in Python is a string of bytes.
typedef struct cpu_bytes {
size_t size;
#ifndef PYWRAP
const uint8 *data;
#endif
} cpu_bytes_t;
The is_existing_instruction method is used to determine if Simics
managed to decode the instruction bytes. Note that despite this method
returning false could imply that the instruction is implemented using a user
supplied implementation through the
x86_instrumentation_subscribe interface.
Additional information can be read out with an architectural specific query
interface, see x86_instruction_query for details.
instruction_handle_t.