Bug 10659 - pretty-printing: Display vectors of vectors as matrix
Summary: pretty-printing: Display vectors of vectors as matrix
Status: ASSIGNED
Alias: None
Product: gdb
Classification: Unclassified
Component: python (show other bugs)
Version: archer
: P2 enhancement
Target Milestone: 6.8
Assignee: Chris Moller
URL:
Keywords:
Depends on: 30816
Blocks:
  Show dependency treegraph
 
Reported: 2009-09-18 17:18 UTC by Jan Kratochvil
Modified: 2023-08-31 20:01 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2009-09-18 17:18:58 UTC
Vector of vectors is currently displayed as:
(gdb) p test
$1 = std::vector of length 2, capacity 2 = {std::vector of length 2, capacity 2
= {0, 1}, std::vector of length 2, capacity 2 = {2, 3}}

while user suggested something like:
(gdb) p test
$1 = std::vector of length 2, capacity 2 = {std::vector of length 2, capacity 2
= {0, 1}, std::vector of length 2, capacity 2 = {2, 3}}
matrix contents = 
0 2
1 3

Testcase:
#include <vector>
#include <iostream>

int main(){
  std::vector< std::vector<int> > test(2, std::vector<int>(2,0));
  test[0][0]=0;
  test[0][1]=1;
  test[1][0]=2;
  test[1][1]=3;

  int a=test[1][0];
  std::cout << a;
}
Comment 1 Tom Tromey 2023-08-31 16:59:48 UTC
One way might be a new 'display_hint' that is some kind
of structured value, e.g. a tuple like ("matrix", 20, 10)