module Byebug::ThreadFunctions
def display_context(context, should_show_top_frame = true)
def display_context(context, should_show_top_frame = true) puts pr('thread.context', thread_arguments(context, should_show_top_frame)) end
def parse_thread_num(subcmd, arg)
def parse_thread_num(subcmd, arg) thnum, err = get_int(arg, subcmd, 1) return [nil, err] unless thnum Byebug.contexts.find { |c| c.thnum == thnum } end
def parse_thread_num_for_cmd(subcmd, arg)
def parse_thread_num_for_cmd(subcmd, arg) c, err = parse_thread_num(subcmd, arg) case when err [c, err] when c.nil? [nil, pr('thread.errors.no_thread')] when @state.context == c [c, pr('thread.errors.current_thread')] when c.ignored? [c, pr('thread.errors.wrong_action', subcmd: subcmd, arg: arg)] else [c, nil] end 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 == Byebug.current_context file_line = "#{@state.file}:#{@state.line}" else backtrace = context.thread.backtrace_locations if backtrace && backtrace[0] file_line = "#{backtrace[0].path}:#{backtrace[0].lineno}" end end end { status_flag: status_flag, debug_flag: debug_flag, id: context.thnum, thread: context.thread.inspect, file_line: file_line || '' } end