Page MenuHomePhabricator

Fix "help format" output
AcceptedPublic

Authored by jessicah on Jul 17 2017, 6:27 PM.

Details

Summary

Fix "help" command output format.
It should keep output to the same line until TerminalWidth is reached.

Diff Detail

Event Timeline

jessicah created this revision.Jul 17 2017, 6:27 PM

Todd, Zachary,

Can you help review this change?

Thanks,
Jessica

Add Jim and Greg per Zachary's suggestion.

Jessica

jingham edited edge metadata.Jul 20 2017, 1:22 PM

Yes, your version clearly has the test right. I was wondering why this didn't have a more dramatic ill-effect, but it turns out that this function is only used for printing argument help text, which it clearly messes up:

(lldb) help format
<format>
            --
            One
            of
            the
            format
            names
            (or
            one-character
            names)

I'm not sure why we need a separate function for printing argument output that does wrapping differently from command help, but that's a question for another day.

It doesn't look like there are any tests for this help output. But it should be possible to write a test for this. You can get what you need programmatically, e.g.:

>>> result = lldb.SBCommandReturnObject()
>>> lldb.debugger.GetCommandInterpreter().HandleCommand("help format", result)
1
>>> print result.GetOutput()
<format> -- One of the format names (or one-character names) that can be used to show a variable's value:
            "default"
            'B' or "boolean"
            'b' or "binary"
            'y' or "bytes"
            'Y' or "bytes with ASCII"

And you can get & set the terminal width of the debugger with the SBDebugger.{Get,Set}TerminalWidth, so you could make sure that the length of line 1 + length of first word on line 2 > terminal width. The only tricky bit would be picking the right command to use.

This is such an obvious fix it seems unkind to stall it for a test, but OTOH, if you could whip one up that would be great!

BTW, the second listing was after applying your patch, showing it clearly does the right thing...

clayborg edited edge metadata.Jul 20 2017, 1:30 PM

Add a test for this and this will be good to go.

jessicah updated this revision to Diff 107623.Jul 20 2017, 6:29 PM

A test case was added.

clayborg accepted this revision.Jul 21 2017, 9:03 AM
This revision is now accepted and ready to land.Jul 21 2017, 9:03 AM