This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/2] Detect 64-bit-ness in PowerPC Book III-E


Yao Qi wrote:

> gdb:
> 
> 2015-01-11  Yao Qi  <yao@codesourcery.com>
> 
> 	* Makefile.in (ppc-linux.o): New rule.
> 	* config/powerpc/ppc64-linux.mh (NATDEPFILES): Add ppc-linux.o.
> 	* nat/ppc-linux.h [__powerpc64__] (ppc64_64bit_inferior_p):
> 	Declare.
> 	* nat/ppc-linux.c: New file.
> 	* ppc-linux-nat.c (ppc_linux_target_wordsize) [__powerpc64__]:
> 	Call ppc64_64bit_inferior_p.
> 
> gdb/gdbserver:
> 
> 2015-01-11  Yao Qi  <yao@codesourcery.com>
> 
> 	* Makefile.in (SFILES): Add nat/ppc-linux.c.
> 	(ppc-linux.o): New rule.
> 	* configure.srv (powerpc*-*-linux*): Add ppc-linux.o.
> 	* linux-ppc-low.c (ppc_arch_setup) [__powerpc64__]: Call
> 	ppc64_64bit_inferior_p

This is OK in principle, however:

> +static void
> +ppc64_host_hwcap (unsigned long *valp)
> +{
> +  unsigned char data[2 * 8];
> +  FILE *f = fopen ("/proc/self/auxv", "r");
> +
> +  if (f == NULL)
> +    return;
> +
> +  while (fread (data, sizeof (data), 1, f) > 0)
> +    {
> +      unsigned long *data_p = (unsigned long *) data;
> +
> +      if (data_p[0] == AT_HWCAP)
> +	{
> +	  *valp = data_p[1];
> +	  break;
> +	}
> +    }
> +
> +  fclose (f);
> +}

All this can be done using "getauxval (AT_HWCAP)", which is faster and works
even if /proc is not mounted.  However, getauxval was only introduced with
glibc 2.16, so we'll probably still need the fallback ...

Bye,
Ulrich

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]