================ @@ -0,0 +1,91 @@ +//===-- GoToTargetsRequestHandler.cpp -------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "DAP.h" + +#include "JSONUtils.h" +#include "Protocol/ProtocolRequests.h" +#include "RequestHandler.h" + +#include <lldb/API/SBBreakpointLocation.h> +#include <lldb/API/SBListener.h> +#include <lldb/API/SBStream.h> + +namespace lldb_dap { + +static llvm::SmallVector<lldb::SBLineEntry> +GetLineValidEntry(DAP &dap, const lldb::SBFileSpec &file_spec, uint32_t line) { + // Disable breakpoint listeners so they do not send events to the DAP client. + lldb::SBListener listener = dap.debugger.GetListener(); + const lldb::SBBroadcaster broadcaster = dap.target.GetBroadcaster(); + constexpr auto event_mask = lldb::SBTarget::eBroadcastBitBreakpointChanged; + listener.StopListeningForEvents(broadcaster, event_mask); + + // Create a breakpoint to resolve the line if it is on an empty line. + lldb::SBBreakpoint goto_bp = + dap.target.BreakpointCreateByLocation(file_spec, line); + if (!goto_bp.IsValid()) + return {}; + + llvm::SmallVector<lldb::SBLineEntry> entry_locations{}; + const size_t resolved_count = goto_bp.GetNumResolvedLocations(); + for (size_t idx = 0; idx < resolved_count; ++idx) { + lldb::SBBreakpointLocation location = goto_bp.GetLocationAtIndex(idx); + if (!location.IsValid()) + continue; + + lldb::SBAddress addr = location.GetAddress(); + if (!addr.IsValid()) + continue; + + lldb::SBLineEntry line_entry = addr.GetLineEntry(); + if (!line_entry.IsValid()) + continue; + + entry_locations.push_back(line_entry); + } + + // clean up; + dap.target.BreakpointDelete(goto_bp.GetID()); + listener.StartListeningForEvents(broadcaster, event_mask); ---------------- da-viper wrote:
Since the breakpoint is not valid it would not create a valid breakpoint that can be deleted https://github.com/llvm/llvm-project/pull/130503 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits