Module: Debugger::ThreadFunctions

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

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#display_context(context, should_show_top_frame = true) ⇒ Object



3
4
5
# File 'lib/ruby-debug/commands/threads.rb', line 3

def display_context(context, should_show_top_frame = true)
  print pr("thread.context", thread_arguments(context, should_show_top_frame))
end

#parse_thread_num(subcmd, arg) ⇒ Object



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

def parse_thread_num(subcmd, arg)
  if '' == arg
    errmsg pr("thread.errors.no_number", subcmd: 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



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ruby-debug/commands/threads.rb', line 40

def parse_thread_num_for_cmd(subcmd, arg)
  c = parse_thread_num(subcmd, arg)
  return nil unless c
  case 
  when nil == c
    errmsg pr("thread.errors.no_thread")
  when @state.context == c
    errmsg pr("thread.errors.current_thread")
  when c.ignored?
    errmsg pr("thread.errors.wrong_action", subcmd: subcmd, arg: arg)
  else # Everything is okay
    return c
  end
  return nil
end

#thread_arguments(context, should_show_top_frame = true) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ruby-debug/commands/threads.rb', line 7

def thread_arguments(context, should_show_top_frame = true)
  is_current = context.thread == Thread.current
  status_flag = if context.suspended?
    "$"
  else
    is_current ? '+' : ' '
  end
  debug_flag = context.ignored? ? '!' : ' '
  file_line = if context.stack_size > 0 && should_show_top_frame
    "#{context.frame_file(0)}:#{context.frame_line(0)}"
  end
  {
    status_flag: status_flag,
    debug_flag: debug_flag,
    id: context.thnum,
    thread: context.thread.inspect,
    file_line: file_line,
    status: context.thread.status,
    current: is_current ? "yes" : "no"
  }
end