Add support for the --gdb-format/-G flag to dwim-print.
The gdb-format flag enables better compatibility with p and v, because it
allows /x and the other gdb-format specifiers.
Paths
| Differential D141425
[lldb] Add --gdb-format flag to dwim-print ClosedPublic Authored by kastiglione on Jan 10 2023, 1:19 PM.
Details Summary Add support for the --gdb-format/-G flag to dwim-print. The gdb-format flag enables better compatibility with p and v, because it
Diff Detail
Event TimelineComment Actions I don't think this is quite right. First off, it's a little weird that your dwim-print command only supports the gdb-format option and not the format option? In the long run, I think you need to support both. Being able to say v -fA variable but not dwim-print -fA would be wrong. But given this is early days, that can be a separate patch. More importantly, your translation is lossy. The gdb format option supports count & size as well as format: e.g. -G 32xb. But the current code will turn that into -G x for the underlying command. So you either need to reconstitute the gdb-format string from the m_count and m_byte_size as well as m_format, or get the OptionGroupFormat to store the unparsed gdb format string and just hand that back to you. This revision now requires changes to proceed.Jan 10 2023, 7:05 PM
Comment Actions @jingham The brief answer is that decisions have been based on compatibility with the behavior of p.
Taking the example of dwim-print -fA variable, if the user were to do the same but with an expression, they'd have to write dwim-print -fA -- expression. Will there be users who know and want the printing options you mentioned (synthetic/raw, depth, etc) but who try to use those with dwim-print instead of directly using v or e? My expectation has been that dwim-print would (1) generally not be used directly, but be via an alias (either p or another choice) and that (2) for compatibility, the alias would be dwim-print --. Thoughts? Comment Actions
So I was expecting at first we'd add a dp or something alias, that was dwim-print -- and in the fullness of time we would switch to it as the "first choice expression printer" by replacing the p -> expr -- alias with p->dwim-print --, thus getting the same convenience AND configurability we got with expr... This revision is now accepted and ready to land.Feb 8 2023, 6:17 PM Closed by commit rGd160873c03ae: [lldb] Add --gdb-format flag to dwim-print (authored by kastiglione). · Explain WhyFeb 8 2023, 7:16 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 494401 lldb/include/lldb/Interpreter/OptionGroupFormat.h
lldb/source/Commands/CommandObjectDWIMPrint.h
lldb/source/Commands/CommandObjectDWIMPrint.cpplldb/source/Interpreter/OptionGroupFormat.cpp
lldb/test/API/commands/dwim-print/TestDWIMPrint.py
|
Is this your long term plan? Even in a dwim print command, I will want to control the depth of structure/pointer traversal, and whether I see the raw or synthetic child version of the result, etc.