Class: Byebug::DAP::Command::StackTrace

Inherits:
Byebug::DAP::Command show all
Defined in:
lib/byebug/dap/commands/stack_trace.rb

Constant Summary

Constants inherited from Byebug::DAP::Command

EVAL_ERROR

Instance Method Summary collapse

Methods inherited from Byebug::DAP::Command

command, execute, #execute_on_thread, #initialize, #log, register!, resolve!, #safe_execute, #started!, #stopped!

Methods included from SafeHelpers

#safe

Constructor Details

This class inherits a constructor from Byebug::DAP::Command

Instance Method Details

#executeObject



7
8
9
10
11
12
13
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
# 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