[PATCH] D99698: [DWARF] Fix crash for DWARFDie::dump.

Alexander Yermolovich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 31 17:49:44 PDT 2021


ayermolo created this revision.
Herald added subscribers: hoy, wenlei, hiraditya.
ayermolo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When DIE is extracted manually, the DieArray is empty. It tries to extract child, even if Dump opitons say otherwise. Resulting in crash.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99698

Files:
  llvm/lib/DebugInfo/DWARF/DWARFDie.cpp


Index: llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -635,14 +635,14 @@
         for (const DWARFAttribute &AttrValue : attributes())
           dumpAttribute(OS, *this, AttrValue, Indent, DumpOpts);
 
-        DWARFDie child = getFirstChild();
-        if (DumpOpts.ShowChildren && DumpOpts.ChildRecurseDepth > 0 && child) {
+        if (DumpOpts.ShowChildren && DumpOpts.ChildRecurseDepth > 0) {
+          DWARFDie Child = getFirstChild();
           DumpOpts.ChildRecurseDepth--;
           DIDumpOptions ChildDumpOpts = DumpOpts;
           ChildDumpOpts.ShowParents = false;
-          while (child) {
-            child.dump(OS, Indent + 2, ChildDumpOpts);
-            child = child.getSibling();
+          while (Child) {
+            Child.dump(OS, Indent + 2, ChildDumpOpts);
+            Child = Child.getSibling();
           }
         }
       } else {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99698.334570.patch
Type: text/x-patch
Size: 1016 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210401/512bd6f8/attachment.bin>


More information about the llvm-commits mailing list