Module: Debugger::ThreadFunctions

Defined in:
lib/ruby-debug/commands/threads.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#display_context(c, show_top_frame = true) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/ruby-debug/commands/threads.rb', line 3

def display_context(c, show_top_frame=true)
  c_flag = c.thread == Thread.current ? '+' : ' '
  c_flag = '$' if c.suspended?
  d_flag = c.ignored? ? '!' : ' '
  print "%s%s", c_flag, d_flag
  print "%d ", c.thnum
  print "%s\t", c.thread.inspect
  if c.stack_size > 0 and show_top_frame
    print "%s:%d", c.frame_file(0), c.frame_line(0)
  end
  print "\n"
end

#parse_thread_num(subcmd, arg) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/ruby-debug/commands/threads.rb', line 16

def parse_thread_num(subcmd, arg)
  if '' == arg
    errmsg "'%s' needs a thread number\n" % subcmd
    nil
  else
    thread_num = get_int(arg, "thread #{subcmd}", 1)
    return nil unless thread_num
    get_context(thread_num)
  end
end

#parse_thread_num_for_cmd(subcmd, arg) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ruby-debug/commands/threads.rb', line 27

def parse_thread_num_for_cmd(subcmd, arg)
  c = parse_thread_num(subcmd, arg)
  return nil unless c
  case 
  when nil == c
    errmsg "No such thread.\n"
  when @state.context == c
    errmsg "It's the current thread.\n"
  when c.ignored?
    errmsg "Can't #{subcmd} to the debugger thread #{arg}.\n"
  else # Everything is okay
    return c
  end
  return nil
end