From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17858 invoked by alias); 6 Jul 2009 16:34:19 -0000 Received: (qmail 17849 invoked by uid 22791); 6 Jul 2009 16:34:17 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 06 Jul 2009 16:34:09 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MNr8o-00005N-3V for gdb-patches@sources.redhat.com; Mon, 06 Jul 2009 16:34:06 +0000 Received: from entropy.qnx.com ([209.226.137.107]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 06 Jul 2009 16:34:06 +0000 Received: from aristovski by entropy.qnx.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 06 Jul 2009 16:34:06 +0000 To: gdb-patches@sources.redhat.com From: Aleksandar Ristovski Subject: Re: [patch] use .gnu.attributes to detect e500 machine type Date: Mon, 06 Jul 2009 16:34:00 -0000 Message-ID: References: <20090428213118.GH31821@adacore.com> <4A16FB06.5080507@qnx.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000405090704040804070700" User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) In-Reply-To: <4A16FB06.5080507@qnx.com> 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/msg00139.txt.bz2 This is a multi-part message in MIME format. --------------000405090704040804070700 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2039 ping? Note: new patch attached taking into account current_gdbarch removal. Aleksandar Ristovski wrote: > Joel, thank you for reviewing this. > > > Joel Brobecker wrote: >>> * rs6000-tdep.c (rs6000_gdbarch_init): Use .gnu.attributes to see >>> if this is a e500 binary (with SPE APU). >>> (powerpc_show_vector_abi): New function. >> >> If you look at today's version of rs6000_gdbarch_init, you'll find >> that we're already checking the Tag_GNU_Power_ABI_Vector, and setting >> the tdep->vector_abi accordingly. It's actually conditionalized on >> HAVE_ELF, so we need at least to make sure that your testing of >> the .gnu.attributes sections gets conditionalized on HAVE_ELF as well. >> >> However, I am wondering if it wouldn't be better to simply take >> advantage of the code that's already there. For that, you'll need >> to move the code up a bit, so that vector_abi gets set earlier. >> You can then use the resulting information to determine whether or >> not to fallback on the current approach of using .PPC.EMB.apuinfo. > > With rearanged code, the patch is simpler, but functionally the same. > > My original patch is broken into two, the one dealing with > rs6000_gdbarch_init changes and using .gnu.attributes, and the other > with printing "powerpc vector-abi" information. > > > Change logs: > * rs6000-tdep.c (rs6000_gdbarch_init): Rearange the code to use > .gnu.attributes to see if this is a e500 binary (with SPE APU). > > > > * rs6000-tdep.c (powerpc_show_vector_abi): New function. > (_initialize_rs6000_tdep): Use powerpc_show_vector_abi. > > > > > Thank you, > > Aleksandar > -- 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. --------------000405090704040804070700 Content-Type: text/x-patch; name="rs6000-tdep-mach_type_from_gnu_obj_attr-20090706.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="rs6000-tdep-mach_type_from_gnu_obj_attr-20090706.diff" Content-length: 3047 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 16:24:41 -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,16 +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) - { - sect = bfd_get_section_by_name (info.abfd, ".PPC.EMB.apuinfo"); - if (sect) - { - 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); - } + if (vector_abi == POWERPC_VEC_SPE + || (info.abfd + && bfd_get_section_by_name (info.abfd, ".PPC.EMB.apuinfo") != NULL)) + { + mach = bfd_mach_ppc_e500; + arch = info.bfd_arch_info->arch; + bfd_default_set_arch_mach (&abfd, arch, mach); + info.bfd_arch_info = bfd_get_arch_info (&abfd); } /* Find a default target description which describes our register @@ -3648,43 +3683,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) --------------000405090704040804070700 Content-Type: text/x-patch; name="rs6000-tdep-show_vector_abi-20090706.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="rs6000-tdep-show_vector_abi-20090706.diff" Content-length: 1675 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 16:24:41 -0000 @@ -4022,6 +4020,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 vector ABI is \"%s\"\n", + powerpc_vector_abi_string); + else + printf_unfiltered ("\ +The vector ABI in use is \"%s\". Default setting is \"%s\".\n", + powerpc_vector_strings[tdep_vector_abi], + powerpc_vector_abi_string); +} + /* Initialization code. */ extern initialize_file_ftype _initialize_rs6000_tdep; /* -Wmissing-prototypes */ @@ -4075,6 +4103,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); } --------------000405090704040804070700--