From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19103 invoked by alias); 21 Dec 2011 19:18:04 -0000 Received: (qmail 19088 invoked by uid 22791); 21 Dec 2011 19:18:02 -0000 X-SWARE-Spam-Status: No, hits=-8.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Dec 2011 19:17:50 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBLJHlNK003042 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 21 Dec 2011 14:17:49 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pBLIHpjS021464; Wed, 21 Dec 2011 13:17:51 -0500 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id pBLIHnoe021719; Wed, 21 Dec 2011 13:17:50 -0500 From: Tom Tromey To: Siva Chandra Cc: gdb-patches@sourceware.org Subject: Re: [RFC] A new command 'explore' References: Date: Wed, 21 Dec 2011 19:36:00 -0000 In-Reply-To: (Siva Chandra's message of "Tue, 20 Dec 2011 00:30:20 +0530") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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-12/txt/msg00741.txt.bz2 >>>>> "Siva" == Siva Chandra writes: Siva> Attached is a patch which implements a new command 'explore' using the Siva> GDB Python API. Thanks. It seems like a nice addition to me. It would have helped a little if you had included a sample session in your email. I read the patch, though not in an extremely deep way. Siva> + """Internel class which invokes other explorers.""" Typo, "Internal". Siva> + raw_input("\nPress enter to return to parent value...") The explorer seems to require a lot of enter-pressing. To me it seems like this would get in the way. I did not actually try it out, though. Siva> + try: Siva> + deref_value = value.dereference() Siva> + except RuntimeError: I think that it should be possible to catch gdb.MemoryError here. That would be more precise. I didn't notice a way to explore a pointer that is really a decayed array. Siva> + array_range = value.type.range() Siva> + if index < array_range[0] or index > array_range[1]: I am not sure this will always do the right thing. It seems possible to me for an array not to have a valid range. Siva> + @staticmethod Siva> + def get_type_from_str(type_str): Siva> + try: Siva> + # Assume the current language to be C/C++ and make a try. Siva> + return gdb.parse_and_eval("(%s *)0" % type_str).type.target() This is a nice trick. If you have time, it would be nice to extend the API so that this trick isn't needed. I think a type-parsing method would be useful. Siva> + raise gdb.GdbError( Siva> + ("ERROR: \'%s\' neither evaluates to a value nor is a type " No need for "ERROR: ", I think. Tom