From patchwork Thu Aug 27 13:53:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 8480 Received: (qmail 9955 invoked by alias); 27 Aug 2015 13:53:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 9943 invoked by uid 89); 27 Aug 2015 13:53:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: e06smtp15.uk.ibm.com Received: from e06smtp15.uk.ibm.com (HELO e06smtp15.uk.ibm.com) (195.75.94.111) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 27 Aug 2015 13:53:54 +0000 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Aug 2015 14:53:50 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 27 Aug 2015 14:53:48 +0100 X-MailFrom: uweigand@de.ibm.com X-RcptTo: gdb-patches@sourceware.org Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id A64612190078 for ; Thu, 27 Aug 2015 14:53:18 +0100 (BST) Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t7RDrgVH35979404 for ; Thu, 27 Aug 2015 13:53:45 GMT Received: from d06av09.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t7RDrOIR021359 for ; Thu, 27 Aug 2015 07:53:24 -0600 Received: from oc7340732750.ibm.com (dyn-9-152-213-24.boeblingen.de.ibm.com [9.152.213.24]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t7RDrO38020945; Thu, 27 Aug 2015 07:53:24 -0600 Received: by oc7340732750.ibm.com (Postfix, from userid 500) id DC0CB39FA; Thu, 27 Aug 2015 15:53:14 +0200 (CEST) Subject: Cell multi-arch type resolution broken (Re: [PATCH 5/6] [PR 17684] add support for primitive types as symbols) To: xdje42@gmail.com (Doug Evans) Date: Thu, 27 Aug 2015 15:53:14 +0200 (CEST) From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org In-Reply-To: from "Doug Evans" at Dec 18, 2014 04:29:00 AM MIME-Version: 1.0 Message-Id: <20150827135314.DC0CB39FA@oc7340732750.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15082713-0021-0000-0000-0000051B3226 Doug Evans wrote: > 2014-12-18 Doug Evans > > * gdbtypes.c (lookup_typename): Call lookup_symbol_in_language. > Remove call to language_lookup_primitive_type. No longer necessary. > (basic_lookup_symbol_nonlocal): Try looking up the symbol as a > primitive type. This seems to have broken per-architecture primitive type resolution for Cell multi-arch debugging. The problem here is that some primitive types have different properties on SPU than on PowerPC, and so you want e.g. print sizeof (long double) to print 16 while in a PowerPC frame, but print 8 in a SPU frame. This used to be triggered by the explicit gdbarch argument that was passed to the language_typename routine (and related). But after your patch, that routine is either no longer called at all, and even where it is, its gdbarch argument to language_typename is now simply ignored. Instead, we have this code in symtab.c:basic_lookup_symbol_nonlocal: > + /* If we didn't find a definition for a builtin type in the static block, > + search for it now. This is actually the right thing to do and can be > + a massive performance win. E.g., when debugging a program with lots of > + shared libraries we could search all of them only to find out the > + builtin type isn't defined in any of them. This is common for types > + like "void". */ > + if (domain == VAR_DOMAIN) > + { > + struct gdbarch *gdbarch; > + > + if (block == NULL) > + gdbarch = target_gdbarch (); > + else > + gdbarch = block_gdbarch (block); > + sym = language_lookup_primitive_type_as_symbol (langdef, gdbarch, name); > + if (sym != NULL) > + return sym; > + } which just uses target_gdbarch. This is wrong just about always in symbol- related code, and on Cell multi-arch debugging it in effect always uses the PowerPC architecture even while in a SPU frame. Note that while sometime the block architecture is used, this doesn't really help here, since lookup_typename is nearly always called with a NULL block. As a quick fix to get Cell going again, the appended patch works for me (by using get_current_arch () instead of target_gdbarch ()). But this isn't a real fix either. I guess we should either: - Pass the intended target architecture alongside the intended language throughout the symbol resolution stack, or ... - Make sure we always have a current block when calling lookup_typename (Note that latter still isn't quite the same: e.g. when debugging code without debug info, or code outside any objfile, we can never have a current block; but we can still have a proper architecture detected at runtime for the current frame.) Any thoughts on this? Bye, Ulrich Index: binutils-gdb/gdb/ada-lang.c =================================================================== --- binutils-gdb.orig/gdb/ada-lang.c +++ binutils-gdb/gdb/ada-lang.c @@ -5792,10 +5792,11 @@ ada_lookup_symbol_nonlocal (const struct if (domain == VAR_DOMAIN) { + /* FIXME: gdbarch should be passed by the caller. */ struct gdbarch *gdbarch; if (block == NULL) - gdbarch = target_gdbarch (); + gdbarch = get_current_arch (); else gdbarch = block_gdbarch (block); sym.symbol = language_lookup_primitive_type_as_symbol (langdef, gdbarch, name); Index: binutils-gdb/gdb/symtab.c =================================================================== --- binutils-gdb.orig/gdb/symtab.c +++ binutils-gdb/gdb/symtab.c @@ -41,6 +41,7 @@ #include "p-lang.h" #include "addrmap.h" #include "cli/cli-utils.h" +#include "arch-utils.h" #include "hashtab.h" @@ -2531,10 +2532,11 @@ basic_lookup_symbol_nonlocal (const stru like "void". */ if (domain == VAR_DOMAIN) { + /* FIXME: gdbarch should be passed by the caller. */ struct gdbarch *gdbarch; if (block == NULL) - gdbarch = target_gdbarch (); + gdbarch = get_current_arch (); else gdbarch = block_gdbarch (block); result.symbol = language_lookup_primitive_type_as_symbol (langdef,