[llvm-bugs] [Bug 39002] New: llvm-dwarfdump parses CUs even when not asked to dump them

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 19 10:18:07 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=39002

            Bug ID: 39002
           Summary: llvm-dwarfdump parses CUs even when not asked to dump
                    them
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: aprantl at apple.com
          Reporter: dblaikie at gmail.com
                CC: llvm-bugs at lists.llvm.org

Looks like offset dumping support added in r313419 caused CUs to be
unconditionally parsed - this seems like a pessimization.

I discovered this when I went to debug something else (dumping only
str_offsets) & broke on the DWARFCompileUnit ctor & found it as being
unconditionally parsed.

Previous to this change, the code looked like:

-  if (shouldDump(Explicit, ".debug_info", DIDT_DebugInfo,
-                 DObj->getInfoSection().Data)) {
-    for (const auto &CU : compile_units())
-      CU->dump(OS, DumpOpts);
-  }

Making the call to "compile_units()" conditional on the "shouldDump" condition.

After the change, the code looks like:

+  auto dumpDebugInfo = [&](bool IsExplicit, const char *Name,
+                           DWARFSection Section, cu_iterator_range CUs) {
+    if (shouldDump(IsExplicit, Name, DIDT_ID_DebugInfo, Section.Data)) {
+      for (const auto &CU : CUs)
+        if (DumpOffset)
+        CU->getDIEForOffset(DumpOffset.getValue()).dump(OS, 0);
+        else
+          CU->dump(OS, DumpOpts);
+    }
+  };
+  dumpDebugInfo(Explicit, ".debug_info", DObj->getInfoSection(),
+                compile_units());

Making the compile_units call unconditional.

Perhaps dumpDebugInfo could take a member function pointer to the accessor
instead of taking the result of calling the accessor? That way allowing the
parsing of units to be deferred until after/conditional on the shouldDump call?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180919/ec1bb3e8/attachment-0001.html>


More information about the llvm-bugs mailing list