Module: Byebug::ThreadFunctions
- Defined in:
- lib/byebug/commands/threads.rb
Overview
Utilities to assist commands related to threads.
Instance Method Summary collapse
- #display_context(context, should_show_top_frame = true) ⇒ Object
- #parse_thread_num(subcmd, arg) ⇒ Object
- #parse_thread_num_for_cmd(subcmd, arg) ⇒ Object
- #thread_arguments(context, should_show_top_frame = true) ⇒ Object
Instance Method Details
#display_context(context, should_show_top_frame = true) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/byebug/commands/threads.rb', line 6 def display_context(context, should_show_top_frame = true) args = thread_arguments(context, should_show_top_frame) interp = format("%s%s%d %s\t%s", args[:status_flag], args[:debug_flag], args[:id], args[:thread], args[:file_line]) puts interp end |
#parse_thread_num(subcmd, arg) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/byebug/commands/threads.rb', line 43 def parse_thread_num(subcmd, arg) return errmsg("\"#{subcmd}\" needs a thread number") if '' == arg thread_num, err = get_int(arg, subcmd, 1) return errmsg(err) unless thread_num Byebug.contexts.find { |c| c.thnum == thnum } end |
#parse_thread_num_for_cmd(subcmd, arg) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/byebug/commands/threads.rb', line 52 def parse_thread_num_for_cmd(subcmd, arg) c = parse_thread_num(subcmd, arg) return unless c case when nil == c errmsg 'No such thread' when @state.context == c errmsg "It's the current thread" when c.ignored? errmsg "Can't #{subcmd} thread #{arg}" else c end end |
#thread_arguments(context, should_show_top_frame = true) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/byebug/commands/threads.rb', line 14 def thread_arguments(context, should_show_top_frame = true) status_flag = if context.suspended? '$' else context.thread == Thread.current ? '+' : ' ' end debug_flag = context.ignored? ? '!' : ' ' if should_show_top_frame if context.thread == Thread.current && !context.dead? file = context.frame_file(0) line = context.frame_line(0) else if context.thread.backtrace_locations && context.thread.backtrace_locations[0] file = context.thread.backtrace_locations[0].path line = context.thread.backtrace_locations[0].lineno end end file_line = "#{file}:#{line}" end { status_flag: status_flag, debug_flag: debug_flag, id: context.thnum, thread: context.thread.inspect, file_line: file_line ? file_line : '' } end |