Class: Byebug::ThreadSwitchCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/byebug/commands/threads.rb

Overview

Switch execution to a different thread.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



208
209
210
# File 'lib/byebug/commands/threads.rb', line 208

def description
  %(th[read] [sw[itch]] <nnn>        Switches thread context to <n>.)
end

.namesObject



204
205
206
# File 'lib/byebug/commands/threads.rb', line 204

def names
  %w(thread)
end

Instance Method Details

#executeObject



189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/byebug/commands/threads.rb', line 189

def execute
  if @match[1] =~ /switch/
    return errmsg('"thread switch" needs a thread number')
  end

  c = parse_thread_num_for_cmd('thread switch', @match[1])
  return unless c

  display_context(c)
  c.step_into 1
  c.thread.run
  @state.proceed
end

#regexpObject



185
186
187
# File 'lib/byebug/commands/threads.rb', line 185

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