[Lldb-commits] [PATCH] D156732: Display PC instead of <unknown> for stack trace in vscode

Tom Yang via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 31 12:42:21 PDT 2023


zhyty created this revision.
Herald added a project: All.
zhyty requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

It isn't useful for users to see "<unknown>" as a stack trace when lldb fails to symbolicate a stack frame. I've replaced "<unknown>" with the value of the program counter instead.

Test Plan:

To test this, I opened a target that lldb fails to symbolicate in
VSCode, and observed in the CALL STACK section that instead of being
shown as "<unknown>", those stack frames are represented by their
program counters.

I also ran `lldb-dotest -p TestVSCode` and saw that the tests passed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156732

Files:
  lldb/tools/lldb-vscode/JSONUtils.cpp


Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===================================================================
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -762,8 +762,14 @@
   const char *func_name = frame.GetFunctionName();
   if (func_name)
     frame_name = func_name;
-  else
-    frame_name = "<unknown>";
+  else {
+    // If the function name is unavailable, display the pc address as a 16-digit
+    // hex string.
+    frame_name.clear();
+    llvm::raw_string_ostream os(frame_name);
+    os << llvm::format_hex(frame.GetPC(), 18);
+    os.flush();
+  }
   bool is_optimized = frame.GetFunction().GetIsOptimized();
   if (is_optimized)
     frame_name += " [opt]";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156732.545764.patch
Type: text/x-patch
Size: 717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230731/601e0628/attachment.bin>


More information about the lldb-commits mailing list