diff --git a/lldb/tools/lldb-vscode/JSONUtils.h b/lldb/tools/lldb-vscode/JSONUtils.h --- a/lldb/tools/lldb-vscode/JSONUtils.h +++ b/lldb/tools/lldb-vscode/JSONUtils.h @@ -232,13 +232,21 @@ /// provided by the setBreakpoints request are returned to the IDE as a /// fallback. /// +/// \param[in] request_column +/// An optional column to use when creating the resulting "Breakpoint" object. +/// It is used if the breakpoint has no valid locations. +/// It is useful to ensure the same column +/// provided by the setBreakpoints request are returned to the IDE as a +/// fallback. +/// /// \return /// A "Breakpoint" JSON object with that follows the formal JSON /// definition outlined by Microsoft. llvm::json::Value CreateBreakpoint(lldb::SBBreakpoint &bp, std::optional request_path = std::nullopt, - std::optional request_line = std::nullopt); + std::optional request_line = std::nullopt, + std::optional request_column = std::nullopt); /// Converts a LLDB module to a VS Code DAP module for use in "modules" events. /// diff --git a/lldb/tools/lldb-vscode/JSONUtils.cpp b/lldb/tools/lldb-vscode/JSONUtils.cpp --- a/lldb/tools/lldb-vscode/JSONUtils.cpp +++ b/lldb/tools/lldb-vscode/JSONUtils.cpp @@ -308,7 +308,8 @@ // } llvm::json::Value CreateBreakpoint(lldb::SBBreakpoint &bp, std::optional request_path, - std::optional request_line) { + std::optional request_line, + std::optional request_column) { // Each breakpoint location is treated as a separate breakpoint for VS code. // They don't have the notion of a single breakpoint with multiple locations. llvm::json::Object object; @@ -345,11 +346,16 @@ const auto line = line_entry.GetLine(); if (line != UINT32_MAX) object.try_emplace("line", line); + const auto column = line_entry.GetColumn(); + if (column != 0) + object.try_emplace("column", column); object.try_emplace("source", CreateSource(line_entry)); } // We try to add request_line as a fallback if (request_line) object.try_emplace("line", *request_line); + if (request_column) + object.try_emplace("column", *request_column); return llvm::json::Value(std::move(object)); } diff --git a/lldb/tools/lldb-vscode/SourceBreakpoint.cpp b/lldb/tools/lldb-vscode/SourceBreakpoint.cpp --- a/lldb/tools/lldb-vscode/SourceBreakpoint.cpp +++ b/lldb/tools/lldb-vscode/SourceBreakpoint.cpp @@ -16,7 +16,9 @@ column(GetUnsigned(obj, "column", 0)) {} void SourceBreakpoint::SetBreakpoint(const llvm::StringRef source_path) { - bp = g_vsc.target.BreakpointCreateByLocation(source_path.str().c_str(), line); + lldb::SBFileSpecList module_list; + bp = g_vsc.target.BreakpointCreateByLocation(source_path.str().c_str(), line, + column, 0, module_list); // See comments in BreakpointBase::GetBreakpointLabel() for details of why // we add a label to our breakpoints. bp.AddName(GetBreakpointLabel());