Class: PuppetDebugServer::DebugSession::PuppetSessionRunMode

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet-debugserver/debug_session/puppet_session_run_mode.rb

Overview

The run mode and configuration for a Debug Session.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode = :run, options = {}) ⇒ PuppetSessionRunMode

Returns a new instance of PuppetSessionRunMode.

Parameters:

  • mode (defaults to: :run)

    See mode. Default is run

  • options (defaults to: {})

    See options



18
19
20
21
22
23
24
25
# File 'lib/puppet-debugserver/debug_session/puppet_session_run_mode.rb', line 18

def initialize(mode = :run, options = {})
  raise "Invalid mode #{mode}" unless %i[run stepin next stepout].include?(mode)

  @mode = mode
  @options = options

  @run_mode_mutex = Mutex.new
end

Instance Attribute Details

#modeSymbol

The run mode fo the debug session. Either run, stepin, next, or stepout

Returns:

  • (Symbol)


9
10
11
# File 'lib/puppet-debugserver/debug_session/puppet_session_run_mode.rb', line 9

def mode
  @mode
end

#optionsHash

Any options associated with the current mode.

Returns:

  • (Hash)


14
15
16
# File 'lib/puppet-debugserver/debug_session/puppet_session_run_mode.rb', line 14

def options
  @options
end

Instance Method Details

#next!(pops_depth_level) ⇒ Object

Configures the run_mode for “next”-ing through a debug session.

Parameters:

  • pops_depth_level (Integer)

    The depth of the AST object where the next command was initiated from.



37
38
39
40
41
42
43
44
# File 'lib/puppet-debugserver/debug_session/puppet_session_run_mode.rb', line 37

def next!(pops_depth_level)
  @run_mode_mutex.synchronize do
    @mode = :next
    @options = {
      pops_depth_level: pops_depth_level
    }
  end
end

#run!Object

Configures the run_mode for “continue until a breakpoint is hit.



28
29
30
31
32
33
# File 'lib/puppet-debugserver/debug_session/puppet_session_run_mode.rb', line 28

def run!
  @run_mode_mutex.synchronize do
    @mode = :run
    @options = {}
  end
end

#step_in!Object

Configures the run_mode for “stepping in” a debug session.



47
48
49
50
51
52
# File 'lib/puppet-debugserver/debug_session/puppet_session_run_mode.rb', line 47

def step_in!
  @run_mode_mutex.synchronize do
    @mode = :stepin
    @options = {}
  end
end

#step_out!(pops_depth_level) ⇒ Object

Configures the run_mode for “stepping out” a debug session.

Parameters:

  • pops_depth_level (Integer)

    The depth of the AST object where the step put command was initiated from.



56
57
58
59
60
61
62
63
# File 'lib/puppet-debugserver/debug_session/puppet_session_run_mode.rb', line 56

def step_out!(pops_depth_level)
  @run_mode_mutex.synchronize do
    @mode = :stepout
    @options = {
      pops_depth_level: pops_depth_level
    }
  end
end