Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* gdb printing of dynamically allocated matrix
@ 2007-07-18 17:59 Peter Toft
  2007-07-18 19:32 ` Daniel Jacobowitz
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Toft @ 2007-07-18 17:59 UTC (permalink / raw)
  To: gdb

Focus of this mail is GDB on 1D and 2D arrays.

I have pasted a small C-code program at
http://pastebin.com/f63009dd8
(download from http://pastebin.com/pastebin.php?dl=f63009dd8)
which I like your opinion on.

I compile it with "gcc -g"
Throw a breakpoint on line 59 and run under gdb.

* I can see the contents of the "a"-vector in by
  (gdb) print *a @ 3
  Very cool!

* I can see the matrix (2D array) contents of the "c"
  matrix by
  (gdb) print c
  Elegant - very cool!

* However how can I use GDB to see the contents of "b"
  similar to the contents of "c" and "a"?
  The best I can do is
  (gdb) print *b[0] @3
  (gdb) print *b[1] @3
  Obviously I would like to do the display in one command rather
  than several, especially if I changed the b-matrix to be b[7][8]
  I think I will manually have to supply the length of the vectors,
  but it seems that I cannot do a compound GDB-operation like
  (gdb) print **b @3 @2
  and get
  {{2, -2, 22},{12 -12 -12}}
  instead I get
  {{2, -2, 22},{17# 12# -12}}
  where I have inserted #-marks where I find wrong values.
  How come that the next vector contains wrong values?
  Or rather - how can I see the b content in one command?

Best


-- 
Peter Toft <pto@linuxbog.dk>


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-07-23 19:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-18 17:59 gdb printing of dynamically allocated matrix Peter Toft
2007-07-18 19:32 ` Daniel Jacobowitz
2007-07-18 20:32   ` Peter Toft
2007-07-18 21:56     ` Peter Toft
2007-07-19  3:10       ` Daniel Jacobowitz
2007-07-20 18:48         ` Peter Toft
2007-07-20 19:08       ` Jim Blandy
2007-07-21 14:16         ` Peter Toft
2007-07-23 17:05           ` Jim Blandy
2007-07-23 21:38             ` Peter Toft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox