evm v0.1.14 EVM.Debugger

A first-class debugger for the EVM. We are able to set breakpoints and walk through code execution.

Link to this section Summary

Functions

Breaks execution and begins a REPL to interact with the currently executing code

Sets a new breakpoint based on supplied conditions

Disables the debugger

Enables the debugger

Return true if the currently line of code is tripped by any previously set breakpoint

Returns true only if debugging is currently enabled

Link to this section Functions

Link to this function break(breakpoint, machine_state, sub_state, exec_env, input_sequence \\ [])
break(EVM.Debugger.Breakpoint.t, MachineState.t, SubState.t, ExecEnv.t, [String.t]) :: {MachineState.t, SubState.t, ExecEnv.t}

Breaks execution and begins a REPL to interact with the currently executing code.

Examples

iex> id = EVM.Debugger.Breakpoint.set_breakpoint(%EVM.Debugger.Breakpoint{conditions: [address: <<25::160>>], enabled: false})
iex> breakpoint = EVM.Debugger.Breakpoint.get_breakpoint(id)
iex> machine_state = %EVM.MachineState{}
iex> sub_state = %EVM.SubState{}
iex> exec_env = %EVM.ExecEnv{address: <<26::160>>}
iex> EVM.Debugger.break(breakpoint, machine_state, sub_state, exec_env, ["continue"])
{ %EVM.MachineState{}, %EVM.SubState{}, %EVM.ExecEnv{address: <<26::160>>} }

iex> id = EVM.Debugger.Breakpoint.set_breakpoint(%EVM.Debugger.Breakpoint{conditions: [address: <<25::160>>], enabled: false})
iex> breakpoint = EVM.Debugger.Breakpoint.get_breakpoint(id)
iex> machine_state = %EVM.MachineState{}
iex> sub_state = %EVM.SubState{}
iex> exec_env = %EVM.ExecEnv{address: <<26::160>>}
iex> EVM.Debugger.break(breakpoint, machine_state, sub_state, exec_env, ["zzzzzzz", "continue"])
{ %EVM.MachineState{}, %EVM.SubState{}, %EVM.ExecEnv{address: <<26::160>>} }

Sets a new breakpoint based on supplied conditions.

Examples

iex> id = EVM.Debugger.break_on(address: <<188, 31, 252, 22, 32, 218, 20, 104, 98, 74, 89, 108, 184, 65, 211, 94, 107, 47, 31, 182>>)
iex> EVM.Debugger.Breakpoint.get_breakpoint(id) |> Map.put(:id, nil)
%EVM.Debugger.Breakpoint{conditions: [address: <<188, 31, 252, 22, 32, 218, 20, 104, 98, 74, 89, 108, 184, 65, 211, 94, 107, 47, 31, 182>>], pc: :start}
Link to this function disable()
disable() :: :ok

Disables the debugger.

Examples

iex> EVM.Debugger.disable
:ok
iex> EVM.Debugger.enable
:ok
iex> EVM.Debugger.disable
:ok
Link to this function enable()
enable() :: :ok

Enables the debugger.

Note: the debugger should only be run when debugging; it may

  seriously degrade performance of the VM during normal
  operations.

Examples

iex> EVM.Debugger.enable
:ok
iex> EVM.Debugger.is_enabled?
true
iex> EVM.Debugger.disable
:ok
iex> EVM.Debugger.enable
:ok
iex> EVM.Debugger.disable
:ok
Link to this function handle_input(input, breakpoint, machine_state, sub_state, exec_env, input_sequence)
handle_input(String.t, EVM.Debugger.Breakpoint.t, MachineState.t, SubState.t, ExecEnv.t, [String.t]) :: {MachineState.t, SubState.t, ExecEnv.t}
Link to this function is_breakpoint?(machine_state, sub_state, exec_env)
is_breakpoint?(MachineState.t, SubState.t, ExecEnv.t) ::
  :continue |
  EVM.Debugger.Breakpoint.t

Return true if the currently line of code is tripped by any previously set breakpoint.

Examples

iex> EVM.Debugger.Breakpoint.set_breakpoint(%EVM.Debugger.Breakpoint{conditions: [address: <<25::160>>], pc: :next})
iex> machine_state = %EVM.MachineState{}
iex> sub_state = %EVM.SubState{}
iex> exec_env = %EVM.ExecEnv{address: <<25::160>>}
iex> EVM.Debugger.is_breakpoint?(machine_state, sub_state, exec_env) |> Map.put(:id, nil)
%EVM.Debugger.Breakpoint{conditions: [address: <<25::160>>], pc: :next}

iex> EVM.Debugger.Breakpoint.set_breakpoint(%EVM.Debugger.Breakpoint{conditions: [address: <<25::160>>], enabled: false})
iex> machine_state = %EVM.MachineState{}
iex> sub_state = %EVM.SubState{}
iex> exec_env = %EVM.ExecEnv{address: <<26::160>>}
iex> EVM.Debugger.is_breakpoint?(machine_state, sub_state, exec_env)
:continue
Link to this function is_enabled?()
is_enabled?() :: boolean

Returns true only if debugging is currently enabled.

This is set in the application config.

Examples

iex> Application.put_env(EVM.Debugger, :enabled, true)
iex> EVM.Debugger.is_enabled?
true
iex> Application.put_env(EVM.Debugger, :enabled, false)
:ok

iex> Application.put_env(EVM.Debugger, :enabled, false)
iex> EVM.Debugger.is_enabled?
false

iex> EVM.Debugger.is_enabled?
false