Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Aleksandar Ristovski <aristovski@qnx.com>
To: gdb-patches@sources.redhat.com
Cc: Daniel Jacobowitz <drow@false.org>
Subject: Re: [patch] use .gnu.attributes to detect e500 machine type
Date: Mon, 06 Jul 2009 21:26:00 -0000	[thread overview]
Message-ID: <4A526BF3.70102@qnx.com> (raw)
In-Reply-To: <20090706174836.GA22949@caradoc.them.org>

[-- Attachment #1: Type: text/plain, Size: 2609 bytes --]

Daniel Jacobowitz wrote:
> On Mon, Jul 06, 2009 at 12:33:51PM -0400, Aleksandar Ristovski wrote:
>> ping?
>>
>> Note: new patch attached taking into account current_gdbarch removal.
> 
> These look OK to me.  You might want to use the same style used for
> other settings though: "auto (currently spe)".
> 

Changed accordingly:

$ ./gdb
GNU gdb (GDB) 6.8.50.20090706-cvs
(gdb) show powerpc vector-abi
The current vector ABI is "auto" (currently "generic").
(gdb) set powerpc vector-abi spe
(gdb) show powerpc vector-abi
The current vector ABI is "spe"
(gdb) file 
/home/src/testcases/ppcspetest/nto/ppc/o-be-g/ppcspetest_gSPE
Reading symbols from 
/home/src/testcases/ppcspetest/nto/ppc/o-be-g/ppcspetest_gSPE...done.
(gdb) show powerpc vector-abi
The current vector ABI is "spe"
(gdb) file 
/home/src/testcases/ppcspetest/nto/ppc/o-be-g/ppcspetest_gnospe
Load new symbol table from 
"/home/src/testcases/ppcspetest/nto/ppc/o-be-g/ppcspetest_gnospe"? 
(y or n) y
Reading symbols from 
/home/src/testcases/ppcspetest/nto/ppc/o-be-g/ppcspetest_gnospe...done.
(gdb) show powerpc vector-abi
The current vector ABI is "spe"
                           ^^^^^^
                   because we set it explicitly.
(gdb) q


Now auto selection:
$ ./gdb
...
(gdb) show powerpc vector-abi
The current vector ABI is "auto" (currently "generic").
(gdb) file 
/home/src/testcases/ppcspetest/nto/ppc/o-be-g/ppcspetest_gSPE
Reading symbols from 
/home/src/testcases/ppcspetest/nto/ppc/o-be-g/ppcspetest_gSPE...done.
(gdb) show powerpc vector-abi
The current vector ABI is "auto" (currently "spe").
(gdb) file 
/home/src/testcases/ppcspetest/nto/ppc/o-be-g/ppcspetest_gnospe
Load new symbol table from 
"/home/src/testcases/ppcspetest/nto/ppc/o-be-g/ppcspetest_gnospe"? 
(y or n) y
Reading symbols from 
/home/src/testcases/ppcspetest/nto/ppc/o-be-g/ppcspetest_gnospe...done.
(gdb) show powerpc vector-abi
The current vector ABI is "auto" (currently "generic").
(gdb)



Note that I made one change to my original proposal, namely 
in rs6000_gdbarch_init, if vector_abi is  POWERPC_VEC_SPE we 
assume arch bfd_arch_powerpc since if we are just changing 
the vector-abi without a file, it would be unable to match 
target description.


-- 
Aleksandar Ristovski
QNX Software Systems


ChangeLog for rs6000-tdep-mach_type_from_gnu_obj_attr:

* rs6000-tdep.c (rs6000_gdbarch_init): Rearange the code to use
..gnu.attributes to see if this is a e500 binary (with SPE APU).


ChangeLog for rs6000-tdep-show_vector_abi:

* rs6000-tdep.c (powerpc_show_vector_abi): New function.
(_initialize_rs6000_tdep): Use powerpc_show_vector_abi.


[-- Attachment #2: rs6000-tdep-mach_type_from_gnu_obj_attr-20090706-1.diff --]
[-- Type: text/x-patch, Size: 2845 bytes --]

Index: gdb/rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.334
diff -u -p -r1.334 rs6000-tdep.c
--- gdb/rs6000-tdep.c	2 Jul 2009 17:25:58 -0000	1.334
+++ gdb/rs6000-tdep.c	6 Jul 2009 21:15:39 -0000
@@ -3390,6 +3390,43 @@ rs6000_gdbarch_init (struct gdbarch_info
 	wordsize = 4;
     }
 
+#ifdef HAVE_ELF
+  if (soft_float_flag == AUTO_BOOLEAN_AUTO && from_elf_exec)
+    {
+      switch (bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU,
+					Tag_GNU_Power_ABI_FP))
+	{
+	case 1:
+	  soft_float_flag = AUTO_BOOLEAN_FALSE;
+	  break;
+	case 2:
+	  soft_float_flag = AUTO_BOOLEAN_TRUE;
+	  break;
+	default:
+	  break;
+	}
+    }
+
+  if (vector_abi == POWERPC_VEC_AUTO && from_elf_exec)
+    {
+      switch (bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU,
+					Tag_GNU_Power_ABI_Vector))
+	{
+	case 1:
+	  vector_abi = POWERPC_VEC_GENERIC;
+	  break;
+	case 2:
+	  vector_abi = POWERPC_VEC_ALTIVEC;
+	  break;
+	case 3:
+	  vector_abi = POWERPC_VEC_SPE;
+	  break;
+	default:
+	  break;
+	}
+    }
+#endif
+
   /* Get the architecture and machine from the BFD.  */
   arch = info.bfd_arch_info->arch;
   mach = info.bfd_arch_info->mach;
