microprobe.code.context.Context
- class Context(default_context: Context | None = None, code_segment: int | None = None, data_segment: int | None = None, symbolic: bool = True, absolute: bool = False)[source]
Bases:
object
Class to represent the execution context (e.g. register values, etc … on each benchmark building block)
- __init__(default_context: Context | None = None, code_segment: int | None = None, data_segment: int | None = None, symbolic: bool = True, absolute: bool = False)[source]
- Parameters:
default_context – (Default value = None)
code_segment – (Default value = None)
data_segment – (Default value = None)
symbolic – (Default value = True)
Methods
__init__
([default_context, code_segment, ...])- param default_context:
(Default value = None)
add_reserved_registers
(rregs)Add the provided registers into the reserved register list.
copy
()Returns a copy of the current context.
dump
()Return a dump of the current context status.
get_closest_address_value
(address)Returns the closest address to the given address.
get_closest_value
(value)Returns the closest value to the given value.
get_memory_value
(address)Gets a memory value.
get_register_closest_value
(value)Returns the register with the closest value to the given value.
get_register_value
(register)Returns the register value.
get_registername_value
(register_name)Returns the register value.
register_has_value
(value)Returns if a value is in a register.
registers_get_value
(value)Gets a list of registers containing the specified value.
remove_reserved_registers
(rregs)Remove the provided registers from the reserved register list.
set_absolute
(value)Sets the force_absolute property.
set_code_segment
(value)Sets the code segment start address.
set_dat
(dat)Sets the dynamic address translation object.
set_data_segment
(value)Sets the data segment start address.
set_memory_value
(mem_value)Sets a memory value.
set_register_value
(register, value)Set the provided register to the specified value.
set_symbolic
(value)Sets the symbolic property.
unset_memory
(address, length)Unsets a memory region.
unset_register
(register)Remove the value from a register.
unset_registers
(registers)Removes the values from registers.
Attributes
Address starting the code segment (:
int
)DAT object (
DynamicAddressTranslation
Address starting the data segment (:
int
)Boolean indicating if absolute addresses are needed.
Dictionary of register, value pairs (
dict
)List of reserved registers (
list
)Boolean indicating if the context allows symbol labels
- add_reserved_registers(rregs: List[Register])[source]
Add the provided registers into the reserved register list.
- remove_reserved_registers(rregs: List[Register])[source]
Remove the provided registers from the reserved register list.
- set_register_value(register: Register, value: int | float | Address | str)[source]
Set the provided register to the specified value.
- get_closest_value(value)[source]
Returns the closest value to the given value.
Returns the closest value to the given value. If there are not values registered, None is returned.
- get_closest_address_value(address: Address)[source]
Returns the closest address to the given address.
Returns the closest address to the given address. If there are not addresses registered, None is returned.
- Parameters:
address (
Address
) – Address to look for
- get_register_closest_value(value)[source]
Returns the register with the closest value to the given value.
Returns the register with the closest value to the given value. If there are not values registered, None is returned. Address values are ignored.
- get_register_value(register: Register)[source]
Returns the register value. None if not found.
- Parameters:
register (
Register
) – Register to get its value
- get_registername_value(register_name: str)[source]
Returns the register value. None if not found.
- Parameters:
register (
str
) – Register name to get its valueregister_name
- unset_register(register)[source]
Remove the value from a register.
- Parameters:
register (
Register
) – Registers
- set_memory_value(mem_value: MemoryValue)[source]
Sets a memory value.
- Parameters:
mem_value (
MemoryValue
) – Memory value to set.
- get_memory_value(address: Address)[source]
Gets a memory value.
- Parameters:
address (
Address
) – Address to look for
- register_has_value(value: int | float | Address | str)[source]
Returns if a value is in a register.
- Parameters:
value (
bool
) – Value to look for
- registers_get_value(value: int | float | Address | str)[source]
Gets a list of registers containing the specified value.
- set_data_segment(value: int | None)[source]
Sets the data segment start address.
- Parameters:
value (:
int
) – Start address.
- property dat
DAT object (
DynamicAddressTranslation
- set_dat(dat: DynamicAddressTranslation)[source]
Sets the dynamic address translation object.
- Parameters:
dat (
DynamicAddressTranslation
) – DAT object.
- set_code_segment(value: int | None)[source]
Sets the code segment start address.
- Parameters:
value (
int
) – Start address.
- property symbolic
Boolean indicating if the context allows symbol labels
Boolean indicating if the context allows symbol labels (
bool
)
- set_symbolic(value: bool)[source]
Sets the symbolic property.
- Parameters:
value (
bool
) – Boolean indicating if the context allows symbol labels
- property force_absolute
Boolean indicating if absolute addresses are needed.
Boolean indicating if absolute addresses are needed (
bool
)