* [patch] use .gnu.attributes to detect e500 machine type
@ 2009-04-08 14:48 Aleksandar Ristovski
2009-04-14 19:48 ` Aleksandar Ristovski
2009-04-28 21:31 ` Joel Brobecker
0 siblings, 2 replies; 8+ messages in thread
From: Aleksandar Ristovski @ 2009-04-08 14:48 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2287 bytes --]
Hello,
The patch introduces determining e500 cpu from
.gnu.attributes; if gnu attributes section is not present,
fall-back to the old way of checking the presence of
.PPC.EMB.apuinfo section.
It also introduces a function for "show powerpc vector-abi"
to print both ABI being used and if different, global
setting (output can be seen below). This could be a separate
patch - let me know if you want it separately.
Background of the patch:
Currently, gdb relies on presence .PPC.EMB.apuinfo section.
This is not completely correct since apuinfo section can
contain information about any APU instructions present, and
not only SPE. So we could have a binary with
.PPC.EMB.apuinfo section and without SPE APU. Further,
.PPC.EMB.apuinfo may not be present at all even if -me500 is
specified. This is due to gas emitting this section only if
it encounters SPE APU instructions in the assembly.
.gnu.attributes section records user setting, whether there
were SPE instructions generated or not. We use gnu object
attributes in rs6000 already (for determining vector-abi and
float-point abi).
The only problem with .gnu.attribute is that if binary is
compiled with pre-4.3 gcc, .gnu.attributes section does not
get generated at all. (.gnu_attribute was added in 4.3).
This is why we fall-back to .PPC.EMB.apuinfo presence.
Results of the patch:
After starting gdb, no executable:
(gdb) show powerpc vector-abi
The vector ABI in use is "generic". Default setting is "auto".
(gdb) file /mnt/win/ppcspetest_g
Reading symbols from /mnt/win/ppcspetest_g...done.
(gdb) show powerpc vector-abi
The vector ABI in use is "spe". Default setting is "auto".
** If user overrides selected vector-abi, this is the display:
(gdb) set powerpc vector-abi generic
(gdb) show powerpc vector-abi
The vector ABI is "generic"
"show powerpc vector-abi" will now display both selected
vector-abi and user setting ("Default setting is ..."). Only
if the two concide, it will only say "Target vector ABI is
...").
Thanks,
Aleksandar Ristovski
QNX Software Systems
ChangeLog
* 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.
(_initialize_rs6000_tdep): Use powerpc_show_vector_abi.
[-- Attachment #2: rs6000-tdep-mach_type_from_gnu_obj_attr-20090408-1.diff --]
[-- Type: text/x-patch, Size: 3074 bytes --]
Index: gdb/rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.328
diff -u -p -r1.328 rs6000-tdep.c
--- gdb/rs6000-tdep.c 22 Feb 2009 01:02:19 -0000 1.328
+++ gdb/rs6000-tdep.c 8 Apr 2009 13:13:12 -0000
@@ -3385,11 +3385,34 @@ rs6000_gdbarch_init (struct gdbarch_info
if (info.abfd)
{
- sect = bfd_get_section_by_name (info.abfd, ".PPC.EMB.apuinfo");
- if (sect)
+ /* We want to check .gnu.attributes first as it records user's
+ setting. In particular, we want to know if this binary is meant
+ to be executed on a popwer pc with SPE APU. To do that,
+ we look for tag 8. Failing that, resort to detecting apuinfo
+ section. See 'as.pdf', section 'Object Attributes'. */
+ int tag8_value; /* Tag_GNU_Power_ABI_Vector */
+ unsigned long m = 0;
+
+ tag8_value = bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU,
+ Tag_GNU_Power_ABI_Vector);
+
+ /* The vector ABI used by this object file. The value will be:
+ - 0 for files not affected by the vector ABI.
+ - 1 for files using general purpose registers to pass vectors.
+ - 2 for files using AltiVec registers to pass vectors.
+ - 3 for files using SPE registers to pass vectors. */
+ if (tag8_value == 3)
+ m = bfd_mach_ppc_e500;
+ else
+ {
+ sect = bfd_get_section_by_name (info.abfd, ".PPC.EMB.apuinfo");
+ if (sect)
+ m = bfd_mach_ppc_e500;
+ }
+ if (m != 0)
{
+ mach = m;
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);
}
@@ -4003,6 +4026,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 = current_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 */
@@ -4056,6 +4109,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);
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] use .gnu.attributes to detect e500 machine type
2009-04-08 14:48 [patch] use .gnu.attributes to detect e500 machine type Aleksandar Ristovski
@ 2009-04-14 19:48 ` Aleksandar Ristovski
2009-04-28 21:31 ` Joel Brobecker
1 sibling, 0 replies; 8+ messages in thread
From: Aleksandar Ristovski @ 2009-04-14 19:48 UTC (permalink / raw)
To: gdb-patches
any thoughts?
Aleksandar Ristovski wrote:
> Hello,
>
>
> The patch introduces determining e500 cpu from .gnu.attributes; if gnu
> attributes section is not present, fall-back to the old way of checking
> the presence of .PPC.EMB.apuinfo section.
>
> It also introduces a function for "show powerpc vector-abi" to print
> both ABI being used and if different, global setting (output can be seen
> below). This could be a separate patch - let me know if you want it
> separately.
>
> Background of the patch:
>
> Currently, gdb relies on presence .PPC.EMB.apuinfo section. This is not
> completely correct since apuinfo section can contain information about
> any APU instructions present, and not only SPE. So we could have a
> binary with .PPC.EMB.apuinfo section and without SPE APU. Further,
> .PPC.EMB.apuinfo may not be present at all even if -me500 is specified.
> This is due to gas emitting this section only if it encounters SPE APU
> instructions in the assembly.
>
> .gnu.attributes section records user setting, whether there were SPE
> instructions generated or not. We use gnu object attributes in rs6000
> already (for determining vector-abi and float-point abi).
>
> The only problem with .gnu.attribute is that if binary is compiled with
> pre-4.3 gcc, .gnu.attributes section does not get generated at all.
> (.gnu_attribute was added in 4.3). This is why we fall-back to
> .PPC.EMB.apuinfo presence.
>
> Results of the patch:
>
> After starting gdb, no executable:
> (gdb) show powerpc vector-abi
> The vector ABI in use is "generic". Default setting is "auto".
> (gdb) file /mnt/win/ppcspetest_g
> Reading symbols from /mnt/win/ppcspetest_g...done.
> (gdb) show powerpc vector-abi
> The vector ABI in use is "spe". Default setting is "auto".
>
> ** If user overrides selected vector-abi, this is the display:
> (gdb) set powerpc vector-abi generic
> (gdb) show powerpc vector-abi
> The vector ABI is "generic"
>
>
> "show powerpc vector-abi" will now display both selected vector-abi and
> user setting ("Default setting is ..."). Only if the two concide, it
> will only say "Target vector ABI is ...").
>
>
> Thanks,
>
> Aleksandar Ristovski
> QNX Software Systems
>
>
> ChangeLog
> * 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.
> (_initialize_rs6000_tdep): Use powerpc_show_vector_abi.
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] use .gnu.attributes to detect e500 machine type
2009-04-08 14:48 [patch] use .gnu.attributes to detect e500 machine type Aleksandar Ristovski
2009-04-14 19:48 ` Aleksandar Ristovski
@ 2009-04-28 21:31 ` Joel Brobecker
2009-05-22 19:21 ` Aleksandar Ristovski
1 sibling, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2009-04-28 21:31 UTC (permalink / raw)
To: Aleksandar Ristovski; +Cc: gdb-patches
Hello Aleksandar,
I wish someone more familiar with the PPC architecture had some time
to review your patch. In the meantime, I'll trust your knowledge of
the PPC; but it's nice to see that the current code seems to confirm
what you said :)
> It also introduces a function for "show powerpc vector-abi" to print both
> ABI being used and if different, global setting (output can be seen
> below). This could be a separate patch - let me know if you want it
> separately.
I think it would make sense to separate this part, especially since
I don't understand what you're trying to do, yet. Perhaps we'll need
to start doing something like what we do for "set/show lang ...",
but we can discuss this relatively minor part separately.
> * 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.
What do you think?
--
Joel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] use .gnu.attributes to detect e500 machine type
2009-04-28 21:31 ` Joel Brobecker
@ 2009-05-22 19:21 ` Aleksandar Ristovski
2009-07-06 16:34 ` Aleksandar Ristovski
0 siblings, 1 reply; 8+ messages in thread
From: Aleksandar Ristovski @ 2009-05-22 19:21 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]
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
[-- Attachment #2: rs6000-tdep-mach_type_from_gnu_obj_attr-20090522-1.diff --]
[-- Type: text/x-patch, Size: 3049 bytes --]
Index: gdb/rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.328
diff -u -p -r1.328 rs6000-tdep.c
--- gdb/rs6000-tdep.c 22 Feb 2009 01:02:19 -0000 1.328
+++ gdb/rs6000-tdep.c 22 May 2009 19:15:42 -0000
@@ -3371,6 +3371,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;
@@ -3383,16 +3420,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
@@ -3629,43 +3664,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-20090522-1.diff --]
[-- Type: text/x-patch, Size: 1678 bytes --]
Index: gdb/rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.328
diff -u -p -r1.328 rs6000-tdep.c
--- gdb/rs6000-tdep.c 22 Feb 2009 01:02:19 -0000 1.328
+++ gdb/rs6000-tdep.c 22 May 2009 18:43:14 -0000
@@ -4003,6 +4029,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 = current_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 */
@@ -4056,6 +4112,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);
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] use .gnu.attributes to detect e500 machine type
2009-05-22 19:21 ` Aleksandar Ristovski
@ 2009-07-06 16:34 ` Aleksandar Ristovski
2009-07-06 17:48 ` Daniel Jacobowitz
0 siblings, 1 reply; 8+ messages in thread
From: Aleksandar Ristovski @ 2009-07-06 16:34 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2039 bytes --]
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.
[-- Attachment #2: rs6000-tdep-mach_type_from_gnu_obj_attr-20090706.diff --]
[-- Type: text/x-patch, Size: 3047 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 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)
[-- Attachment #3: rs6000-tdep-show_vector_abi-20090706.diff --]
[-- Type: text/x-patch, Size: 1675 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 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);
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] use .gnu.attributes to detect e500 machine type
2009-07-06 16:34 ` Aleksandar Ristovski
@ 2009-07-06 17:48 ` Daniel Jacobowitz
2009-07-06 21:26 ` Aleksandar Ristovski
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2009-07-06 17:48 UTC (permalink / raw)
To: Aleksandar Ristovski; +Cc: gdb-patches
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)".
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] use .gnu.attributes to detect e500 machine type
2009-07-06 17:48 ` Daniel Jacobowitz
@ 2009-07-06 21:26 ` Aleksandar Ristovski
2009-07-21 15:41 ` Aleksandar Ristovski
0 siblings, 1 reply; 8+ messages in thread
From: Aleksandar Ristovski @ 2009-07-06 21:26 UTC (permalink / raw)
To: gdb-patches; +Cc: Daniel Jacobowitz
[-- 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);
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] use .gnu.attributes to detect e500 machine type
2009-07-06 21:26 ` Aleksandar Ristovski
@ 2009-07-21 15:41 ` Aleksandar Ristovski
0 siblings, 0 replies; 8+ messages in thread
From: Aleksandar Ristovski @ 2009-07-21 15:41 UTC (permalink / raw)
To: gdb-patches; +Cc: Daniel Jacobowitz
I haven't committed this... I made changes as per
suggestion. Is it ok to commit?
Aleksandar Ristovski wrote:
> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-07-21 15:39 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-08 14:48 [patch] use .gnu.attributes to detect e500 machine type 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
2009-07-21 15:41 ` Aleksandar Ristovski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox