From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14535 invoked by alias); 1 Nov 2012 20:19:09 -0000 Received: (qmail 14480 invoked by uid 22791); 1 Nov 2012 20:19:05 -0000 X-SWARE-Spam-Status: No, hits=-7.1 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,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; Thu, 01 Nov 2012 20:18:55 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qA1KIrbd018712 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 1 Nov 2012 16:18:54 -0400 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qA1KIqlc009633 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 1 Nov 2012 16:18:53 -0400 From: Tom Tromey To: Siva Chandra Cc: gdb-patches@sourceware.org Subject: Re: [RFC] Fix for gdb.parameter('architecture') returning empty string References: Date: Thu, 01 Nov 2012 20:19:00 -0000 In-Reply-To: (Siva Chandra's message of "Sat, 13 Oct 2012 16:43:51 -0700") Message-ID: <87y5ilqdoz.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (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: 2012-11/txt/msg00025.txt.bz2 >>>>> "Siva" == Siva Chandra writes: Siva> Currently, gdb.parameter ('architecture') and gdb.parameter ('endian') Siva> return an empty string. Attached is a patch which fixes this. I am Siva> not very sure if this is the cleanest fix, but I could not come up Siva> with a better one. Thanks for the patch. I'm not certain that this patch is correct. Also I tend to think (but of course I am willing to be convinced otherwise) that a different direction would be preferable. Siva> +static void Siva> +on_architecture_change (struct gdbarch *arch) Siva> +{ Siva> + architecture_string = gdbarch_bfd_arch_info (arch)->printable_name; Siva> + set_endian_string (arch); Siva> +} Siva> + observer_attach_architecture_changed (on_architecture_change); I suspect this means that gdb.parameter('architecture') will not always show the same result as "show architecture". Right now, in the auto case show_architecture will call get_current_arch: struct gdbarch * get_current_arch (void) { if (has_stack_frames ()) return get_frame_arch (get_selected_frame (NULL)); else return target_gdbarch; } But from what I can tell, the architecture-change observer is not notified in every situation that might cause that function to return a different result. I think a better approach might be to address the problem of "auto" gdb parameters more globally. For example, we could add a method to the appropriate CLI object so that the Python could call this to get the correct current value. What do you think of that? I don't think we'd have to convert all auto parameters at once. However, this approach would make it easy to convert them as needed. Tom