Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: xdje42@gmail.com (Doug Evans)
Cc: gdb-patches@sourceware.org
Subject: Cell multi-arch type resolution broken (Re: [PATCH 5/6] [PR 17684] add support for primitive types as symbols)
Date: Thu, 27 Aug 2015 13:53:00 -0000	[thread overview]
Message-ID: <20150827135314.DC0CB39FA@oc7340732750.ibm.com> (raw)
In-Reply-To: <m3k31pb0qb.fsf@sspiff.org> from "Doug Evans" at Dec 18, 2014 04:29:00 AM

Doug Evans wrote:

> 2014-12-18  Doug Evans  <xdje42@gmail.com>
> 
>	* 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,

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


  reply	other threads:[~2015-08-27 13:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-18 12:29 [PATCH 5/6] [PR 17684] add support for primitive types as symbols Doug Evans
2015-08-27 13:53 ` Ulrich Weigand [this message]
2015-08-30 21:04   ` Cell multi-arch type resolution broken (Re: [PATCH 5/6] [PR 17684] add support for primitive types as symbols) Doug Evans
2015-08-31  4:17     ` Doug Evans
2015-08-31 13:55       ` Ulrich Weigand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150827135314.DC0CB39FA@oc7340732750.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=xdje42@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox