From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13723 invoked by alias); 8 Jul 2009 02:46:54 -0000 Received: (qmail 13713 invoked by uid 22791); 8 Jul 2009 02:46:54 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from wf-out-1314.google.com (HELO wf-out-1314.google.com) (209.85.200.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 08 Jul 2009 02:46:47 +0000 Received: by wf-out-1314.google.com with SMTP id 23so1992779wfg.24 for ; Tue, 07 Jul 2009 19:46:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.105.10 with SMTP id d10mr2149044wfc.91.1247021205099; Tue, 07 Jul 2009 19:46:45 -0700 (PDT) In-Reply-To: <200907071645.n67GjR0X001418@d12av02.megacenter.de.ibm.com> References: <200907071645.n67GjR0X001418@d12av02.megacenter.de.ibm.com> Date: Wed, 08 Jul 2009 02:46:00 -0000 Message-ID: Subject: Re: [RFA] Check solib bfd arch From: Hui Zhu To: Ulrich Weigand Cc: gdb-patches ml , Michael Snyder Content-Type: multipart/mixed; boundary=001636e1fcb6f51762046e28bf48 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: 2009-07/txt/msg00222.txt.bz2 --001636e1fcb6f51762046e28bf48 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-length: 2116 On Wed, Jul 8, 2009 at 00:45, Ulrich Weigand wrote: > Hui Zhu wrote: > >> + =A0/* Check bfd arch. =A0*/ >> + =A0b =3D gdbarch_bfd_arch_info (target_gdbarch); >> + =A0if (b->compatible (b, bfd_get_arch_info (abfd)) !=3D b) >> + =A0 =A0{ >> + =A0 =A0 =A0bfd_close (abfd); >> + =A0 =A0 =A0make_cleanup (xfree, found_pathname); >> + =A0 =A0 =A0error (_("`%s': ARCH not same with inferior."), found_pathn= ame); >> + =A0 =A0} > > I'm not sure this should be an error; we allow debugging a main > executable whose architecture does not match the target architecture > (if the user knows what they're doing), so IMO we should allow this > for shared libraries too. =A0A *warning* would be more appropriate. > > Also, I think it would be good if the message mentioned the architecture > in question, along the lines of: > > =A0warning (_("`%s': Shared library architecture %s is not compatible " > =A0 =A0 =A0 =A0 =A0 =A0 "with target architecture %s."), found_pathname, > =A0 =A0 =A0 =A0 =A0 bfd_get_arch_info (abfd)->printable_name, b->printabl= e_name); > Agree with you. I make a new patch for it. Please help me review it. Thanks. Hui 2009-07-08 Hui Zhu * solib.c (solib_bfd_open): Output a warning if solib's architecture is not compatible with inferior's architecture. --- solib.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/solib.c +++ b/solib.c @@ -289,6 +289,7 @@ solib_bfd_open (char *pathname) char *found_pathname; int found_file; bfd *abfd; + const struct bfd_arch_info *b; /* Use target-specific override if present. */ if (ops->bfd_open) @@ -311,6 +312,13 @@ solib_bfd_open (char *pathname) found_pathname, bfd_errmsg (bfd_get_error ())); } + /* Check bfd arch. */ + b =3D gdbarch_bfd_arch_info (target_gdbarch); + if (b->compatible (b, bfd_get_arch_info (abfd)) !=3D b) + warning (_("`%s': Shared library architecture %s is not compatible " + "with target architecture %s."), found_pathname, + bfd_get_arch_info (abfd)->printable_name, b->printable_name); + return abfd; } --001636e1fcb6f51762046e28bf48 Content-Type: text/plain; charset=US-ASCII; name="solib-check-bfd_arch_info.txt" Content-Disposition: attachment; filename="solib-check-bfd_arch_info.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_fwvgatfz0 Content-length: 1078 LS0tCiBzb2xpYi5jIHwgICAgOCArKysrKysrKwogMSBmaWxlIGNoYW5nZWQs IDggaW5zZXJ0aW9ucygrKQoKLS0tIGEvc29saWIuYworKysgYi9zb2xpYi5j CkBAIC0yODksNiArMjg5LDcgQEAg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