[Lldb-commits] [lldb] da59370 - [lldb-vscode] Adding support for column break points.
David Goldman via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 6 13:34:09 PDT 2023
Author: John Harrison
Date: 2023-07-06T16:33:22-04:00
New Revision: da59370b0977083fa081f4f113179110c86916e5
URL: https://github.com/llvm/llvm-project/commit/da59370b0977083fa081f4f113179110c86916e5
DIFF: https://github.com/llvm/llvm-project/commit/da59370b0977083fa081f4f113179110c86916e5.diff
LOG: [lldb-vscode] Adding support for column break points.
Reviewed By: wallace
Differential Revision: https://reviews.llvm.org/D154029
Added:
Modified:
lldb/tools/lldb-vscode/JSONUtils.cpp
lldb/tools/lldb-vscode/JSONUtils.h
lldb/tools/lldb-vscode/SourceBreakpoint.cpp
Removed:
################################################################################
diff --git a/lldb/tools/lldb-vscode/JSONUtils.cpp b/lldb/tools/lldb-vscode/JSONUtils.cpp
index 2c54f1a4e271bd..8632ba929f77d9 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.cpp
+++ b/lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -308,7 +308,8 @@ llvm::json::Value CreateScope(const llvm::StringRef name,
// }
llvm::json::Value CreateBreakpoint(lldb::SBBreakpoint &bp,
std::optional<llvm::StringRef> request_path,
- std::optional<uint32_t> request_line) {
+ std::optional<uint32_t> request_line,
+ std::optional<uint32_t> 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 @@ llvm::json::Value CreateBreakpoint(lldb::SBBreakpoint &bp,
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/JSONUtils.h b/lldb/tools/lldb-vscode/JSONUtils.h
index 73cfb425ee2900..45f69965914017 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.h
+++ b/lldb/tools/lldb-vscode/JSONUtils.h
@@ -232,13 +232,21 @@ void AppendBreakpoint(
/// 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<llvm::StringRef> request_path = std::nullopt,
- std::optional<uint32_t> request_line = std::nullopt);
+ std::optional<uint32_t> request_line = std::nullopt,
+ std::optional<uint32_t> 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/SourceBreakpoint.cpp b/lldb/tools/lldb-vscode/SourceBreakpoint.cpp
index 742d6142d32341..7c57bf7d7c4f53 100644
--- a/lldb/tools/lldb-vscode/SourceBreakpoint.cpp
+++ b/lldb/tools/lldb-vscode/SourceBreakpoint.cpp
@@ -16,7 +16,9 @@ SourceBreakpoint::SourceBreakpoint(const llvm::json::Object &obj)
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());
More information about the lldb-commits
mailing list