[lldb-dev] one line output for 'print' and 'display'

Enrico Granata egranata at apple.com
Fri Jul 10 09:30:44 PDT 2015


Hi David,
by default the decision of what types do and do not get “one line” printing is hardcoded in FormatManager::ShouldPrintAsOneLiner

The only setting that users can tweak with regard to that is
(lldb) settings show auto-one-line-summaries
auto-one-line-summaries (boolean) = true

which acts as a global kill-switch for the feature (true means “allow”)

A quick fix for your problem is to manually add a summary for all int arrays, thusly:
(lldb) type summary add -x "int \[[0-9]+]" -c

That is saying, for all types whose names match the regular expression int [ followed by one ore more digits followed by a ], then force one-line formatting

With that, I get
(lldb) fr var x
(int [10]) x = ([0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5, [6] = 6, [7] = 7, [8] = 8, [9] = 9)
(lldb) expr x
(int [10]) $2 = ([0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5, [6] = 6, [7] = 7, [8] = 8, [9] = 9)

With all of that said, I think lldb-300 is a fairly old series. And indeed, on a recent LLDB I automatically get the kind of output you would like to see:
(lldb) expr x
(int [10]) $0 = ([0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5, [6] = 6, [7] = 7, [8] = 8, [9] = 9)

even without applying any custom formatting

> On Jul 9, 2015, at 11:39 PM, David Froger <david.froger.ml at mailoo.org> wrote:
> 
> Hello,
> 
> With my LLDB version lldb-300.2.53, printing a array is formatted like this:
> 
>    (int [10]) $0 = {
>      [0] = 0
>      [1] = 1
>      [2] = 2
>      [3] = 3
>      [4] = 4
>      [5] = 5
>      [6] = 6
>      [7] = 7
>      [8] = 8
>      [9] = 9
>    }
> 
> But I would link a compact printing on one line, like with GDB:
> 
>    $1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
> 
> Where I can change this formatting setting?
> 
> I have the same question for the 'display' command.
> 
> I already asked the question on stackoverflow:
>    http://stackoverflow.com/q/31328204/744629
> 
> Thanks for reading!
> 
> Best regards,
> David
> 
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev


Thanks,
- Enrico
📩 egranata@.com ☎️ 27683

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20150710/509b11da/attachment.html>


More information about the lldb-dev mailing list