From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7783 invoked by alias); 12 Sep 2011 15:08:10 -0000 Received: (qmail 7772 invoked by uid 22791); 12 Sep 2011 15:08:09 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 12 Sep 2011 15:07:50 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=EU1-MAIL.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1R386v-0002VH-Nd from pedro_alves@mentor.com ; Mon, 12 Sep 2011 08:07:49 -0700 Received: from scottsdale.localnet ([172.16.63.104]) by EU1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 12 Sep 2011 16:07:38 +0100 From: Pedro Alves To: Abhijit Halder Subject: Re: Provision for array as debugger variable Date: Mon, 12 Sep 2011 15:11:00 -0000 User-Agent: KMail/1.13.6 (Linux/2.6.38-11-generic; KDE/4.7.0; x86_64; ; ) Cc: gdb-patches@sourceware.org References: <201109121442.17296.pedro@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201109121607.37489.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-09/txt/msg00194.txt.bz2 On Monday 12 September 2011 15:14:52, Abhijit Halder wrote: > On Mon, Sep 12, 2011 at 7:12 PM, Pedro Alves wrote: > > On Monday 12 September 2011 13:44:15, Abhijit Halder wrote: > > > >> in GDB we can do this to define a debugger variable: > >> (gdb) set $var > >> > >> The $var is a scalar variable. Can we define similarly an array? > > > > (gdb) set $var1 = {0, 1} > > (gdb) ptype $var1 > > type = int [2] > > (gdb) p $var1 > > $1 = {0, 1} > > > > (gdb) set $var2 = (char[2]) {0, 1} > > (gdb) ptype $var2 > > type = char [2] > > (gdb) p $var2 > > $2 = "\000\001" > > > > -- > > Pedro Alves > > > > Okay I got it. I'm just curious about whether we can have similarly > dynamic array and associative array along with it, and at the same > time some functionality on top of this, like push etc. function as in > perl. This will be an approach towards making gdb in itself as a > mature scripting language. Just a thought! This array syntax I've shown is meant to create artificial arrays that can be passed to the inferior in function calls, and do manipulations on them as if they came from the inferior in the first place. If you want better handling of arrays for use in scripts, a better approach that should work now, would be to use python instead of the CLI. -- Pedro Alves