Lots of users use "po" as their default print command. If the type
doesn't implement the description function the output is often not what
the user wants. Print a hint telling the user that they might prefer
using "p" instead.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
@kastiglione I wonder if we should hint in all 3 command objects (expr, frame var and DWIM) or if we should limit this to DWIM instead (since DWIM is the one aliased to p and po and I don't think vo or expr -O are often used unintentionally).
lldb/source/Commands/CommandObjectDWIMPrint.cpp | ||
---|---|---|
81–83 | I wonder if there are users who might ignore this, and then find it annoying to see it repeatedly. Should it be a once per session warning? Once per class? Or controlled by a setting. | |
157–166 | I know it would be less "DRY", but it also feels weird to me to pass in a bool that controls whether the function does anything. At the callsite, I think the semantics would be more clear as: if (is_po) MaybeAddPoHintAndDump(*valobj_sp.get(), dump_options, language, result.GetOutputStream()); | |
186–196 | ||
lldb/source/Commands/CommandObjectDWIMPrint.h | ||
46–51 ↗ | (On Diff #533449) | Should this hint be part of dwim-print only? At this point I see expression as a command you use to do exactly what you ask it to do. |
lldb/source/Commands/CommandObjectFrame.cpp | ||
708 ↗ | (On Diff #533449) | Why is this line added? If this getter has side effects, we should create an appropriately named function that performs the side effects. |
I wonder if we should hint in all 3 command objects (expr, frame var and DWIM) or if we should limit this to DWIM instead (since DWIM is the one aliased to p and po and I don't think vo or expr -O are often used unintentionally).
I missed this comment. My instinct is to have only dwim-print produce the hint. It feels more in scope for it.
lldb/source/Commands/CommandObjectDWIMPrint.h | ||
---|---|---|
46–51 ↗ | (On Diff #533449) | I see you asked this same question, and I had missed it at first. |
lldb/include/lldb/Target/Target.h | ||
---|---|---|
496 | did you mean to use this, or should it be deleted? | |
lldb/source/Commands/CommandObjectDWIMPrint.cpp | ||
129–130 | question: would people want to be warned once per target, or once per type? If I do like the warning, I might want to know every time I po a type that doesn't support it. | |
158–162 | what do you think of passing in the result's stream into maybe_add_hint? Perhaps I am overlooking something, but I wonder if it would simplify the code to reuse the one stream, instead of separating and then combining two streams. |
lldb/include/lldb/Target/Target.h | ||
---|---|---|
496 | Leftover from a different implementation, I'll delete it. | |
lldb/source/Commands/CommandObjectDWIMPrint.cpp | ||
129–130 | In my opinion once per target should be enough, if we do it for every type that could potentially be too noisy, and hopefully after seeing the hint a few times users will start remembering to try p too. | |
158–162 | I need the two streams to print it in the correct order (hint first, result later) |
lldb/source/Commands/CommandObjectDWIMPrint.cpp | ||
---|---|---|
133–135 | ok, I have a new suggestion. Since lldb will warn only once per target, and not per type, I think this note should be reworded to focus the guidance on the format of the output, not the type. My concern is lldb emits basically "this type doesn't need a po", but then the diagnostic is printed for only one type, and never tells you about other types. How will people know that other types should use p not po? If the message were on the format, and not the type, then I think it makes more sense as a once per target message. A possible rewording:
| |
158–162 | do we have a precedent for before vs after? Maybe I need to see some examples, but I think it should be after. My logic is "here's the output you requested, and then here's a note about it". Also the note would be next to the next prompt, so maybe closer to the eyes? Just figured it was worth hashing out. |
lldb/source/Commands/CommandObjectDWIMPrint.cpp | ||
---|---|---|
133–135 | Personally I find the new message a bit more confusing for users to understand. Maybe: note: object description requested, but type doesn't implement a custom object description. Consider using "p" instead of "po" (this warning will only be displayed once per debug session). What do you think? | |
158–162 | DWIM print will add the note beforehand, I don't have strong feelings about this either way though. We'd probably still need 2 streams though, since we only want to match what's added by the value object's Dump, and nothing that may already be on the stream. |
did you mean to use this, or should it be deleted?