[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 26 15:59:45 PDT 2025


================
@@ -0,0 +1,165 @@
+//===-- 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 <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();
+  lldb::SBBroadcaster broadcaster = dap.target.GetBroadcaster();
+  constexpr auto event_mask = lldb::SBTarget::eBroadcastBitBreakpointChanged;
+  listener.StopListeningForEvents(broadcaster, event_mask);
----------------
clayborg wrote:

This will work for code in the current source file when the source file itself matchs the name of a compile unit, but it won't work for inline functions. The line table above could easily contain entryes for "/.../stl/vector:123" where this is the `vector` header file from the STL. There will be no top level compile unit for this. 

So we really should add the new API so that it can use the same source file searching code that the breakpoints use.

It is easy to add things to the public API by following the API rules and making sure people agree on the signature and function location. Typically for things that want to search for things in a `lldb::SBModule`, we can add a `lldb::SBModule` API, but we might also want to add an API at the `lldb::SBTarget` so that it can search all modules so we might want the following APIs:

```
/// Find all locations for a file and line in this lldb::SBModule
lldb::SBSymbolContextList lldb::SBModule::ResolveContexts(lldb::SBFileSpec &file_spec, uint32_t line);
/// Find all locations for a file and line in all lldb::SBModule in the lldb::SBTarget
lldb::SBSymbolContextList lldb::SBTarget::ResolveContexts(lldb::SBFileSpec &file_spec, uint32_t line);
```


https://github.com/llvm/llvm-project/pull/130503


More information about the lldb-commits mailing list