RFA: probable rs6000-aix-tdep.c bug found by clang

Joel Brobecker brobecker@adacore.com
Wed Oct 17 21:24:00 GMT 2012

> Based on indentation and logic I think that the fix is to remove the ";".
> However, I have no decent way to test this and would appreciate someone
> else looking at it.
> 2012-10-17  Tom Tromey  <tromey@redhat.com>
> 	* rs6000-aix-tdep.c (rs6000_aix_osabi_sniffer): Remove extraneous
> 	semicolon.

Thanks Tom, for shaming my Evil twin :-). He's pretending to be
spelunking at the moment - aka hiding in a cave, while his Good
twin is writing a reply...

The patch looks completely correct. In fact, AdaCore's version of GDB
defines the function as follow:

  if (bfd_get_flavour (abfd) != bfd_target_xcoff_flavour)

  /* The only noticeable difference between Lynx178 XCOFF files and
     AIX XCOFF files comes from the fact that there are no shared
     libraries on Lynx178. On AIX, we are betting that an executable
     linked with no shared library will never exist.  */
  if (xcoff_get_n_import_files (abfd) <= 0)

  return GDB_OSABI_AIX;

We've had that change for a few months, now, so that should be
enough evidence that the change is not going to create problems.

I researched a little bit how this error managed to not break any
other platform.  But I think we just got lucky, because no other
powerpc target outside of AIX uses the xcoff flavor.

In fact, going one step further, do we need the check at all?
This is how the sniffer is registered:

  gdbarch_register_osabi_sniffer (bfd_arch_rs6000,
  gdbarch_register_osabi_sniffer (bfd_arch_powerpc,

So, isn't rs6000_aix_osabi_sniffer going to be called if, and only
if, the bfd has a bfd_target_xcoff_flavour, thus making the check

> diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
> index 59cfa73..749c109 100644
> --- a/gdb/rs6000-aix-tdep.c
> +++ b/gdb/rs6000-aix-tdep.c
> @@ -723,7 +723,7 @@ static enum gdb_osabi
>  rs6000_aix_osabi_sniffer (bfd *abfd)
>  {
> -  if (bfd_get_flavour (abfd) == bfd_target_xcoff_flavour);
> +  if (bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
>      return GDB_OSABI_AIX;
>    return GDB_OSABI_UNKNOWN;


More information about the Gdb-patches mailing list