one line output for 'print' and 'display'

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

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

Hi Enrico,

Thanks for reply!

So I think I will try to update my lldb.

Thanks,
David

Quoting Enrico Granata (2015-07-10 18:30:44)