class Byebug::DAP::Command::StackTrace

Public Instance Methods

execute() click to toggle source
# File lib/byebug/dap/commands/stack_trace.rb, line 7
def execute
  started!

  ctx = find_thread(args.threadId)

  first = args.startFrame || 0
  if !args.levels
    last = ctx.stack_size
  else
    last = first + args.levels
    if last > ctx.stack_size
      last = ctx.stack_size
    end
  end

  frames = (first...last).map do |i|
    frame = ::Byebug::Frame.new(ctx, i)
    {
      id: @session.save_frame(ctx.thnum, i),
      name: frame_name(frame),
      source: {
        name: File.basename(frame.file),
        path: File.expand_path(frame.file),
      },
      line: frame.line,
      column: 1,
    }
  end

  respond! body: {
    stackFrames: frames,
    totalFrames: ctx.stack_size,
  }
end

Private Instance Methods

frame_name(frame) click to toggle source
# File lib/byebug/dap/commands/stack_trace.rb, line 44
def frame_name(frame)
  frame.deco_call
rescue
  frame.deco_block + frame.deco_class + frame.deco_method + "(?)"
end