From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28569 invoked by alias); 18 Jul 2007 11:22:38 -0000 Received: (qmail 28560 invoked by uid 22791); 18 Jul 2007 11:22:38 -0000 X-Spam-Check-By: sourceware.org Received: from nz-out-0506.google.com (HELO nz-out-0506.google.com) (64.233.162.238) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 18 Jul 2007 11:22:36 +0000 Received: by nz-out-0506.google.com with SMTP id x7so122643nzc for ; Wed, 18 Jul 2007 04:22:34 -0700 (PDT) Received: by 10.143.40.12 with SMTP id s12mr104994wfj.1184757753960; Wed, 18 Jul 2007 04:22:33 -0700 (PDT) Received: by 10.142.72.16 with HTTP; Wed, 18 Jul 2007 04:22:33 -0700 (PDT) Message-ID: Date: Wed, 18 Jul 2007 17:59:00 -0000 From: "Peter Toft" To: gdb@sourceware.org Subject: gdb printing of dynamically allocated matrix MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: b0bb67b14aa5e61b X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-07/txt/msg00141.txt.bz2 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