solitude.debugger module

class solitude.debugger.EvmTrace(rpc: solitude.common.rpc_client.RPCClient, contracts: solitude.common.contract_objectlist.ContractObjectList)[source]

Bases: object

Access debug information from the ETH server

__init__(rpc: solitude.common.rpc_client.RPCClient, contracts: solitude.common.contract_objectlist.ContractObjectList)[source]

Create an EvmTrace instance

Parameters:
  • rpc – RPC client connected to the ETH server
  • contracts – a collection of contracts (see ContractObjectList)
trace_iter(txhash: bytes) → Iterator[Tuple[solitude.debugger.evm_trace.TraceStep, solitude.debugger.evm_trace.CallStackEvent]][source]

Iterate contract execution steps (instructions)

Parameters:txhash – transaction hash to inspect, as byte array
Returns:generator of tuples of (TraceStep, CallStackEvent)
class solitude.debugger.TraceStep

Bases: tuple

Debugger step (instruction) information

code

a SourceMapping object containing the source code and line information

contractname

contract name

depth

call stack depth

error

Error message

fileno

index which identifies the source unit

gas

Gas cost of the instruction

index

incrementing index of the step

jumptype

type of jump, ‘i’ for ‘jump into call’, ‘o’, for ‘jump out of call’, or empty (‘’)

length

length of the source code mapped to this instruction

memory

EVM memory as list of hex strings

op

opcode string

pc

program counter

stack

EVM stack as list of hex strings

start

index of the character in the source file where the source code mapped to this instruction starts

storage

EVM storage as dictionary of hex strings

class solitude.debugger.SourceMapping

Bases: tuple

Source code and line information related to an instruction

line_index

line index where the relevant portion begins

line_pos

index of the column where the relevant portion begins (in line)

line_start

index of the character where the line starts in the file

lines

full source text split in lines

source

full source text

unitname

source unit name

class solitude.debugger.CallStackElement

Bases: tuple

Basic stack frame information

prev

the TraceStep before entering a call

step

the TraceStep after entering a call

class solitude.debugger.CallStackEvent

Bases: tuple

Call stack event information

data

Event data. If the event is of type ‘push’, a CallStackElement

event

Type of event. Can be ‘push’, ‘pop’ or None

class solitude.debugger.EvmDebugCore(client: solitude.client.eth_client.ETHClient, txhash: bytes, windowsize=50)[source]

Bases: object

Provides common debugger-like access to the EVM’s debug information

INVALID_STEP = <solitude.debugger.evm_debug_core.Step object>
__init__(client: solitude.client.eth_client.ETHClient, txhash: bytes, windowsize=50)[source]

Create an EvmDebugCore.

Parameters:
  • client – an ETHClient connected to the ETH node
  • txhash – transaction hash, as bytes
  • windowsize – amount of previous and next steps buffered, for a total of previous (windowsize) + current (1) + next (windowsize).
get_callstack_depth() → int[source]

Get the call stack depth :return: number of frames in the call stack

get_frames() → List[solitude.debugger.evm_debug_core.Frame][source]

Get call stack frames :return: a list of Frame

get_step(offset=0) → solitude.debugger.evm_debug_core.Step[source]

Get step, relative to current step.

Parameters:offset – step offset, relative to the current one. Can be in range (-windowsize, windowsize), according to the windowsize value provided in the constructor.
Returns:a Step
get_values() → Dict[str, solitude.debugger.evm_debug_core.Value][source]

Get named values in the current step, from function parameters and local variables.

Returns:list of Value
step()[source]

Step one instruction forward

class solitude.debugger.Function(name: str, parameters: List[solitude.debugger.evm_debug_core.Value])[source]

Bases: solitude._internal.oi_serializable.ISerializable

Object containing a function call information

__init__(name: str, parameters: List[solitude.debugger.evm_debug_core.Value])[source]

Create a Function object

Parameters:
  • name – function name
  • parameters – list of function parameters, as Value objects
static from_obj(obj)[source]
to_obj()[source]
class solitude.debugger.Frame(prev: solitude.debugger.evm_trace.TraceStep, cur: solitude.debugger.evm_trace.TraceStep)[source]

Bases: solitude._internal.oi_serializable.ISerializable

Call stack frame information

Variables:
  • locals – dictionary of local variable values
  • return_values – list of values produced by return statements
  • function – function call information

Step information is lost during serialization, and the three attributes above are kept

__init__(prev: solitude.debugger.evm_trace.TraceStep, cur: solitude.debugger.evm_trace.TraceStep)[source]

Create a Frame object

Parameters:
  • prev – step before entering the function
  • cur – step after entering the function
static from_obj(obj)[source]
to_obj()[source]
class solitude.debugger.Step(step: Optional[solitude.debugger.evm_trace.TraceStep], event: Optional[solitude.debugger.evm_trace.CallStackEvent])[source]

Bases: object

Single instruction step information

Variables:
  • ast – AST nodes mapped to the instruction, as dictionary of (node type name -> node dict)
  • values – values associated to this instruction (variable assignment, value produced by evaluation of statement, …)
__init__(step: Optional[solitude.debugger.evm_trace.TraceStep], event: Optional[solitude.debugger.evm_trace.CallStackEvent])[source]

Create a Step object

Parameters:
  • step – step information
  • event – call stack event associated with the step

This object may be create empty, with null step and event data.

valid

Wether this object contains step information or is empty

Returns:True if not empty, otherwise False
class solitude.debugger.Value(vtype: str, name: str, value, kind: str, origin=None)[source]

Bases: solitude._internal.oi_serializable.ISerializable

Value debug information

It represents a value associated to a named entity in the source code. Only supports numeric values.

__init__(vtype: str, name: str, value, kind: str, origin=None)[source]

Create a Value object

Parameters:
  • vtype – value type name
  • name – value name
  • value – integer content of value
  • kind – one of ValueKind enum values
  • origin – type of AST node from which the variable information was extracted
static from_obj(obj)[source]
to_obj()[source]
value_repr() → str[source]

Get string representation of the value

Returns:string representation
class solitude.debugger.InteractiveDebuggerOI(txhash, client, code_lines=(3, 6))[source]

Bases: solitude._internal.oi_interface.ObjectInterface

__init__(txhash, client, code_lines=(3, 6))[source]

Initialize self. See help(type(self)) for accurate signature.

cmd_backtrace(args)[source]
cmd_break(args)[source]
cmd_continue(args)[source]
cmd_delete(args)[source]
cmd_finish(args)[source]
cmd_frame(args)[source]
cmd_info_args(args)[source]
cmd_info_breakpoints(args)[source]
cmd_info_locals(args)[source]
cmd_list(args)[source]
cmd_next(args)[source]
cmd_print(args)[source]
cmd_quit(args)[source]
cmd_step(args)[source]
cmd_stepi(args)[source]
format_code(step, before=None, after=None)[source]
static get_source_lines(step: solitude.debugger.evm_trace.TraceStep, strip=False, color='green', before=0, after=0) → solitude._internal.oi_common_objects.ColorText[source]
on_breakpoint(args)[source]
on_revert(args)[source]
on_step(args)[source]
on_terminate(args)[source]