1414#include " lldb/API/SBLineEntry.h"
1515#include " lldb/API/SBMutex.h"
1616#include " llvm/ADT/StringExtras.h"
17- #include " llvm/Support/JSON.h"
1817#include < cstddef>
1918#include < cstdint>
2019#include < mutex>
@@ -30,13 +29,16 @@ void Breakpoint::SetHitCondition() {
3029 m_bp.SetIgnoreCount (hitCount - 1 );
3130}
3231
33- void Breakpoint::CreateJsonObject (llvm::json::Object &object) {
32+ protocol::Breakpoint Breakpoint::ToProtocolBreakpoint () {
33+ protocol::Breakpoint breakpoint;
34+
3435 // Each breakpoint location is treated as a separate breakpoint for VS code.
3536 // They don't have the notion of a single breakpoint with multiple locations.
3637 if (!m_bp.IsValid ())
37- return ;
38- object.try_emplace (" verified" , m_bp.GetNumResolvedLocations () > 0 );
39- object.try_emplace (" id" , m_bp.GetID ());
38+ return breakpoint;
39+
40+ breakpoint.verified = m_bp.GetNumResolvedLocations () > 0 ;
41+ breakpoint.id = m_bp.GetID ();
4042 // VS Code DAP doesn't currently allow one breakpoint to have multiple
4143 // locations so we just report the first one. If we report all locations
4244 // then the IDE starts showing the wrong line numbers and locations for
@@ -60,16 +62,18 @@ void Breakpoint::CreateJsonObject(llvm::json::Object &object) {
6062 if (bp_addr.IsValid ()) {
6163 std::string formatted_addr =
6264 " 0x" + llvm::utohexstr (bp_addr.GetLoadAddress (m_bp.GetTarget ()));
63- object. try_emplace ( " instructionReference" , formatted_addr) ;
65+ breakpoint. instructionReference = formatted_addr;
6466 auto line_entry = bp_addr.GetLineEntry ();
6567 const auto line = line_entry.GetLine ();
6668 if (line != UINT32_MAX)
67- object. try_emplace ( " line" , line) ;
69+ breakpoint. line = line;
6870 const auto column = line_entry.GetColumn ();
6971 if (column != 0 )
70- object. try_emplace ( " column" , column) ;
71- object. try_emplace ( " source" , CreateSource (line_entry) );
72+ breakpoint. column = column;
73+ breakpoint. source = CreateSource (line_entry);
7274 }
75+
76+ return breakpoint;
7377}
7478
7579bool Breakpoint::MatchesName (const char *name) {
0 commit comments