smallworld.state.memory.stack

class smallworld.state.memory.stack.Stack(address: int, size: int)

A stack-like region of memory with convenient operations like push and pop.

abstract property platform: Platform

The platform for which this stack is intended.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

abstractmethod get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

abstractmethod push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.AArch64Stack(address: int, size: int)

A stack for an ARM 64-bit CPU

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.AMD64Stack(address: int, size: int)

A stack for an AMD 64-bit CPU

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.ARMv5tStack(address: int, size: int)

A stack for an ARMv5t 32-bit CPU

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.ARMv6mStack(address: int, size: int)

A stack for an ARMv6m 32-bit CPU

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.ARMv7mStack(address: int, size: int)

A stack for an ARMv7m 32-bit CPU

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.ARMv7rStack(address: int, size: int)

A stack for an ARMv7r 32-bit CPU

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.ARMv7aStack(address: int, size: int)

A stack for an ARMv7a 32-bit CPU

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.X86Stack(address: int, size: int)

A stack for an Intel 32-bit CPU

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.LoongArch64Stack(address: int, size: int)

A stack for a LoongArch 64-bit CPU

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.M68KStack(address: int, size: int)

A stack for an M68K CPU

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.MIPSBEStack(address: int, size: int)

A stack for a big-endian MIPS 32-bit CPU

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.MIPSELStack(address: int, size: int)

A stack for a little-endian MIPS 32-bit CPU

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.MIPS64BEStack(address: int, size: int)

A stack for a big-endian MIPS 64-bit CPU

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.MIPS64ELStack(address: int, size: int)

A stack for a little-endian MIPS 64-bit CPU

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.MSP430Stack(address: int, size: int)

A stack for a TI msp430 CPU

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.PowerPC32Stack(address: int, size: int)

A stack for a PPC 32-bit CPU

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.PowerPC64Stack(address: int, size: int)

A stack for a PPC 64-bit CPU

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.RISCV64Stack(address: int, size: int)

A stack for a RISCV 64-bit CPU

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.XTensaBEStack(address: int, size: int)

A stack for a big-endian XTensa CPU

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.

class smallworld.state.memory.stack.XTensaELStack(address: int, size: int)

A stack for a little-endian XTensa CPU

apply(emulator: Emulator) None

Apply state to an emulator.

Parameters:

emulator – The emulator to which state should applied.

extract(emulator: Emulator) None

Load state from an emulator.

Parameters:

emulator – The emulator from which to load

classmethod for_platform(platform: Platform, address: int, size: int)

Create a stack for this platform.

Parameters:
  • platform – The platform for which this stack is intended.

  • address – Start address for this stack.

  • size – Size of requested stack, in bytes.

get_alignment() int

Get the alignment for this stack.

Returns:

The alignment for this stack.

get_capacity() int

Gets the total number of bytes this memory region can store. :returns: The total number of bytes this memory region can store.

classmethod get_platform() Platform

Retrieve the platform for this stack.

get_pointer() int

Get the current stack pointer.

Returns:

The current value of the stack pointer.

get_used() int

Gets the number of bytes written to this memory region.

Returns:

The number of bytes written to this memory region.

push(value: Value) int

Push a value to the stack.

Parameters:

value – The value to be pushed.

Returns:

The stack pointer after the push.

push_bytes(content: bytes | bytearray, label: str) int

Push some bytes to the stack.

Parameters:
  • content – The bytes to push.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_ctype(content: CTypesAny, label: str) int

Push some structured bytes to the stack.

Parameters:
  • content – The ctypes structured bytes.

  • label – The label for the bytes.

Returns:

The stack pointer after the push.

push_integer(integer: int, size: int, label: str) int

Push an integer to the stack.

Parameters:
  • integer – The integer value to be pushed.

  • size – The size in bytes for the integer on the stack.

  • label – The label for the integer.

Returns:

The stack pointer after the push.

push_symbolic(size: int, label: str) int

Push an uninitialized placeholder to the stack.

Parameters:
  • size – The number of bytes to push.

  • label – The label for the bytes

Returns:

The stack pointer after the push.

read_bytes(address: int, size: int) bytes

Read part of this memory region. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The number of bytes to read.

Returns:

The bytes in the requested memory region.

read_int(address: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) int

Read and interpret as an integer. This will fail if any sub-region of the memory requested is symbolic or uninitialized.

Parameters:
  • address – The address to read from.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

Returns:

The integer read from memory.

to_bytes() bytes

Convert this memory region into a byte string.

Missing/undefined space will be filled with zeros.

Parameters:

byteorder – Byteorder for conversion to raw bytes.

Returns:

Bytes for this object with the given byteorder.

write_bytes(address: int, data: bytes) None

Overwrite part of this memory region with specific bytes. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • data – The bytes to write.

write_int(address: int, value: int, size: Literal[1, 2, 4, 8], byteorder: Byteorder) None

Write an integer to memory. This will fail if any sub-region of the existing memory is symbolic.

Parameters:
  • address – The address to write to.

  • value – The integer value to write.

  • size – The size of the integer in bytes.

  • endianness – The byteorder of the platform.

address: int

The start address of this memory region.

size: int

The size address of this memory region.