Class: Debugger::ThreadSwitchCommand

Inherits:
Command
  • Object
show all
Includes:
ThreadFunctions
Defined in:
lib/ruby-debug/commands/threads.rb

Overview

:nodoc:

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ThreadFunctions

#debugger_thread?, #display_context

Methods inherited from Command

commands, inherited, #initialize, load_commands, #match, method_missing, options

Constructor Details

This class inherits a constructor from Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



78
79
80
81
82
# File 'lib/ruby-debug/commands/threads.rb', line 78

def help(cmd)
  %{
    th[read] [sw[itch]] <nnn>\tswitch thread context to nnn
  }
end

.help_commandObject



74
75
76
# File 'lib/ruby-debug/commands/threads.rb', line 74

def help_command
  'thread'
end

Instance Method Details

#executeObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ruby-debug/commands/threads.rb', line 58

def execute
  c = get_context(@match[1].to_i)
  case
  when c == @state.context
    print "It's the current thread.\n"
  when debugger_thread?(c)
    print "Can't switch to the debugger thread.\n"
  else
    display_context(c)
    c.stop_next = 1
    c.thread.run
    @state.proceed
  end
end

#regexpObject



54
55
56
# File 'lib/ruby-debug/commands/threads.rb', line 54

def regexp
  /^\s*th(?:read)?\s+(?:sw(?:itch)?\s+)?(\d+)\s*$/
end