[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)
John Harrison via lldb-commits
lldb-commits at lists.llvm.org
Fri May 30 13:43:12 PDT 2025
================
@@ -0,0 +1,115 @@
+//===-- ProtocolUtils.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 "Protocol/ProtocolUtils.h"
+#include "LLDBUtils.h"
+
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBTarget.h"
+
+namespace lldb_dap::protocol {
+
+static bool ShouldDisplayAssemblySource(
+ lldb::SBAddress address,
+ lldb::StopDisassemblyType stop_disassembly_display) {
+ if (stop_disassembly_display == lldb::eStopDisassemblyTypeNever)
+ return false;
+
+ if (stop_disassembly_display == lldb::eStopDisassemblyTypeAlways)
+ return true;
+
+ // A line entry of 0 indicates the line is compiler generated i.e. no source
+ // file is associated with the frame.
+ auto line_entry = address.GetLineEntry();
+ auto file_spec = line_entry.GetFileSpec();
+ if (!file_spec.IsValid() || line_entry.GetLine() == 0 ||
+ line_entry.GetLine() == LLDB_INVALID_LINE_NUMBER)
+ return true;
+
+ if (stop_disassembly_display == lldb::eStopDisassemblyTypeNoSource &&
+ !file_spec.Exists()) {
+ return true;
+ }
+
+ return false;
+}
+
+static protocol::Source CreateAssemblySource(const lldb::SBTarget &target,
+ lldb::SBAddress address) {
----------------
ashgti wrote:
Nit, can this be a `const &` as well?
https://github.com/llvm/llvm-project/pull/141426
More information about the lldb-commits
mailing list