@@ -3402,13 +3439,14 @@ rs6000_gdbarch_init (struct gdbarch_info
      which version of it) can execute it. In our case we just look for
      the existance of the section.  */
 
-  if (info.abfd)
+  if (vector_abi == POWERPC_VEC_SPE)
     {
-      sect = bfd_get_section_by_name (info.abfd, ".PPC.EMB.apuinfo");
-      if (sect)
+      mach = bfd_mach_ppc_e500;
+      arch = bfd_arch_powerpc;
+      if (info.abfd
+	  && bfd_get_section_by_name (info.abfd, ".PPC.EMB.apuinfo") != NULL)
 	{
 	  arch = info.bfd_arch_info->arch;
-	  mach = bfd_mach_ppc_e500;
 	  bfd_default_set_arch_mach (&abfd, arch, mach);
 	  info.bfd_arch_info = bfd_get_arch_info (&abfd);
 	}
@@ -3648,43 +3686,6 @@ rs6000_gdbarch_init (struct gdbarch_info
       return NULL;
     }
 
-#ifdef HAVE_ELF
-  if (soft_float_flag == AUTO_BOOLEAN_AUTO && from_elf_exec)
-    {
-      switch (bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU,
-					Tag_GNU_Power_ABI_FP))
-	{
-	case 1:
-	  soft_float_flag = AUTO_BOOLEAN_FALSE;
-	  break;
-	case 2:
-	  soft_float_flag = AUTO_BOOLEAN_TRUE;
-	  break;
-	default:
-	  break;
-	}
-    }
-
-  if (vector_abi == POWERPC_VEC_AUTO && from_elf_exec)
-    {
-      switch (bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU,
-					Tag_GNU_Power_ABI_Vector))
-	{
-	case 1:
-	  vector_abi = POWERPC_VEC_GENERIC;
-	  break;
-	case 2:
-	  vector_abi = POWERPC_VEC_ALTIVEC;
-	  break;
-	case 3:
-	  vector_abi = POWERPC_VEC_SPE;
-	  break;
-	default:
-	  break;
-	}
-    }
-#endif
-
   if (soft_float_flag == AUTO_BOOLEAN_TRUE)
     soft_float = 1;
   else if (soft_float_flag == AUTO_BOOLEAN_FALSE)

[-- Attachment #3: rs6000-tdep-show_vector_abi-20090706-1.diff --]
[-- Type: text/x-patch, Size: 1676 bytes --]

Index: gdb/rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.334
diff -u -p -r1.334 rs6000-tdep.c
--- gdb/rs6000-tdep.c	2 Jul 2009 17:25:58 -0000	1.334
+++ gdb/rs6000-tdep.c	6 Jul 2009 21:15:39 -0000
@@ -4022,6 +4023,36 @@ powerpc_set_vector_abi (char *args, int 
     internal_error (__FILE__, __LINE__, "could not update architecture");
 }
 
+static void
+powerpc_show_vector_abi (struct ui_file *file,
+			 int from_tty,
+			 struct cmd_list_element *c,
+			 const char *value)
+{
+  struct gdbarch *gdbarch = target_gdbarch;
+  enum powerpc_vector_abi tdep_vector_abi;
+  int global_msg_only = 0;
+
+  if (gdbarch == NULL)
+    global_msg_only = 1;
+  else 
+    {
+      tdep_vector_abi = gdbarch_tdep (gdbarch)->vector_abi;
+      if (strcmp (powerpc_vector_abi_string,
+		  powerpc_vector_strings[tdep_vector_abi]) == 0)
+	global_msg_only = 1;
+    }
+
+  if (global_msg_only)
+    printf_unfiltered ("The current vector ABI is \"%s\"\n",
+		       powerpc_vector_abi_string);
+  else
+    printf_unfiltered ("\
+The current vector ABI is \"%s\" (currently \"%s\").\n",
+		       powerpc_vector_abi_string,
+		       powerpc_vector_strings[tdep_vector_abi]); 
+}
+
 /* Initialization code.  */
 
 extern initialize_file_ftype _initialize_rs6000_tdep; /* -Wmissing-prototypes */
@@ -4075,6 +4106,6 @@ _initialize_rs6000_tdep (void)
 			&powerpc_vector_abi_string,
 			_("Set the vector ABI."),
 			_("Show the vector ABI."),
-			NULL, powerpc_set_vector_abi, NULL,
+			NULL, powerpc_set_vector_abi, powerpc_show_vector_abi,
 			&setpowerpccmdlist, &showpowerpccmdlist);
 }

  reply	other threads:[~2009-07-06 21:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-08 14:48 Aleksandar Ristovski
2009-04-14 19:48 ` Aleksandar Ristovski
2009-04-28 21:31 ` Joel Brobecker
2009-05-22 19:21   ` Aleksandar Ristovski
2009-07-06 16:34     ` Aleksandar Ristovski
2009-07-06 17:48       ` Daniel Jacobowitz
2009-07-06 21:26         ` Aleksandar Ristovski [this message]
2009-07-21 15:41           ` Aleksandar Ristovski

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=4A526BF3.70102@qnx.com \
    --to=aristovski@qnx.com \
    --cc=drow@false.org \
    --cc=gdb-patches@sources.redhat.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