Module: Byebug::ThreadFunctions

Defined in:
lib/byebug/commands/threads.rb

Instance Method Summary collapse

Instance Method Details

#display_context(c, show_top_frame = true) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/byebug/commands/threads.rb', line 4

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



17
18
19
20
21
22
23
24
25
26
# File 'lib/byebug/commands/threads.rb', line 17

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



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

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 byebug's thread #{arg}.\n"
  else # Everything is okay
    return c
  end
  return nil
end