[PATCH v2][PR gdb/17320] Fix array pretty formatter

Simon Marchi simark@simark.ca
Tue Apr 28 15:17:26 GMT 2020


On 2020-04-27 8:59 a.m., Hannes Domani via Gdb-patches wrote:
> Currently, printing with array pretty formatting makes the output actually
> less readable than without:
> 
> (gdb) p -array on -- {{1,2,3},{4,5,6}}
> $1 =   {    {1,
>     2,
>     3},
>       {4,
>     5,
>     6}}
> (gdb) p -array on -array-indexes on -- {{1,2,3},{4,5,6}}
> $2 =   {[0] =     {[0] = 1,
>     [1] = 2,
>     [2] = 3},
>   [1] =     {[0] = 4,
>     [1] = 5,
>     [2] = 6}}
> 
> These changes now also put the first element and the array end bracket on a new
> line, similar to the structure pretty formatter:
> 
> (gdb) p -array on -- {{1,2,3},{4,5,6}}
> $1 = {
>   {
>     1,
>     2,
>     3
>   },
>   {
>     4,
>     5,
>     6
>   }
> }
> (gdb) p -array on -array-indexes on -- {{1,2,3},{4,5,6}}
> $2 = {
>   [0] = {
>     [0] = 1,
>     [1] = 2,
>     [2] = 3
>   },
>   [1] = {
>     [0] = 4,
>     [1] = 5,
>     [2] = 6
>   }
> }

Thanks for providing a test case, this is ok.

Simon



More information about the Gdb-patches mailing list