From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19667 invoked by alias); 10 May 2002 04:21:57 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 19655 invoked from network); 10 May 2002 04:21:55 -0000 Received: from unknown (HELO dr-evil.shagadelic.org) (208.176.2.162) by sources.redhat.com with SMTP; 10 May 2002 04:21:55 -0000 Received: by dr-evil.shagadelic.org (Postfix, from userid 7518) id 761BE9869; Thu, 9 May 2002 21:21:36 -0700 (PDT) Date: Thu, 09 May 2002 21:21:00 -0000 From: Jason R Thorpe To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: [PATCH/RFA] Don't gdbarch_init for core files Message-ID: <20020509212134.W3435@dr-evil.shagadelic.org> Reply-To: thorpej@wasabisystems.com Mail-Followup-To: Jason R Thorpe , Andrew Cagney , gdb-patches@sources.redhat.com References: <20020509185824.U3435@dr-evil.shagadelic.org> <3CDB38BB.4030807@cygnus.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="n83H03bbH672hrlY" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3CDB38BB.4030807@cygnus.com>; from ac131313@cygnus.com on Thu, May 09, 2002 at 11:04:27PM -0400 Organization: Wasabi Systems, Inc. X-SW-Source: 2002-05/txt/msg00322.txt.bz2 --n83H03bbH672hrlY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 454 On Thu, May 09, 2002 at 11:04:27PM -0400, Andrew Cagney wrote: > Instead of removing the call, is it possible to reasonably detect if the > core file belongs to the current architecture (either in corefile.c) or > in gdbarch_FOO_init(). How about this? * corelow.c (core_open): If the core's arch is known and different from the current, reinitialize gdbarch based on the core file. -- -- Jason R. Thorpe --n83H03bbH672hrlY Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=core-patch Content-length: 1021 Index: corelow.c =================================================================== RCS file: /cvs/src/src/gdb/corelow.c,v retrieving revision 1.21 diff -u -r1.21 corelow.c --- corelow.c 5 May 2002 01:15:13 -0000 1.21 +++ corelow.c 10 May 2002 04:14:05 -0000 @@ -264,6 +264,7 @@ bfd *temp_bfd; int ontop; int scratch_chan; + const struct bfd_arch_info *current_arch_info; target_preopen (from_tty); if (!filename) @@ -321,7 +322,13 @@ error ("\"%s\": Can't find sections: %s", bfd_get_filename (core_bfd), bfd_errmsg (bfd_get_error ())); - set_gdbarch_from_file (core_bfd); + /* If the core's arch is known and different from the current, + reinitialize gdbarch based on the core file. */ + + current_arch_info = gdbarch_bfd_arch_info (current_gdbarch); + if (core_bfd->arch_info->arch != bfd_arch_unknown + && core_bfd->arch_info->arch != current_arch_info->arch) + set_gdbarch_from_file (core_bfd); ontop = !push_target (&core_ops); discard_cleanups (old_chain); --n83H03bbH672hrlY--