From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13706 invoked by alias); 22 Dec 2011 10:35:23 -0000 Received: (qmail 13605 invoked by uid 22791); 22 Dec 2011 10:35:21 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-qy0-f169.google.com (HELO mail-qy0-f169.google.com) (209.85.216.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 22 Dec 2011 10:35:07 +0000 Received: by qcsd17 with SMTP id d17so5641073qcs.0 for ; Thu, 22 Dec 2011 02:35:07 -0800 (PST) Received: by 10.229.78.141 with SMTP id l13mr3906207qck.120.1324550106952; Thu, 22 Dec 2011 02:35:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.78.141 with SMTP id l13mr3906201qck.120.1324550106842; Thu, 22 Dec 2011 02:35:06 -0800 (PST) Received: by 10.224.72.210 with HTTP; Thu, 22 Dec 2011 02:35:06 -0800 (PST) In-Reply-To: References: Date: Thu, 22 Dec 2011 11:00:00 -0000 Message-ID: Subject: Re: [RFC] A new command 'explore' From: Siva Chandra To: Tom Tromey Cc: gdb-patches@sourceware.org X-System-Of-Record: true Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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-12/txt/msg00779.txt.bz2 Thanks for taking a look Tom. My comments inline. Siva> + =A0 =A0 =A0 =A0raw_input("\nPress enter to return to parent value..= .") Tom > The explorer seems to require a lot of enter-pressing. Tom > Tom > To me it seems like this would get in the way. Tom > I did not actually try it out, though. I didn't find any better way than this to inform the user that returning to the parent is the only possible thing to do. Siva> + =A0 =A0 =A0 =A0try: Siva> + =A0 =A0 =A0 =A0 =A0 =A0deref_value =3D value.dereference() Siva> + =A0 =A0 =A0 =A0except RuntimeError: Tom > I think that it should be possible to catch gdb.MemoryError here. Tom > That would be more precise. OK. I will change to MemoryError. But I think just dereferencing does not suffice here. There should be something else to try reading the value: str(value.dereference()) ?? Tom > I didn't notice a way to explore a pointer that is really a decayed Tom > array. I will try to add something for this. Siva> + =A0 =A0 =A0 =A0array_range =3D value.type.range() Siva> + =A0 =A0 =A0 =A0if index < array_range[0] or index > array_range[1]: Tom > I am not sure this will always do the right thing. Tom > It seems possible to me for an array not to have a valid range. I agree. I do know that it is not sufficient for many of the GCC data structures. However, I couldn't think of a better compromise. How do we convey to the user that he is going out of bounds? Is such a thing required at all?? Let the user figure out the array bounds by some other means? Siva> + =A0 =A0@staticmethod Siva> + =A0 =A0def get_type_from_str(type_str): Siva> + =A0 =A0 =A0 =A0try: Siva> + =A0 =A0 =A0 =A0 =A0 =A0# Assume the current language to be C/C++ an= d make a try. Siva> + =A0 =A0 =A0 =A0 =A0 =A0return gdb.parse_and_eval("(%s *)0" % type_s= tr).type.target() Tom > This is a nice trick. This trick is not mine, it was suggested to me by Doug Evans. Tom > If you have time, it would be nice to extend the API so that this tri= ck Tom > isn't needed. =A0I think a type-parsing method would be useful. Can I take a look at this after clearing this patch? Thanks, Siva Chandra