module Byebug::ThreadFunctions
def display_context(context, should_show_top_frame = true)
def display_context(context, should_show_top_frame = true) args = thread_arguments(context, should_show_top_frame) print "%s%s%d %s\t%s\n", args[:status_flag], args[:debug_flag], args[:id], args[:thread], args[:file_line] end
def parse_thread_num(subcmd, arg)
def parse_thread_num(subcmd, arg) if '' == arg errmsg "\"#{subcmd}\" needs a thread number" nil else thread_num = get_int(arg, subcmd, 1) return nil unless thread_num get_context(thread_num) end end
def parse_thread_num_for_cmd(subcmd, arg)
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' when @state.context == c errmsg "It's the current thread" when c.ignored? errmsg "Can't #{subcmd} thread #{arg}" else return c end return nil end
def thread_arguments(context, should_show_top_frame = true)
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 file = @state.context.frame_file(0) line = @state.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