This is an archive of the discontinued LLVM Phabricator instance.

Add option eTypeOptionHideEmptyAggregates.
ClosedPublic

Authored by sivachandra on Jul 23 2015, 1:03 PM.

Details

Summary

For certain data structures, when the synthetic child provider returns
zero children, a summary like "Empty instance of <typename>" could be
more appropriate than something like "size=0 {}". This new option helps
hide the trailing "{}".

This is also exposed with a -h option for the command "type summary add".

Diff Detail

Event Timeline

sivachandra retitled this revision from to Add option eTypeOptionHideEmptyAggregates..
sivachandra updated this object.
sivachandra added a subscriber: lldb-commits.

I will add tests if the general direction of this change is OK.

sivachandra updated this object.Jul 23 2015, 2:07 PM

The change itself seems fine, just a couple minor things:

  • I have some ideas on what should happen if synthetic children fail to produce values for whatever reason. This change itself does not conflict with any of that, though, so it's good to go
  • Is there going to be a flag to "type summary add" for setting your new flag, or is this only meant for internal formatters?
  • How do you plan to test it?
  • If anything, maybe replace Print with Expand, to get ShouldExpandEmptyAggregates(). We are indeed printing the aggregate, just not "expanding" it

On Thu, Jul 23, 2015 at 2:17 PM, Enrico Granata <granata.enrico@gmail.com> wrote:

  • Is there going to be a flag to "type summary add" for setting your new flag, or is this only meant for internal formatters?

I have only envisioned using such an option in scripts. If you feel it would be relevant/complete to expose it in the "type summary flags", I will do it as a follow up unless you want me to do it with this change itself.

  • How do you plan to test it?

I am testing my change locally by having a type summary script along with a synthetic children provider script which returns 0 children. I will add the same as a test for this patch.

  • If anything, maybe replace Print with Expand, to get ShouldExpandEmptyAggregates(). We are indeed printing the aggregate, just not "expanding" it

Will do it.

On Thu, Jul 23, 2015 at 2:17 PM, Enrico Granata <granata.enrico@gmail.com> wrote:

  • Is there going to be a flag to "type summary add" for setting your new flag, or is this only meant for internal formatters?

I have only envisioned using such an option in scripts. If you feel it would be relevant/complete to expose it in the "type summary flags", I will do it as a follow up unless you want me to do it with this change itself.

It seems like a generally useful option to have, since we're adding this ability to the summary, to set it at the command line for a formatter you are creating yourself

  • How do you plan to test it?

I am testing my change locally by having a type summary script along with a synthetic children provider script which returns 0 children. I will add the same as a test for this patch.

Of course this mode would work just as well for a type which just happens to have zero children "organically", as in:

struct S {};
S myS;

I don't think there should be anything specific to synthetic children here, even though I see why that's mostly useful there
My general theory would be for synthetic children to be able to fail-safe themselves, as in, recognize that some of their preconditions are not met (imagine an std::list<T> with a NULL base pointer), and then fall back to displaying the actual child values. The issue you run into is that the summary is independent of the synthetic children, so you risk getting a mismatch between what the summary says and the content you see.
For instance, a list might store its count inline, but then have a bogus first-node pointer, so you would get, say, "size =5" and then incorrect children.
I have yet to figure out a sustainable strategy for that, but that's way beyond the scope of this change.

  • If anything, maybe replace Print with Expand, to get ShouldExpandEmptyAggregates(). We are indeed printing the aggregate, just not "expanding" it

Will do it.

clayborg resigned from this revision.Jul 23 2015, 2:52 PM
clayborg removed a reviewer: clayborg.

I am OK if Enrico is ok with this.

sivachandra edited edge metadata.

Expose the new option in the "type summary add" command via a -h option.

Ping. How does this look now?

granata.enrico accepted this revision.Jul 24 2015, 11:36 AM
granata.enrico edited edge metadata.

If the test suite passes, go ahead and commit

This revision is now accepted and ready to land.Jul 24 2015, 11:36 AM
sivachandra updated this object.Jul 24 2015, 2:30 PM
sivachandra edited edge metadata.
sivachandra closed this revision.Jul 24 2015, 2:31 PM