[lldb-dev] Patch for ValueObjectPrinter::PrintChildrenIfNeeded

Ted Woodward via lldb-dev lldb-dev at lists.llvm.org
Wed Mar 6 14:45:06 PST 2019


Hi Nat!,

The best way to do this is to go to http://reviews.llvm.org .
Under Differential, click Create Diff, then paste in the raw diff for your patch.
We like to see a full context diff, so reviewers can easily see the full file.

More info on how to submit a patch here: http://llvm.org/docs/Contributing.html

Ted

> -----Original Message-----
> From: lldb-dev <lldb-dev-bounces at lists.llvm.org> On Behalf Of Nat! via lldb-
> dev
> Sent: Wednesday, March 6, 2019 8:47 AM
> To: lldb-dev at lists.llvm.org
> Subject: [EXT] [lldb-dev] Patch for ValueObjectPrinter::PrintChildrenIfNeeded
> 
> I couldn't figure out how to post a patch to reviews.llvm.org, so here it is per
> email, with the hope that someone adopts it :)
> 
> Basically it's just moving the `bool print_oneline` out of the execution path, if
> no children are
> 
> printed, since this value is then never used. This may not seem like a big deal,
> but solves a big
> 
> problem in my debugger :)
> 
> 
> 
> ```
> 
> void ValueObjectPrinter::PrintChildrenIfNeeded(bool value_printed,
>                                                 bool summary_printed) {
>    // this flag controls whether we tried to display a description for this
>    // object and failed if that happens, we want to display the children, if any
>    bool is_failed_description =
>        !PrintObjectDescriptionIfNeeded(value_printed, summary_printed);
> 
>    auto curr_ptr_depth = m_ptr_depth;
>    bool print_children =
>        ShouldPrintChildren(is_failed_description, curr_ptr_depth);
> 
>    //
>    // DataVisualization::ShouldPrintAsOneLiner is often called for
>    // print_oneline (see below) and it is very expensive, so use an
>    // early exit, if we are not printing children (also easier to read)
>    //
>    if (!print_children) {
>      if (m_curr_depth >= m_options.m_max_depth && IsAggregate() &&
>                 ShouldPrintValueObject()) {
>        m_stream->PutCString("{...}\n");
>      } else
>        m_stream->EOL();
>      return;
>    }
> 
>    //
>    // TODO: maybe move the bool print_oneline line to #1#, but its unclear to
>    // me if DataVisualization::ShouldPrintAsOneLiner can modify *m_valobj or
> not
>    //
>    bool print_oneline =
>        (curr_ptr_depth.CanAllowExpansion() || m_options.m_show_types ||
>         !m_options.m_allow_oneliner_mode || m_options.m_flat_output ||
>         (m_options.m_pointer_as_array) || m_options.m_show_location)
>            ? false
>            : DataVisualization::ShouldPrintAsOneLiner(*m_valobj);
> 
>    bool is_instance_ptr = IsInstancePointer();
>    uint64_t instance_ptr_value = LLDB_INVALID_ADDRESS;
> 
>    if (is_instance_ptr) {
>      instance_ptr_value = m_valobj->GetValueAsUnsigned(0);
>      if (m_printed_instance_pointers->count(instance_ptr_value)) {
>        // we already printed this instance-is-pointer thing, so don't expand it
>        m_stream->PutCString(" {...}\n");
> 
>        // we're done here - get out fast
>        return;
>      } else
>        m_printed_instance_pointers->emplace(
>            instance_ptr_value); // remember this guy for future reference
>    }
> 
>    // #1#
>    if (print_oneline) {
>      m_stream->PutChar(' ');
>      PrintChildrenOneLiner(false);
>      m_stream->EOL();
>    } else
>      PrintChildren(value_printed, summary_printed, curr_ptr_depth); }
> 
> ```
> 
> 
> Ciao
> 
>     Nat!
> 
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev


More information about the lldb-dev mailing list