From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6070 invoked by alias); 20 Jul 2007 22:22:12 -0000 Received: (qmail 6062 invoked by uid 22791); 20 Jul 2007 22:22:12 -0000 X-Spam-Check-By: sourceware.org Received: from 0x5731473b.taanxx2.adsl-dhcp.tele.dk (HELO linuxbog.dk) (87.49.71.59) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 20 Jul 2007 22:22:08 +0000 Received: from localhost (localhost [127.0.0.1]) by linuxbog.dk (Postfix) with ESMTP id C9082328098; Sat, 21 Jul 2007 00:22:05 +0200 (CEST) Date: Sat, 21 Jul 2007 14:16:00 -0000 From: Peter Toft To: Jim Blandy cc: gdb@sourceware.org Subject: Re: gdb printing of dynamically allocated matrix In-Reply-To: Message-ID: References: <20070718183326.GA25345@caradoc.them.org> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-1463811583-671241226-1184970116=:4288" 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/msg00156.txt.bz2 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1463811583-671241226-1184970116=:4288 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Content-length: 670 On Fri, 20 Jul 2007, Jim Blandy wrote: > > Peter Toft writes: > >> (gdb) matprint c 2 3 > > Could you use sizeof to compute the dimensions automatically? Or at > least one of them? Dear Jim I think I understand which direction you are point me to, but "sizeof" in GDB does not ring a bell here. In C yes, but in GDB no. Can you give me an example e.g. for 1D arrays? We might target this snippet befor we move to 2D matrices; int *a; a=(int *)malloc(3*sizeof(int)); a[0] = 1; a[1] = 6; a[2] = 8; Best Peter -- Peter Toft, Ph.D. [pto@linuxbog.dk] http://petertoft.dk Følg min Linux-blog på http://www.version2.dk/blogs/petertoft ---1463811583-671241226-1184970116=:4288--