Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

walter-erquinigo
Copy link
Member

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.

…mat 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.
@llvmbot
Copy link
Member

llvmbot commented Dec 8, 2023

@llvm/pr-subscribers-lldb

Author: Walter Erquinigo (walter-erquinigo)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/74861.diff

1 Files Affected:

  • (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+4-2)
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);

Copy link
Member

@bulbazord bulbazord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think conceptually this makes sense, but I somewhat wonder if folks would get confused when they have a custom frame format and don't see the [opt] in there? The current behavior is that [opt] is always there so folks know they don't have to put it in their custom frame format. When it's missing after this change, I wonder if they'll notice.

@jimingham
Copy link
Collaborator

jimingham commented Dec 9, 2023 via email

@clayborg
Copy link
Collaborator

clayborg commented Dec 9, 2023

{${function.is-optimized} [opt]} is how is already is and can be done with frame formats, so I agree with this patch that if the user customizes it, they have complete control and we shouldn't add anything. Does everyone else agree?

@bulbazord
Copy link
Member

{${function.is-optimized} [opt]} is how is already is and can be done with frame formats, so I agree with this patch that if the user customizes it, they have complete control and we shouldn't add anything. Does everyone else agree?

I think I agree with this in principle -- this will give users complete control over the format of their frame, like frame formats were made to do. This change is breaking in the sense that folks who forgot to put is-optimized or is using a frame format they did not create (without is-optimized) will no longer know that they're debugging optimized code. I think this an acceptable trade-off.

@walter-erquinigo walter-erquinigo merged commit 07ed325 into llvm:main Dec 11, 2023
@walter-erquinigo walter-erquinigo deleted the walter/opt branch December 11, 2023 19:46
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this pull request Jan 19, 2024
…mat is not specified. (llvm#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.

(cherry picked from commit 07ed325)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants