From 2b428ff2632e73295e9decbcf1c40d8e26213305 Mon Sep 17 00:00:00 2001 From: Mathias Fussenegger Date: Fri, 9 Aug 2024 14:36:09 +0200 Subject: [PATCH] Always set startFrame in stackTrace request Relates to https://github.com/mfussenegger/nvim-dap/discussions/869#discussioncomment-10058258 --- lua/dap/protocol.lua | 31 +++++++++++++++++++++++++++++++ lua/dap/session.lua | 7 ++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lua/dap/protocol.lua b/lua/dap/protocol.lua index 0128bf5e..7662a81f 100644 --- a/lua/dap/protocol.lua +++ b/lua/dap/protocol.lua @@ -61,6 +61,37 @@ ---@field presentationHint nil|"normal"|"label"|"subtle"; ---@field scopes? dap.Scope[] Not part of spec; added by nvim-dap + +---@class dap.StackFrameFormat : dap.ValueFormat +--- Displays parameters for the stack frame. +--- @field parameters? boolean +--- +--- Displays the types of parameters for the stack frame. +--- @field parameterTypes? boolean +--- +--- Displays the names of parameters for the stack frame. +--- @field parameterNames? boolean +--- +--- Displays the values of parameters for the stack frame. +--- @field parameterValues? boolean +--- +--- Displays the line number of the stack frame. +--- @field line? boolean +--- +--- Displays the module of the stack frame. +--- @field module? boolean +--- +--- Includes all stack frames, including those the debug adapter might +--- otherwise hide. +--- @field includeAll? boolean + + +---@class dap.StackTraceArguments +---@field threadId number thread for which to retrieve the stackTrace +---@field startFrame? number index of the first frame to return. If omitted frames start at 0 +---@field levels? number maximum number of frames to return. If absent or 0 all frames are returned +---@field format? dap.StackFrameFormat only honored with supportsValueFormattingOptions capability + ---@class dap.StackTraceResponse ---@field stackFrames dap.StackFrame[] ---@field totalFrames? number diff --git a/lua/dap/session.lua b/lua/dap/session.lua index a717bf8e..10371e34 100644 --- a/lua/dap/session.lua +++ b/lua/dap/session.lua @@ -703,7 +703,12 @@ function Session:event_stopped(stopped) local thread = self.threads[stopped.threadId] assert(thread, 'Thread not found: ' .. stopped.threadId) - local err, response = self:request('stackTrace', { threadId = stopped.threadId; }) + ---@type dap.StackTraceArguments + local params = { + startFrame = 0, + threadId = stopped.threadId + } + local err, response = self:request('stackTrace', params) if err then utils.notify('Error retrieving stack traces: ' .. utils.fmt_error(err), vim.log.levels.ERROR) return