[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Sat Nov 11 10:55:28 PST 2023


================
@@ -785,11 +785,18 @@ llvm::json::Value CreateStackFrame(lldb::SBFrame &frame) {
   int64_t frame_id = MakeDAPFrameID(frame);
   object.try_emplace("id", frame_id);
 
-  // `function_name` can be a nullptr, which throws an error when assigned to an
-  // `std::string`.
-  const char *function_name = frame.GetDisplayFunctionName();
-  std::string frame_name =
-      function_name == nullptr ? std::string() : function_name;
+  std::string frame_name;
+  if (g_dap.frame_format.IsValid()) {
+    lldb::SBStream stream;
+    frame.GetDescriptionWithFormat(g_dap.frame_format, stream, "No value");
----------------
clayborg wrote:

Doesn't make sense to show "No value" here, that will confuse users. we should listen to this return value and allow the standard code below to run `frame.GetDisplayFunctionName()`.

```
std::string frame_name;
lldb::SBStream stream;
if (g_dap.frame_format.IsValid() && frame.GetDescriptionWithFormat(g_dap.frame_format, stream)) 
  frame_name = stream.GetData();
else if (const char *name = frame.GetDisplayFunctionName())
  frame_name = name;

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


More information about the lldb-commits mailing list