This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] Fix for gdb.parameter('architecture') returning empty string
- From: Siva Chandra <sivachandra at google dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 2 Nov 2012 06:44:43 -0700
- Subject: Re: [RFC] Fix for gdb.parameter('architecture') returning empty string
- References: <CAGyQ6gzRaxiQyM71_RaX7yRiUWYGrTUpmNKpd92=MRSxShJAgQ@mail.gmail.com> <87y5ilqdoz.fsf@fleche.redhat.com>
On Thu, Nov 1, 2012 at 1:18 PM, Tom Tromey <tromey@redhat.com> wrote:
> 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".
I do not understand this completely. In my patch, show_architecture
only prints 'architecture_string'. Hence,
gdb.parameter('architecture') and "show architecture" should always
show the same result. Did I miss something?
> 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.
Pardon my ignorance here, does target arch change between frames?
> 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.
Do you mean that the CLI object should have a method (which can
evaluate the property value on the go), rather than a property like
'architecture_string' and 'endian_string'? If yes, do you envision
that Python make use of the method if it exists, otherwise use the
property?
Thanks,
Siva Chandra