[PATCH] D132900: [DWARF] Fix infinite recursion in Type Printer.

Alexander Yermolovich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 26 12:01:12 PDT 2022


ayermolo added a comment.

In D132900#3812611 <https://reviews.llvm.org/D132900#3812611>, @dblaikie wrote:

> So, I'm not sure what failures you're seeing, but I tried this locally:
>
>   $ git diff
>   diff --git a/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp b/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
>   index 2d8add64537c..969a6525d821 100644
>   --- a/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
>   +++ b/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
>   @@ -284,12 +284,32 @@ void DWARFTypePrinter::appendUnqualifiedNameAfter(
>    
>    void DWARFTypePrinter::appendQualifiedName(DWARFDie D) {
>      if (D)
>   -    appendScopes(D.getParent());
>   +    switch (D.getTag()) {
>   +    case dwarf::DW_TAG_structure_type:
>   +    case dwarf::DW_TAG_class_type:
>   +    case dwarf::DW_TAG_union_type:
>   +    case dwarf::DW_TAG_namespace:
>   +    case dwarf::DW_TAG_enumeration_type:
>   +      appendScopes(D.getParent());
>   +      break;
>   +    default:
>   +      break;
>   +    }
>      appendUnqualifiedName(D);
>    }
>    DWARFDie DWARFTypePrinter::appendQualifiedNameBefore(DWARFDie D) {
>      if (D)
>   -    appendScopes(D.getParent());
>   +    switch (D.getTag()) {
>   +    case dwarf::DW_TAG_structure_type:
>   +    case dwarf::DW_TAG_class_type:
>   +    case dwarf::DW_TAG_union_type:
>   +    case dwarf::DW_TAG_namespace:
>   +    case dwarf::DW_TAG_enumeration_type:
>   +      appendScopes(D.getParent());
>   +      break;
>   +    default:
>   +      break;
>   +    }
>      return appendUnqualifiedNameBefore(D);
>    }
>    bool DWARFTypePrinter::appendTemplateParameters(DWARFDie D,
>   @@ -516,7 +536,7 @@ void DWARFTypePrinter::appendSubroutineNameAfter(
>      for (DWARFDie P : D) {
>        if (P.getTag() != DW_TAG_formal_parameter &&
>            P.getTag() != DW_TAG_unspecified_parameters)
>   -      return;
>   +      continue;
>        DWARFDie T = resolveReferencedType(P);
>        if (SkipFirstParamIfArtificial && RealFirst && P.find(DW_AT_artificial)) {
>          FirstParamIfArtificial = T;
>
> and I tried the initial test case and the follow-up one and they seem to work correctly without assertions/crashes/infinite recursion for me.
>
> Can you help me understand what you're hitting up against?
>
> (this ^ patch isn't quite ready - would be good to refactor out the two switches into a single switch to avoid code duplication & possibly adding extra test coverage for that `return` -> `continue` change that lets the function type be fully printed despite non-parameter DIEs in the subroutine type)

Sorry was on PTO. 
Ah, so I only had the check in appendQualifiedName. I might have miss understood your original comment. Thanks for pointing this out!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132900



More information about the llvm-commits mailing list