[Lldb-commits] [PATCH] Fix showing children of synthetic providers for void*

Bruce Mitchener bruce.mitchener at gmail.com
Sun Jun 22 17:20:36 PDT 2014


Or is the concern here that the curr_ptr_depth isn't getting incremented
yet we go and show children for it?

If so, why have the check for is_ref in this:

else if (is_ref && m_curr_depth == 0 && curr_ptr_depth == 0)
{
    curr_ptr_depth = 1;
}

My issue would probably be fixed by removing the check for is_ref there as
well.

 - Bruce



On Mon, Jun 23, 2014 at 7:10 AM, Bruce Mitchener <bruce.mitchener at gmail.com>
wrote:

> On Sun, Jun 22, 2014 at 11:29 PM, Enrico Granata <egranata at apple.com>
> wrote:
>
>> Bruce,
>> your patch seems to essentially implement the algorithm "display children
>> of pointer types if within the pointer depth OR there is a formatter that
>> wants them shown"
>>
>> That's somewhat worrisome. The reason for having a pointer depth is that
>> pointers potentially introduce recursion - i.e. you can have a pointer that
>> points to itself. Limiting how deep you look into pointer values has the
>> benefit that lldb will not hang in such situations trying to display an i
>> infinitely recursive structure - which is especially useful if the infinite
>> recursion was accidental and unexpected.
>>
>
> That isn't the case with my patch as I understand things.
>
> Looking at the code, but stripped of comments:
>
> bool
> ValueObjectPrinter::ShouldPrintChildren (bool is_failed_description,
>                                          uint32_t& curr_ptr_depth)
> {
>     const bool is_ref = IsRef ();
>     const bool is_ptr = IsPtr ();
>
>     if (is_failed_description || m_curr_depth < options.m_max_depth)
>     {
>         bool print_children = false;
>         if (is_ptr || is_ref)
>         {
>             AddressType ptr_address_type;
>             if (m_valobj->GetPointerValue (&ptr_address_type) == 0)
>                 return false;
>
>             else if (is_ref && m_curr_depth == 0 && curr_ptr_depth == 0)
>             {
>                 curr_ptr_depth = 1;
>             }
>
>             print_children = (curr_ptr_depth > 0);
>         }
>
>         TypeSummaryImpl* entry = GetSummaryFormatter();
>
>         return (print_children || !entry ||
> entry->DoesPrintChildren(m_valobj) || m_summary.empty());
>     }
>     return false;
> }
>
> You can see that my change is squarely within the depth check, so it won't
> allow infinite recursion.  If m_curr_depth >= options.m_max_depth, it will
> still return false.
>
> The only situation where my patch actually changes things with regards to
> pointer depth is that now, a pointer at depth 0 will result in checking the
> summary formatter.
>
>  - Bruce
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20140623/98e46e72/attachment.html>


More information about the lldb-commits mailing list