[Lldb-commits] [lldb] [DRAFT] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels (PR #148877)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 15 09:06:04 PDT 2025


================
@@ -249,6 +250,41 @@ static unsigned GetCXXMethodCVQuals(const DWARFDIE &subprogram,
   return cv_quals;
 }
 
+// TODO:
+// 0. Adjust FindInSymbols
+// 1. log failure paths
+// 2. What happens for functions without a linkage name? Previously we didn't
+// attach a label for those but now we would
+// 3. Unit-test
+// 4. API test (whilch checks expr and AST dump)
+static std::optional<std::string> MakeLLDBFuncAsmLabel(const DWARFDIE &die) {
+  std::optional<std::string> label;
+  char const *mangled = die.GetMangledName(/*substitute_name_allowed=*/false);
+  if (mangled)
+    label.emplace(mangled);
+
+  auto module_sp = die.GetModule();
+  if (!module_sp)
+    return label;
+
+  // Module UID is only a Darwin concept (?)
+  // If UUID is not available encode as pointer.
+  // Maybe add character to signal whether this is a pointer
+  // or UUID. Or maybe if it's not hex that implies a UUID?
+  auto module_id = module_sp->GetUUID();
+  Module * module_ptr = nullptr;
+  if (!module_id.IsValid())
+    module_ptr = module_sp.get();
----------------
Michael137 wrote:

@labath I'm trying to clean up this prototype of your suggestion in my [ABI-tagged structors RFC](https://discourse.llvm.org/t/rfc-lldb-handling-abi-tagged-constructors-destructors-in-expression-evaluator/82816/7).

This function here is what encodes the label.

Something I wasn't sure about though was how we should encode the Module in the string. Since UIDs need not exist (e.g., on Linux IIUC?), was your original suggestion to simply print out the pointer? If so, how would we defend against the module getting unloaded under our feet? I might've misunderstood your idea though.

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


More information about the lldb-commits mailing list