mib updated this revision to Diff 233464.
mib added a comment.

Simplifying the test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71237/new/

https://reviews.llvm.org/D71237

Files:
  lldb/docs/use/formatting.rst
  lldb/include/lldb/Core/FormatEntity.h
  lldb/source/Core/FormatEntity.cpp
  lldb/test/Shell/Settings/Inputs/main.cpp
  lldb/test/Shell/Settings/TestFrameFormatMangling.test

Index: lldb/test/Shell/Settings/TestFrameFormatMangling.test
===================================================================
--- /dev/null
+++ lldb/test/Shell/Settings/TestFrameFormatMangling.test
@@ -0,0 +1,12 @@
+# UNSUPPORTED: system-windows
+# RUN: %clangxx_host -g -O0 %S/Inputs/main.cpp -o %t.out
+# RUN: %lldb -b -s %s %t.out | FileCheck %s
+br set -p "Set break"
+run
+frame info
+# CHECK: frame #0: {{.*}}Increment::GetValue(
+set set frame-format "frame #${frame.index}: {${function.mangled-name}}\n"
+frame info
+# CHECK: frame #0: _ZN9Increment8GetValueEv
+c
+q
Index: lldb/test/Shell/Settings/Inputs/main.cpp
===================================================================
--- /dev/null
+++ lldb/test/Shell/Settings/Inputs/main.cpp
@@ -0,0 +1,21 @@
+class Increment {
+public:
+  Increment(int value) { Increment::value += value; }
+
+  const int GetValue();
+
+private:
+  static int value;
+};
+
+int Increment::value = 40;
+
+const int Increment::GetValue() {
+  return value; // Set break point at this line.
+}
+
+int main() {
+  Increment i(2);
+  const int new_val = i.GetValue();
+  return new_val;
+}
Index: lldb/source/Core/FormatEntity.cpp
===================================================================
--- lldb/source/Core/FormatEntity.cpp
+++ lldb/source/Core/FormatEntity.cpp
@@ -125,6 +125,7 @@
     ENTRY("name", FunctionName),
     ENTRY("name-without-args", FunctionNameNoArgs),
     ENTRY("name-with-args", FunctionNameWithArgs),
+    ENTRY("mangled-name", FunctionMangledName),
     ENTRY("addr-offset", FunctionAddrOffset),
     ENTRY("concrete-only-addr-offset-no-padding", FunctionAddrOffsetConcrete),
     ENTRY("line-offset", FunctionLineOffset),
@@ -351,6 +352,7 @@
     ENUM_TO_CSTR(FunctionName);
     ENUM_TO_CSTR(FunctionNameWithArgs);
     ENUM_TO_CSTR(FunctionNameNoArgs);
+    ENUM_TO_CSTR(FunctionMangledName);
     ENUM_TO_CSTR(FunctionAddrOffset);
     ENUM_TO_CSTR(FunctionAddrOffsetConcrete);
     ENUM_TO_CSTR(FunctionLineOffset);
@@ -1745,6 +1747,30 @@
   }
     return false;
 
+  case Entry::Type::FunctionMangledName: {
+    const char *name = nullptr;
+    if (sc->symbol)
+      name = sc->symbol->GetMangled()
+                 .GetName(sc->symbol->GetLanguage(), Mangled::ePreferMangled)
+                 .AsCString();
+    else if (sc->function)
+      name = sc->function->GetMangled()
+                 .GetName(sc->symbol->GetLanguage(), Mangled::ePreferMangled)
+                 .AsCString();
+
+    if (!name)
+      return false;
+    s.PutCString(name);
+
+    if (Block *inline_block = sc->block->GetContainingInlinedBlock()) {
+        if (const InlineFunctionInfo *inline_info = sc->block->GetInlinedFunctionInfo()) {
+          s.PutCString(" [inlined] ");
+          inline_info->GetName(sc->function->GetLanguage()).Dump(&s);
+        }
+    }
+    return true;
+  }
+
   case Entry::Type::FunctionAddrOffset:
     if (addr) {
       if (DumpAddressOffsetFromFunction(s, sc, exe_ctx, *addr, false, false,
Index: lldb/include/lldb/Core/FormatEntity.h
===================================================================
--- lldb/include/lldb/Core/FormatEntity.h
+++ lldb/include/lldb/Core/FormatEntity.h
@@ -85,6 +85,7 @@
       FunctionName,
       FunctionNameWithArgs,
       FunctionNameNoArgs,
+      FunctionMangledName,
       FunctionAddrOffset,
       FunctionAddrOffsetConcrete,
       FunctionLineOffset,
Index: lldb/docs/use/formatting.rst
===================================================================
--- lldb/docs/use/formatting.rst
+++ lldb/docs/use/formatting.rst
@@ -92,6 +92,8 @@
 +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | ``function.name-without-args``                    | The name of the current function without arguments and values (used to include a function name in-line in the ``disassembly-format``)                                                                                                                                                       |
 +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| ``function.mangled-name``                         | The mangled name of the current function or symbol.                                                                                                                                                                                                                                         |
++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | ``function.pc-offset``                            | The program counter offset within the current function or symbol                                                                                                                                                                                                                            |
 +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | ``function.addr-offset``                          | The offset in bytes of the current function, formatted as " + dddd"                                                                                                                                                                                                                         |
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to