[Lldb-commits] [lldb] [lldb-dap] Include [opt] in the frame name only if a custom frame format is not specified. (PR #74861)

Walter Erquinigo via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 8 08:33:10 PST 2023


https://github.com/walter-erquinigo created https://github.com/llvm/llvm-project/pull/74861

Currently there's an include in which `[opt]` might be emitted twice if the frame format also asks for it. As a trivial fix, we should manually emit `[opt]` only if a custom frame format is not specified.


>From 349cd0694eccdaa4e403cfc6ba9389ed61b1d232 Mon Sep 17 00:00:00 2001
From: walter erquinigo <walter at modular.com>
Date: Wed, 29 Nov 2023 13:46:54 -0500
Subject: [PATCH] [lldb-dap] Include [opt] in the frame name only if a custom
 frame format is not specified.

Currently there's an include in which `[opt]` might be emitted twice if the frame format also asks for it. As a trivial fix, we should manually emit `[opt]` only if a custom frame format is not specified.
---
 lldb/tools/lldb-dap/JSONUtils.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp
index 03a43f9da87f24..e55a69ecd0e9f2 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -803,9 +803,11 @@ llvm::json::Value CreateStackFrame(lldb::SBFrame &frame) {
     llvm::raw_string_ostream os(frame_name);
     os << llvm::format_hex(frame.GetPC(), 18);
   }
-  bool is_optimized = frame.GetFunction().GetIsOptimized();
-  if (is_optimized)
+
+  // We only include `[opt]` if a custom frame format is not specified.
+  if (!g_dap.frame_format && frame.GetFunction().GetIsOptimized())
     frame_name += " [opt]";
+
   EmplaceSafeString(object, "name", frame_name);
 
   auto source = CreateSource(frame);



More information about the lldb-commits mailing list