This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add expression command options in dwim-print
ClosedPublic

Authored by kastiglione on Feb 15 2023, 9:31 AM.

Details

Summary

Adopt expression's options in dwim-print.

This is primarily added to support the --language/-l flag.

Diff Detail

Event Timeline

kastiglione created this revision.Feb 15 2023, 9:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2023, 9:31 AM
kastiglione requested review of this revision.Feb 15 2023, 9:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2023, 9:31 AM

Some expression flags force the use of expression evaluation.

Use expression's "description verbosity"

aprantl accepted this revision.Feb 15 2023, 4:00 PM

Conceptually, I think this looks good to me.

lldb/source/Commands/CommandObjectDWIMPrint.cpp
77

Maybe comment here that these are the only options that only make sense in the expression evaluator?

lldb/test/API/commands/dwim-print/TestDWIMPrint.py
119

why is this needed?

This revision is now accepted and ready to land.Feb 15 2023, 4:00 PM

Use only a subset of expression flags.

Specifically, don't expose --debug/-g or --top-level/-p. These, unlike
the other expression flags, the semantics of these flags would seem to force
expression evaluation. In which case, user should use expression directly.

kastiglione added inline comments.Feb 16 2023, 9:45 AM
lldb/source/Commands/CommandObjectDWIMPrint.cpp
77

As we discussed offline, instead of having flags that force expression evaluation, those flags are no longer exposed. If users need to force expression evaluation, they can use the expression command directly.

lldb/test/API/commands/dwim-print/TestDWIMPrint.py
119

the test this comment referred to has since been deleted, on account of no longer having flags that force expression evaluation.

aprantl accepted this revision.Feb 16 2023, 1:51 PM

Yeah, this is better.

jingham requested changes to this revision.Feb 16 2023, 3:10 PM
jingham added inline comments.
lldb/source/Commands/CommandObjectDWIMPrint.cpp
118

There's a version of Append that lets you exclude and remap option sets. This seems like a finer-grained version of the same thing where you just want to exclude particular options by name but not mess with the option sets. That seems a generally useful thing to do, so it would be better to make another flavor of Append that takes an array of short character options and just excludes them, than do it as a one-off here.

lldb/source/Commands/CommandObjectExpression.h
38

Maybe this should instead take an OptionGroupValueObjectDisplay& instead? I think it's clearer to say "some of the EvaluateExpressionOptions are governed by how you want to display the result ValueObject you're going to produce" than "I'm passing a couple separate ValueObjectDisplay options under the table." Plus, that way if you end up needing another display option you won't have to keep adding parameters to this.

This revision now requires changes to proceed.Feb 16 2023, 3:10 PM

Add and adopt new variation of OptionGroupOptions::Append
Pass OptionGroupValueObjectDisplay to GetEvalateExpressionOptions

  • Fix bug in new OptionGroupOptions::Append
  • Fix typo in GetEvaluateExpressionOptions
jingham accepted this revision.Feb 17 2023, 10:57 AM

LGTM

lldb/source/Commands/CommandObjectDWIMPrint.cpp
118

That would also make this code easier to read, since the exclusion would happen where you added it rather than way down below.

This revision is now accepted and ready to land.Feb 17 2023, 10:57 AM
kastiglione added inline comments.Feb 17 2023, 11:06 AM
lldb/source/Commands/CommandObjectDWIMPrint.cpp
118

This approach is much better. I appreciate the helpful review!

This revision was automatically updated to reflect the committed changes.