Skip to content

[lldb][dap] always add column field in StackFrame body #73393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2024

Conversation

xujuntwt95329
Copy link
Contributor

The column field is mandatory in StackTraceResponse, otherwise the debugger client may raise error (e.g. VSCode can't correctly open an editor without the column field)

@llvmbot
Copy link
Member

llvmbot commented Nov 25, 2023

@llvm/pr-subscribers-lldb

Author: Xu Jun (xujuntwt95329)

Changes

The column field is mandatory in StackTraceResponse, otherwise the debugger client may raise error (e.g. VSCode can't correctly open an editor without the column field)


Full diff: https://github.com/llvm/llvm-project/pull/73393.diff

1 Files Affected:

  • (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+1-2)
diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp
index 03a43f9da87f241..e65b05243df7066 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -817,8 +817,7 @@ llvm::json::Value CreateStackFrame(lldb::SBFrame &frame) {
     if (line && line != LLDB_INVALID_LINE_NUMBER)
       object.try_emplace("line", line);
     auto column = line_entry.GetColumn();
-    if (column && column != LLDB_INVALID_COLUMN_NUMBER)
-      object.try_emplace("column", column);
+    object.try_emplace("column", column);
   } else {
     object.try_emplace("line", 0);
     object.try_emplace("column", 0);

Copy link
Member

@bulbazord bulbazord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm thanks!

Copy link
Member

@walter-erquinigo walter-erquinigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@semensanyok
Copy link

Bug confirmed. Its causing exception for nvim-dap plugin which expects column required in specification, but not sent by server.
pr contains log message, showing missing column case. closed by maintainer:

Thanks for the PR, but I'm not going to merge this. column is a required property of a StackFrame according to the specification:

https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame

This needs to be fixed in the debug adapter.

mfussenegger/nvim-dap#1195

@walter-erquinigo
Copy link
Member

@semensanyok, I've just merged this PR because it's very straightforward. If it breaks the buildbots, I'll just revert it and let the original author fix it.

pranavk added a commit that referenced this pull request Apr 23, 2024
#73393 introduced a mandatory column field. Update test for that.
JDevlieghere pushed a commit to swiftlang/llvm-project that referenced this pull request May 24, 2024
The `column` field is mandatory in StackTraceResponse, otherwise the
debugger client may raise error (e.g. VSCode can't correctly open an
editor without the column field)

---------

Signed-off-by: Xu Jun <[email protected]>
(cherry picked from commit 99f42e6)
JDevlieghere pushed a commit to swiftlang/llvm-project that referenced this pull request May 24, 2024
llvm#73393 introduced a mandatory column field. Update test for that.

(cherry picked from commit aa89c1b)
@CheapMeow
Copy link

It still has bug in VSCode: The editor could not be opened due to an unexpected error: Invalid arguments

My llvm version is

lldb version 18.1.8
clang version 18.1.8
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: E:\software\LLVM\bin
Found HIP installation: E:\software\AMD\ROCm\6.1\, version 6.1.40252

platform is

microsoft windows 11 professional

@clayborg
Copy link
Collaborator

I wonder if this needs to default to column 1? We might end up adding column zero.

  /**
   * Start position of the range covered by the stack frame. It is measured in
   * UTF-16 code units and the client capability `columnsStartAt1` determines
   * whether it is 0- or 1-based. If attribute `source` is missing or doesn't
   * exist, `column` is 0 and should be ignored by the client.
   */
  column: number;

So if we return zero, it might cause a problem as the InitializeRequestArguments contains:

  /**
   * If true all column numbers are 1-based (default).
   */
  columnsStartAt1?: boolean;

1 is the default, and if we return zero, this could cause a problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants