Bug 20287

Summary: X32 and "gdb_static_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t))"
Product: gdb Reporter: Jeffrey Walton <noloader>
Component: gdbAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: equationssolver, noloader, pedro, walfred.tedeschi
Priority: P2    
Version: 7.11.1   
Target Milestone: 7.12   
Host: Target:
Build: Last reconfirmed:
Attachments: Logs for all components located with a `find ... -name 'config.log'`
Fix

Description Jeffrey Walton 2016-06-21 21:05:27 UTC
I'm trying to build GDB 7.11 from sources under Debian X32 (http://debian-x32.org/).

After a standard "./configure" and building a few components, the compile fails:

gcc -g -O2   -I. -I. -I./common -I./config -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -I./../include/opcode -I./../opcodes/.. -I./../readline/.. -I./../zlib -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber  -I./gnulib/import -Ibuild-gnulib/import    -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wpointer-sign -Wmissing-prototypes -Wdeclaration-after-statement -Wmissing-parameter-type -Wold-style-declaration -Wold-style-definition -Wformat-nonliteral  -c -o amd64-linux-siginfo.o -MT amd64-linux-siginfo.o -MMD -MP -MF .deps/amd64-linux-siginfo.Tpo ./nat/amd64-linux-siginfo.c
In file included from ./common/common-defs.h:71:0,
                 from ./nat/amd64-linux-siginfo.c:21:
		 ./common/gdb_assert.h:26:14: error: size of array 'never_defined_just_used_for_checking' is negative
               extern int never_defined_just_used_for_checking[(expr) ? 1 : -1]
               ^
               ./nat/amd64-linux-siginfo.c:113:1: note: in expansion of macro 'gdb_static_assert'
               gdb_static_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t));
               ^
Makefile:2370: recipe for target 'amd64-linux-siginfo.o' failed
make[2]: *** [amd64-linux-siginfo.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/gdb-7.11.1/gdb'
Makefile:9156: recipe for target 'all-gdb' failed
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory '/gdb-7.11.1'
Makefile:846: recipe for target 'all' failed
make: *** [all] Error 2
Comment 1 Jeffrey Walton 2016-06-21 21:06:09 UTC
Created attachment 9348 [details]
Logs for all components located with a `find ... -name 'config.log'`
Comment 2 Jeffrey Walton 2016-06-21 21:12:12 UTC
I can't use Debian supplied GDB because of http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=799556. It was reported to GDB and promptly fixed, but it appears Debian never applied the upstream patch.
Comment 3 Jeffrey Walton 2016-06-21 21:49:26 UTC
I can't find the definition for nat_siginfo_t in /usr/include or /usr/lib.

Here' the definition of siginfo_t in the X32 environment. It may (or may not) be the same as x86_64. 

$ cat siginfo_t.txt 
typedef struct
  {
    int si_signo;		/* Signal number.  */
    int si_errno;		/* If non-zero, an errno value associated with
				   this signal, as defined in <errno.h>.  */
    int si_code;		/* Signal code.  */

    union
      {
	int _pad[__SI_PAD_SIZE];

	 /* kill().  */
	struct
	  {
	    __pid_t si_pid;	/* Sending process ID.  */
	    __uid_t si_uid;	/* Real user ID of sending process.  */
	  } _kill;

	/* POSIX.1b timers.  */
	struct
	  {
	    int si_tid;		/* Timer ID.  */
	    int si_overrun;	/* Overrun count.  */
	    sigval_t si_sigval;	/* Signal value.  */
	  } _timer;

	/* POSIX.1b signals.  */
	struct
	  {
	    __pid_t si_pid;	/* Sending process ID.  */
	    __uid_t si_uid;	/* Real user ID of sending process.  */
	    sigval_t si_sigval;	/* Signal value.  */
	  } _rt;

	/* SIGCHLD.  */
	struct
	  {
	    __pid_t si_pid;	/* Which child.  */
	    __uid_t si_uid;	/* Real user ID of sending process.  */
	    int si_status;	/* Exit value or signal.  */
	    __sigchld_clock_t si_utime;
	    __sigchld_clock_t si_stime;
	  } _sigchld;

	/* SIGILL, SIGFPE, SIGSEGV, SIGBUS.  */
	struct
	  {
	    void *si_addr;	/* Faulting insn/memory ref.  */
	    short int si_addr_lsb;	/* Valid LSB of the reported address.  */
	    struct
	      {
		void *_lower;
		void *_upper;
	      } si_addr_bnd;
	  } _sigfault;

	/* SIGPOLL.  */
	struct
	  {
	    long int si_band;	/* Band event for SIGPOLL.  */
	    int si_fd;
	  } _sigpoll;

	/* SIGSYS.  */
	struct
	  {
	    void *_call_addr;	/* Calling user insn.  */
	    int _syscall;	/* Triggering system call number.  */
	    unsigned int _arch; /* AUDIT_ARCH_* of syscall.  */
	  } _sigsys;
      } _sifields;
  } siginfo_t __SI_ALIGNMENT;
Comment 4 Walfred Tedeschi 2016-06-22 09:37:35 UTC
Pedro,

I think the assert has to be changed.
We have to guarantee that what we need there is:

gdb_static_assert (sizeof (nat_siginfo_t) >= sizeof (siginfo_t))

siginfo have to be anyway back compatible.
In this way we get a fault when new siginfo is created, so we need to implement it.

Do you agree?

Thanks and regards,
/Fred


-----Original Message-----
From: palves at redhat dot com [mailto:sourceware-bugzilla@sourceware.org] 
Sent: Wednesday, June 22, 2016 10:15 AM
To: Tedeschi, Walfred <walfred.tedeschi@intel.com>
Subject: [Bug gdb/20287] X32 and "gdb_static_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t))"

https://sourceware.org/bugzilla/show_bug.cgi?id=20287

Pedro Alves <palves at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |palves at redhat dot com,
                   |                            |walfred.tedeschi at intel dot com
Comment 5 Pedro Alves 2016-06-22 09:39:02 UTC
Why are the sizes different in the first place?  What's different between the types?
Comment 6 Walfred Tedeschi 2016-06-22 09:44:31 UTC
It can be that x32 siginfo doe not implement the MPX specific part in it.
I.e. the _sigfault member  could be written as:
	struct
	  {
	    void *si_addr;	/* Faulting insn/memory ref.  */
	    short int si_addr_lsb;	/* Valid LSB of the reported address.  */
	  } _sigfault;

This is a first thought that comes into my mind.

Or we have new members not implemented yet in GDB.
Comment 7 Walfred Tedeschi 2016-06-22 09:45:40 UTC


It can be that x32 siginfo doe not implement the MPX specific part in it.
I.e. the _sigfault member  could be written as:
	struct
	  {
	    void *si_addr;	/* Faulting insn/memory ref.  */
	    short int si_addr_lsb;	/* Valid LSB of the reported address.  */
	  } _sigfault;

This is a first thought that comes into my mind.

Or we have new members not implemented yet in GDB.
Comment 8 Pedro Alves 2016-06-22 09:46:15 UTC
New members should not matter, because they are added as new fields of a _union_, and the union has a field that ensures the size is fixed:

	int _pad[__SI_PAD_SIZE];
Comment 9 Walfred Tedeschi 2016-06-22 12:31:00 UTC
Looks like the sigsys was missing in the nat_sig_info.
Bellow it is nat_siginfo as in mainline.



  48 typedef struct nat_siginfo
  49 {
  50   int si_signo;
  51   int si_errno;
  52   int si_code;
  53 
  54   union
  55   {
  56     int _pad[((128 / sizeof (int)) - 4)];
  57     /* kill() */
  58     struct
  59     {
  60       unsigned int _pid;
  61       unsigned int _uid;
  62     } _kill;
  63 
  64     /* POSIX.1b timers */
  65     struct
  66     {
  67       nat_timer_t _tid;
  68       int _overrun;
  69       nat_sigval_t _sigval;
  70     } _timer;
  71 
  72     /* POSIX.1b signals */
  73     struct
  74     {
  75       unsigned int _pid;
  76       unsigned int _uid;
  77       nat_sigval_t _sigval;
  78     } _rt;
  79 
  80     /* SIGCHLD */
  81     struct
  82     {
  83       unsigned int _pid;
  84       unsigned int _uid;
  85       int _status;
  86       nat_clock_t _utime;
  87       nat_clock_t _stime;
  88     } _sigchld;
  89 
  90     /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
  91     struct
  92     {
  93       nat_uptr_t _addr;
  94       short int _addr_lsb;
  95       struct
  96       {
  97         nat_uptr_t _lower;
  98         nat_uptr_t _upper;
  99       } si_addr_bnd;
 100     } _sigfault;
 101 
 102     /* SIGPOLL */
 103     struct
 104     {
 105       int _band;
 106       int _fd;
 107     } _sigpoll;
 108   } _sifields;
 109 } nat_siginfo_t __attribute__ ((__aligned__ (8)));

sigsys is not there.
Comment 10 Pedro Alves 2016-06-22 12:55:57 UTC
It shouldn't make a difference because the _pad field should guarantee a stable size.  The whole siginfo_t object should be 128 bytes.

Unless of course, the _pad field's definition is wrong , which sounds quite plausible:

From above, it's:

  56     int _pad[((128 / sizeof (int)) - 4)];

While /usr/include/bits/siginfo.h has:

# define __SI_MAX_SIZE     128
# if __WORDSIZE == 64
#  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 4)
# else
#  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 3)
# endif

And I believe __WORDSIZE == 32 for x32.
Comment 11 Walfred Tedeschi 2016-06-22 13:02:00 UTC
Yes, you are right.

So we need to mimic this code in gdb.
I can prepare a patch for that.
Comment 12 Jeffrey Walton 2016-06-22 13:03:34 UTC
> From above, it's:
>
>   56     int _pad[((128 / sizeof (int)) - 4)];
>
> While /usr/include/bits/siginfo.h has:
>
> # define __SI_MAX_SIZE     128
> # if __WORDSIZE == 64
> #  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 4)
> # else
> #  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 3)
> # endif
>
> And I believe __WORDSIZE == 32 for x32.

Good find.

Jeff
Comment 13 Pedro Alves 2016-06-22 13:12:01 UTC
All these different siginfo types give me headaches...  :-) I don't know exactly which of the foo_siginfo_t types needs to be adjusted.

If gdb is built as x32, isn't the layout of the siginfo_t object that PTRACE_GETSIGINFO returns the full 64-bit layout?  If so, then isn't nat_siginfo_t all wrong for x32, since it uses x32 types (pointers, etc.)?
Comment 14 Walfred Tedeschi 2016-06-22 13:40:58 UTC
Only the nat_siginfo has to be changed, in case we are compiling in x32 native.

All others have the right pad.

  48 typedef struct nat_siginfo
  49 {
  50   int si_signo;
  51   int si_errno;
  52   int si_code;
  53 
  54   union
  55   {
  56     int _pad[((128 / sizeof (int)) - 4)];


Here is the compatibility layer i.e. 32bit running on x86_64
 138 typedef struct compat_siginfo
 139 {
 140   int si_signo;
 141   int si_errno;
 142   int si_code;
 143 
 144   union
 145   {
 146     int _pad[((128 / sizeof (int)) - 3)];


For X32:

 205 typedef struct compat_x32_siginfo
 206 {
 207   int si_signo;
 208   int si_errno;
 209   int si_code;
 210 
 211   union
 212   {
 213     int _pad[((128 / sizeof (int)) - 3)];
 214
Comment 15 Walfred Tedeschi 2016-06-22 13:43:20 UTC
In fact for x32 native the conversion should not be needed.

I have to investigate it.
Comment 16 Pedro Alves 2016-06-22 13:45:34 UTC
Sof if gdb is built as x32, that's the layout of the siginfo_t object that
PTRACE_GETSIGINFO returns?  x32 layout, or full 64-bit layout?
Comment 17 Pedro Alves 2016-06-22 13:46:05 UTC
Bah, too many typos.  Trying again:

So if gdb is built as x32, what's the layout of the siginfo_t object that
PTRACE_GETSIGINFO returns?  x32 layout, or full 64-bit layout?
Comment 18 Walfred Tedeschi 2016-06-22 14:04:18 UTC
I would consider that it would come as x32 layout.

Otherwise we shouldn't have got the assert, or?

Best would be to test it.
Comment 19 Walfred Tedeschi 2016-06-22 14:11:14 UTC
No processing for x32 native siginfo should be done.
This is in amd64-linux-nat.c.
Comment 20 Pedro Alves 2016-06-22 14:12:00 UTC
> Otherwise we shouldn't have got the assert, or?

No.  The assert is about the size of compile-time types.

Even if we get the size right, if the kernel actually returns a 64-bit layout, then we'll interpret the object's contents incorrectly.

> Best would be to test it.

Yes, I think so.  It might also be easy to determine from the kernel sources.
Comment 21 Walfred Tedeschi 2016-06-23 16:22:59 UTC
Installed the Debian x32 and analyzed the headers, it looks like we have a
int _pad[((128 / sizeof (int)) - 3)];

I intend to add the details tomorrow.
Comment 22 Walfred Tedeschi 2016-06-24 12:02:51 UTC
In the Kernel sources we have:

  1 #ifndef _ASM_X86_SIGINFO_H
  2 #define _ASM_X86_SIGINFO_H
  3 
  4 #ifdef __x86_64__
  5 # ifdef __ILP32__ /* x32 */
  6 typedef long long __kernel_si_clock_t __attribute__((aligned(4)));
  7 #  define __ARCH_SI_CLOCK_T             __kernel_si_clock_t
  8 #  define __ARCH_SI_ATTRIBUTES          __attribute__((aligned(8)))
  9 # else /* x86-64 */
 10 #  define __ARCH_SI_PREAMBLE_SIZE       (4 * sizeof(int))
 11 # endif
 12 #endif
 13 
 14 #include <asm-generic/siginfo.h>
 15 
 16 #endif /* _ASM_X86_SIGINFO_H */

http://lxr.free-electrons.com/source/arch/x86/include/uapi/asm/siginfo.h

So for fix we could set the _pad conditionally as the glic does.
Comment 23 Jeffrey Walton 2016-06-24 12:20:24 UTC
(In reply to Walfred Tedeschi from comment #22)
> In the Kernel sources we have:
> 
>   1 #ifndef _ASM_X86_SIGINFO_H
>   2 #define _ASM_X86_SIGINFO_H
>   3 
>   4 #ifdef __x86_64__
>   5 # ifdef __ILP32__ /* x32 */
>   6 typedef long long __kernel_si_clock_t __attribute__((aligned(4)));
>   7 #  define __ARCH_SI_CLOCK_T             __kernel_si_clock_t
>   8 #  define __ARCH_SI_ATTRIBUTES          __attribute__((aligned(8)))
>   9 # else /* x86-64 */
>  10 #  define __ARCH_SI_PREAMBLE_SIZE       (4 * sizeof(int))
>  11 # endif
>  12 #endif
>  13 
>  14 #include <asm-generic/siginfo.h>
>  15 
>  16 #endif /* _ASM_X86_SIGINFO_H */
> 
> http://lxr.free-electrons.com/source/arch/x86/include/uapi/asm/siginfo.h
> 
> So for fix we could set the _pad conditionally as the glic does.

I've got a fresh directory ready to test this. Where would you like it?

Grep is turning up 0 hits:

  # grep -R '_ASM_X86_SIGINFO_H' *
  # grep -R '__ARCH_SI_ATTRIBUTES' *
  # debian-8-x32-vm:gdb-7.11#
Comment 24 Pedro Alves 2016-06-24 12:22:28 UTC
Can't see how that's related to what the kernel puts in the PTRACE_GET_SIGINFO request.  That's the _userspace_ header.  Those are _compile_ time #ifdefs, thus they can't affect whether ptrace returns an x32 siginfo or not _at runtime_.

kernel/ptrace.c:ptrace_request handles PTRACE_GETSIGINFO:

	case PTRACE_GETSIGINFO:
		ret = ptrace_getsiginfo(child, &siginfo);
		if (!ret)
			ret = copy_siginfo_to_user(datavp, &siginfo);
		break;

and I can't see any custom copy_siginfo_to_user under arch/x86/.  There's a custom copy_siginfo_to_user32 implementation (arch/x86/kernel/signal_compat.c), but I think that that's for real 32-bit ptrace, not x32.
Comment 25 Walfred Tedeschi 2016-06-24 12:27:48 UTC
This file changes the definition of the siginfo itself.

It also change the _pad for 64 bit. the default one is the 32bit.
This is what I could understand from the header.

I am adding the default Kernel Header in here.
Comment 26 Pedro Alves 2016-06-24 12:34:23 UTC
The kernel is not compiled as a x32 binary...
Comment 27 Pedro Alves 2016-06-24 13:01:07 UTC
> and I can't see any custom copy_siginfo_to_user under arch/x86/.  There's a 
> custom copy_siginfo_to_user32 implementation (arch/x86/kernel
> /signal_compat.c), but I think that that's for real 32-bit ptrace, not x32.

OK, I think I see now.

arch/x86/kernel/ptrace.c has an x32_arch_ptrace function, that I assume is what is called when the _ptracer_ is a x32 process (not the kernel!).

That defers to compat_ptrace_request, which then ends up in copy_siginfo_to_user32, which _does_ handle x32:

int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
{
	bool ia32 = test_thread_flag(TIF_IA32);
...
					put_user_ex(from->si_utime, &to->si_utime);
					put_user_ex(from->si_stime, &to->si_stime);
				} else {
					put_user_ex(from->si_utime, &to->_sifields._sigchld_x32._utime);
					put_user_ex(from->si_stime, &to->_sifields._sigchld_x32._stime);
				}
				put_user_ex(from->si_status, &to->si_status);
...


So it does look plausible that PTRACE_GETSIGINFO returns a x32 siginfo if the ptracer is a x32 process.
Comment 28 Walfred Tedeschi 2016-06-24 13:12:35 UTC
Kernel is then 64bit.

With a set of libraries we could also have 64bit applications running on the x32 systems, or?

Would that be an use case?
Comment 29 Jeffrey Walton 2016-06-24 13:48:54 UTC
(In reply to Walfred Tedeschi from comment #28)
> Kernel is then 64bit.
> 
> With a set of libraries we could also have 64bit applications running on the
> x32 systems, or?
> 
> Would that be an use case?

You will likely experience this issue on multiple platforms, and not just X32. Its a problem incumbent to the 32-bit data models (ILP32), and it should resurface on ARM with Aarch32 execution environments on AArch64.

The data model is the reasons applications are advised to use the pair {__ILP32__,__x86_64__}, {__ILP32__,__aarch64__}, etc when determining the execution environment.
Comment 30 Pedro Alves 2016-06-24 14:08:29 UTC
OK, so PTRACE_GETSIGINFO returns a x32 siginfo_t object when the ptracer is a x32 process.

So the correct fix is indeed to make nat_siginfo_t match the x32 siginfo, when gdb is built as an x32 program.

However, it doesn't look like it's just the padding that is wrong.  We have this:

 /* For native 64-bit, clock_t in _sigchld is 64bit aligned at 4 bytes.  */
 typedef long __attribute__ ((__aligned__ (4))) nat_clock_t;

However, /usr/include/bits/siginfo.h has:

 # if defined __x86_64__ && __WORDSIZE == 32
 /* si_utime and si_stime must be 4 byte aligned for x32 to match the
    kernel.  We align siginfo_t to 8 bytes so that si_utime and si_stime
    are actually aligned to 8 bytes since their offsets are multiple of
    8 bytes.  */
 typedef __clock_t __attribute__ ((__aligned__ (4))) __sigchld_clock_t;
 #  define __SI_ALIGNMENT __attribute__ ((__aligned__ (8)))
 # else
 typedef __clock_t __sigchld_clock_t;
 #  define __SI_ALIGNMENT
 # endif

So we're currently forcing 4-byte alignment on clock_t, when it should only be so for x32, not 64-bit?
Comment 31 Jeffrey Walton 2016-06-24 14:16:59 UTC
(In reply to Jeffrey Walton from comment #29)
> (In reply to Walfred Tedeschi from comment #28)
> > Kernel is then 64bit.
> > 
> > With a set of libraries we could also have 64bit applications running on the
> > x32 systems, or?
> > 
> > Would that be an use case?
> 
> You will likely experience this issue on multiple platforms, and not just
> X32. Its a problem incumbent to the 32-bit data models (ILP32), and it
> should resurface on ARM with Aarch32 execution environments on AArch64.
> 
> The data model is the reasons applications are advised to use the pair
> {__ILP32__,__x86_64__}, {__ILP32__,__aarch64__}, etc when determining the
> execution environment.

One other use case to be aware of is this one... It bit me, and its why I [mostly] know how to detect the execution environment...

Sun Studio and Clang always defines __ILP32__ when using a 32-bit data model. It will be defined for i386, i686, etc. Its why __x86_64__, __arm64__, __aarch64__, etc are needed to discriminate.

It also diverges from System-V amd64 ABI guides at http://sites.google.com/site/x32abi/documents/abi.pdf. When I asked Clang devs  about it, they stated they were not prohibited from defining __ILP32__ on 32-bit machines.
Comment 32 Pedro Alves 2016-06-24 14:51:45 UTC
I have an idea:

- leave nat_siginfo only for 64-bit

- add a siginfo-that-ptrace-uses typedef :

#if __ILP32__
typedef compat_x32_siginfo_t ptrace_siginfo_t
#else
typedef nat_siginfo_t ptrace_siginfo_t
#endif

and then use ptrace_siginfo_t instead of nat_siginfo for the memcpys.

Hand on while I try it out.
Comment 33 Pedro Alves 2016-06-24 15:31:48 UTC
Created attachment 9360 [details]
Fix

Like this.  Can you give it a try?
Comment 34 Jeffrey Walton 2016-06-24 16:34:45 UTC
(In reply to Pedro Alves from comment #33)
> Created attachment 9360 [details]
> Fix
> 
> Like this.  Can you give it a try?

Applied to HEAD with `patch -p1 < 9360.diff`.

It looks like there are some issues, but I _think_ some progress was made since the assert did not fire.

However, when I commented out the assert in the 7.11.1 tarball, I did not encounter the issues below.

**********

gcc -g -O2   -I. -I. -I./common -I./config -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -I./../include/opcode -I./../opcodes/.. -I./../readline/.. -I./../zlib -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber  -I./gnulib/import -Ibuild-gnulib/import    -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wpointer-sign -Wmissing-prototypes -Wdeclaration-after-statement -Wmissing-parameter-type -Wold-style-declaration -Wold-style-definition -Wformat-nonliteral  -c -o amd64-linux-siginfo.o -MT amd64-linux-siginfo.o -MMD -MP -MF .deps/amd64-linux-siginfo.Tpo ./nat/amd64-linux-siginfo.c
./nat/amd64-linux-siginfo.c:297:9: error: unknown type name ‘x32_siginfo_t’
 typedef x32_siginfo_t ptrace_siginfo_t;
         ^
./nat/amd64-linux-siginfo.c: In function ‘compat_siginfo_from_siginfo’:
./nat/amd64-linux-siginfo.c:313:29: error: request for member ‘si_signo’ in something not a structure or union
   to->si_signo = from_ptrace.si_signo;
                             ^
./nat/amd64-linux-siginfo.c:314:29: error: request for member ‘si_errno’ in something not a structure or union
   to->si_errno = from_ptrace.si_errno;
                             ^
./nat/amd64-linux-siginfo.c:315:28: error: request for member ‘si_code’ in something not a structure or union
   to->si_code = from_ptrace.si_code;
                            ^
./nat/amd64-linux-siginfo.c:319:39: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_timerid = from_ptrace.cpt_si_timerid;
                                       ^
./nat/amd64-linux-siginfo.c:320:39: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_overrun = from_ptrace.cpt_si_overrun;
                                       ^
./nat/amd64-linux-siginfo.c:321:46: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_ptr = (intptr_t) from_ptrace.cpt_si_ptr;
                                              ^
./nat/amd64-linux-siginfo.c:325:35: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_pid = from_ptrace.cpt_si_pid;
                                   ^
./nat/amd64-linux-siginfo.c:326:35: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_uid = from_ptrace.cpt_si_uid;
                                   ^
./nat/amd64-linux-siginfo.c:330:35: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_pid = from_ptrace.cpt_si_pid;
                                   ^
./nat/amd64-linux-siginfo.c:331:35: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_uid = from_ptrace.cpt_si_uid;
                                   ^
./nat/amd64-linux-siginfo.c:332:46: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_ptr = (intptr_t) from_ptrace.cpt_si_ptr;
                                              ^
./nat/amd64-linux-siginfo.c:339:32: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_pid = from_ptrace.cpt_si_pid;
                                ^
./nat/amd64-linux-siginfo.c:340:32: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_uid = from_ptrace.cpt_si_uid;
                                ^
./nat/amd64-linux-siginfo.c:341:35: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_status = from_ptrace.cpt_si_status;
                                   ^
./nat/amd64-linux-siginfo.c:342:34: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_utime = from_ptrace.cpt_si_utime;
                                  ^
./nat/amd64-linux-siginfo.c:343:34: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_stime = from_ptrace.cpt_si_stime;
                                  ^
./nat/amd64-linux-siginfo.c:349:44: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_addr = (intptr_t) from_ptrace.cpt_si_addr;
                                            ^
./nat/amd64-linux-siginfo.c:352:33: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_band = from_ptrace.cpt_si_band;
                                 ^
./nat/amd64-linux-siginfo.c:353:31: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_fd = from_ptrace.cpt_si_fd;
                               ^
./nat/amd64-linux-siginfo.c:356:32: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_pid = from_ptrace.cpt_si_pid;
                                ^
./nat/amd64-linux-siginfo.c:357:32: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_uid = from_ptrace.cpt_si_uid;
                                ^
./nat/amd64-linux-siginfo.c:358:43: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_ptr = (intptr_t) from_ptrace.cpt_si_ptr;
                                           ^
./nat/amd64-linux-siginfo.c: In function ‘siginfo_from_compat_siginfo’:
./nat/amd64-linux-siginfo.c:373:12: error: request for member ‘si_signo’ in something not a structure or union
   to_ptrace.si_signo = from->si_signo;
            ^
./nat/amd64-linux-siginfo.c:374:12: error: request for member ‘si_errno’ in something not a structure or union
   to_ptrace.si_errno = from->si_errno;
            ^
./nat/amd64-linux-siginfo.c:375:12: error: request for member ‘si_code’ in something not a structure or union
   to_ptrace.si_code = from->si_code;
            ^
./nat/amd64-linux-siginfo.c:377:16: error: request for member ‘si_code’ in something not a structure or union
   if (to_ptrace.si_code == SI_TIMER)
                ^
./nat/amd64-linux-siginfo.c:379:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_timerid = from->cpt_si_timerid;
                ^
./nat/amd64-linux-siginfo.c:380:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_overrun = from->cpt_si_overrun;
                ^
./nat/amd64-linux-siginfo.c:381:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
                ^
./nat/amd64-linux-siginfo.c:383:21: error: request for member ‘si_code’ in something not a structure or union
   else if (to_ptrace.si_code == SI_USER)
                     ^
./nat/amd64-linux-siginfo.c:385:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_pid = from->cpt_si_pid;
                ^
./nat/amd64-linux-siginfo.c:386:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_uid = from->cpt_si_uid;
                ^
./nat/amd64-linux-siginfo.c:388:16: error: request for member ‘si_code’ in something not a structure or union
   if (to_ptrace.si_code < 0)
                ^
./nat/amd64-linux-siginfo.c:390:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_pid = from->cpt_si_pid;
                ^
./nat/amd64-linux-siginfo.c:391:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_uid = from->cpt_si_uid;
                ^
./nat/amd64-linux-siginfo.c:392:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
                ^
./nat/amd64-linux-siginfo.c:396:24: error: request for member ‘si_signo’ in something not a structure or union
       switch (to_ptrace.si_signo)
                        ^
./nat/amd64-linux-siginfo.c:399:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_pid = from->cpt_si_pid;
             ^
./nat/amd64-linux-siginfo.c:400:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_uid = from->cpt_si_uid;
             ^
./nat/amd64-linux-siginfo.c:401:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_status = from->cpt_si_status;
             ^
./nat/amd64-linux-siginfo.c:402:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_utime = from->cpt_si_utime;
             ^
./nat/amd64-linux-siginfo.c:403:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_stime = from->cpt_si_stime;
             ^
./nat/amd64-linux-siginfo.c:409:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_addr = (void *) (intptr_t) from->cpt_si_addr;
             ^
./nat/amd64-linux-siginfo.c:410:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_addr_lsb = (short) from->cpt_si_addr_lsb;
             ^
./nat/amd64-linux-siginfo.c:413:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_band = from->cpt_si_band;
             ^
./nat/amd64-linux-siginfo.c:414:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_fd = from->cpt_si_fd;
             ^
./nat/amd64-linux-siginfo.c:417:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_pid = from->cpt_si_pid;
             ^
./nat/amd64-linux-siginfo.c:418:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_uid = from->cpt_si_uid;
             ^
./nat/amd64-linux-siginfo.c:419:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
             ^
./nat/amd64-linux-siginfo.c: In function ‘compat_x32_siginfo_from_siginfo’:
./nat/amd64-linux-siginfo.c:437:29: error: request for member ‘si_signo’ in something not a structure or union
   to->si_signo = from_ptrace.si_signo;
                             ^
./nat/amd64-linux-siginfo.c:438:29: error: request for member ‘si_errno’ in something not a structure or union
   to->si_errno = from_ptrace.si_errno;
                             ^
./nat/amd64-linux-siginfo.c:439:28: error: request for member ‘si_code’ in something not a structure or union
   to->si_code = from_ptrace.si_code;
                            ^
./nat/amd64-linux-siginfo.c:443:39: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_timerid = from_ptrace.cpt_si_timerid;
                                       ^
./nat/amd64-linux-siginfo.c:444:39: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_overrun = from_ptrace.cpt_si_overrun;
                                       ^
./nat/amd64-linux-siginfo.c:445:46: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_ptr = (intptr_t) from_ptrace.cpt_si_ptr;
                                              ^
./nat/amd64-linux-siginfo.c:449:35: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_pid = from_ptrace.cpt_si_pid;
                                   ^
./nat/amd64-linux-siginfo.c:450:35: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_uid = from_ptrace.cpt_si_uid;
                                   ^
./nat/amd64-linux-siginfo.c:454:35: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_pid = from_ptrace.cpt_si_pid;
                                   ^
./nat/amd64-linux-siginfo.c:455:35: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_uid = from_ptrace.cpt_si_uid;
                                   ^
./nat/amd64-linux-siginfo.c:456:46: error: request for member ‘_sifields’ in something not a structure or union
       to->cpt_si_ptr = (intptr_t) from_ptrace.cpt_si_ptr;
                                              ^
./nat/amd64-linux-siginfo.c:463:32: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_pid = from_ptrace.cpt_si_pid;
                                ^
./nat/amd64-linux-siginfo.c:464:32: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_uid = from_ptrace.cpt_si_uid;
                                ^
./nat/amd64-linux-siginfo.c:465:35: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_status = from_ptrace.cpt_si_status;
                                   ^
./nat/amd64-linux-siginfo.c:466:43: error: request for member ‘_sifields’ in something not a structure or union
    memcpy (&to->cpt_si_utime, &from_ptrace.cpt_si_utime,
                                           ^
./nat/amd64-linux-siginfo.c:468:43: error: request for member ‘_sifields’ in something not a structure or union
    memcpy (&to->cpt_si_stime, &from_ptrace.cpt_si_stime,
                                           ^
./nat/amd64-linux-siginfo.c:475:44: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_addr = (intptr_t) from_ptrace.cpt_si_addr;
                                            ^
./nat/amd64-linux-siginfo.c:478:33: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_band = from_ptrace.cpt_si_band;
                                 ^
./nat/amd64-linux-siginfo.c:479:31: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_fd = from_ptrace.cpt_si_fd;
                               ^
./nat/amd64-linux-siginfo.c:482:32: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_pid = from_ptrace.cpt_si_pid;
                                ^
./nat/amd64-linux-siginfo.c:483:32: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_uid = from_ptrace.cpt_si_uid;
                                ^
./nat/amd64-linux-siginfo.c:484:43: error: request for member ‘_sifields’ in something not a structure or union
    to->cpt_si_ptr = (intptr_t) from_ptrace.cpt_si_ptr;
                                           ^
./nat/amd64-linux-siginfo.c: In function ‘siginfo_from_compat_x32_siginfo’:
./nat/amd64-linux-siginfo.c:501:12: error: request for member ‘si_signo’ in something not a structure or union
   to_ptrace.si_signo = from->si_signo;
            ^
./nat/amd64-linux-siginfo.c:502:12: error: request for member ‘si_errno’ in something not a structure or union
   to_ptrace.si_errno = from->si_errno;
            ^
./nat/amd64-linux-siginfo.c:503:12: error: request for member ‘si_code’ in something not a structure or union
   to_ptrace.si_code = from->si_code;
            ^
./nat/amd64-linux-siginfo.c:505:16: error: request for member ‘si_code’ in something not a structure or union
   if (to_ptrace.si_code == SI_TIMER)
                ^
./nat/amd64-linux-siginfo.c:507:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_timerid = from->cpt_si_timerid;
                ^
./nat/amd64-linux-siginfo.c:508:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_overrun = from->cpt_si_overrun;
                ^
./nat/amd64-linux-siginfo.c:509:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
                ^
./nat/amd64-linux-siginfo.c:511:21: error: request for member ‘si_code’ in something not a structure or union
   else if (to_ptrace.si_code == SI_USER)
                     ^
./nat/amd64-linux-siginfo.c:513:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_pid = from->cpt_si_pid;
                ^
./nat/amd64-linux-siginfo.c:514:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_uid = from->cpt_si_uid;
                ^
./nat/amd64-linux-siginfo.c:516:16: error: request for member ‘si_code’ in something not a structure or union
   if (to_ptrace.si_code < 0)
                ^
./nat/amd64-linux-siginfo.c:518:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_pid = from->cpt_si_pid;
                ^
./nat/amd64-linux-siginfo.c:519:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_uid = from->cpt_si_uid;
                ^
./nat/amd64-linux-siginfo.c:520:16: error: request for member ‘_sifields’ in something not a structure or union
       to_ptrace.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
                ^
./nat/amd64-linux-siginfo.c:524:24: error: request for member ‘si_signo’ in something not a structure or union
       switch (to_ptrace.si_signo)
                        ^
./nat/amd64-linux-siginfo.c:527:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_pid = from->cpt_si_pid;
             ^
./nat/amd64-linux-siginfo.c:528:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_uid = from->cpt_si_uid;
             ^
./nat/amd64-linux-siginfo.c:529:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_status = from->cpt_si_status;
             ^
./nat/amd64-linux-siginfo.c:530:22: error: request for member ‘_sifields’ in something not a structure or union
    memcpy (&to_ptrace.cpt_si_utime, &from->cpt_si_utime,
                      ^
./nat/amd64-linux-siginfo.c:531:22: error: request for member ‘_sifields’ in something not a structure or union
     sizeof (to_ptrace.cpt_si_utime));
                      ^
./nat/amd64-linux-siginfo.c:532:22: error: request for member ‘_sifields’ in something not a structure or union
    memcpy (&to_ptrace.cpt_si_stime, &from->cpt_si_stime,
                      ^
./nat/amd64-linux-siginfo.c:533:22: error: request for member ‘_sifields’ in something not a structure or union
     sizeof (to_ptrace.cpt_si_stime));
                      ^
./nat/amd64-linux-siginfo.c:539:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_addr = (void *) (intptr_t) from->cpt_si_addr;
             ^
./nat/amd64-linux-siginfo.c:542:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_band = from->cpt_si_band;
             ^
./nat/amd64-linux-siginfo.c:543:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_fd = from->cpt_si_fd;
             ^
./nat/amd64-linux-siginfo.c:546:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_pid = from->cpt_si_pid;
             ^
./nat/amd64-linux-siginfo.c:547:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_uid = from->cpt_si_uid;
             ^
./nat/amd64-linux-siginfo.c:548:13: error: request for member ‘_sifields’ in something not a structure or union
    to_ptrace.cpt_si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
             ^
In file included from ./common/common-defs.h:71:0,
                 from ./nat/amd64-linux-siginfo.c:21:
./nat/amd64-linux-siginfo.c: At top level:
./common/gdb_assert.h:26:14: error: size of array ‘never_defined_just_used_for_checking’ is negative
   extern int never_defined_just_used_for_checking[(expr) ? 1 : -1]
              ^
./nat/amd64-linux-siginfo.c:597:1: note: in expansion of macro ‘gdb_static_assert’
 gdb_static_assert (sizeof (ptrace_siginfo_t) == GDB_SI_SIZE);
 ^
Makefile:2370: recipe for target 'amd64-linux-siginfo.o' failed
make[2]: *** [amd64-linux-siginfo.o] Error 1
make[2]: Leaving directory '/gdb-7.11/gdb'
Makefile:9156: recipe for target 'all-gdb' failed
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory '/gdb-7.11'
Makefile:846: recipe for target 'all' failed
make: *** [all] Error 2
Comment 35 Jeffrey Walton 2016-06-24 16:41:12 UTC
(In reply to Jeffrey Walton from comment #34)
> (In reply to Pedro Alves from comment #33)
> > Created attachment 9360 [details]
> > Fix
> > 
> > Like this.  Can you give it a try?
> 
> Applied to HEAD with `patch -p1 < 9360.diff`.
> 
> It looks like there are some issues, but I _think_ some progress was made
> since the assert did not fire.
> 
> However, when I commented out the assert in the 7.11.1 tarball, I did not
> encounter the issues below.

Cancel this... I cd'd into gdb, and not binutils-gdb.
Comment 36 Pedro Alves 2016-06-24 16:44:18 UTC
That probably because I made a typo.  Where it reads:

 typedef x32_siginfo_t ptrace_siginfo_t;

Try changing it to:

 typedef compat_x32_siginfo_t ptrace_siginfo_t;
Comment 37 Jeffrey Walton 2016-06-24 16:50:01 UTC
(In reply to Pedro Alves from comment #33)
> Created attachment 9360 [details]
> Fix
> 
> Like this.  Can you give it a try?

(In reply to Pedro Alves from comment #33)
> Created attachment 9360 [details]
> Fix
> 
> Like this.  Can you give it a try?

OK, now I'm hitting the MAKEINFO bug briefly discussed at https://sourceware.org/bugzilla/show_bug.cgi?id=18987#c4.

Any ideas?

***********

# ./configure MAKEINFO=false 2>&1 | tee binutils-gdb.txt
...
# make 2>&1 | tee binutils-gdb.txt
...

/binutils-gdb/missing: 81: /binutils-gdb/missing: makeinfo: not found
WARNING: 'makeinfo' is missing on your system.
         You should only need it if you modified a '.texi' file, or
         any other file indirectly affecting the aspect of the manual.
         You might want to install the Texinfo package:
         <http://www.gnu.org/software/texinfo/>
         The spurious makeinfo call might also be the consequence of
         using a buggy 'make' (AIX, DU, IRIX), in which case you might
         want to install GNU make:
         <http://www.gnu.org/software/make/>
Makefile:472: recipe for target 'bfd.info' failed
make[3]: *** [bfd.info] Error 127
make[3]: Leaving directory '/binutils-gdb/bfd/doc'
Making info in po
make[3]: Entering directory '/binutils-gdb/bfd/po'
( if test 'x.' != 'x.'; then \
    posrcprefix='../'; \
  else \
    posrcprefix="../"; \
  fi; \
  rm -f SRC-POTFILES-t SRC-POTFILES \
    && (sed -e '/^#/d' \
            -e '/^[ 	]*$/d' \
	    -e "s@.*@	$posrcprefix& \\\\@" < ./SRC-POTFILES.in \
	| sed -e '$s/\\$//') > SRC-POTFILES-t \
    && chmod a-w SRC-POTFILES-t \
    && mv SRC-POTFILES-t SRC-POTFILES )
( rm -f BLD-POTFILES-t BLD-POTFILES \
    && (sed -e '/^#/d' \
            -e '/^[ 	]*$/d' \
	    -e "s@.*@	../& \\\\@" < ./BLD-POTFILES.in \
	| sed -e '$s/\\$//') > BLD-POTFILES-t \
    && chmod a-w BLD-POTFILES-t \
    && mv BLD-POTFILES-t BLD-POTFILES )
cd .. \
  && CONFIG_FILES=po/Makefile.in:po/Make-in \
     CONFIG_HEADERS= /bin/bash ./config.status
config.status: creating po/Makefile.in
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing default-1 commands
config.status: executing bfd_stdint.h commands
config.status: executing default commands
make[3]: Nothing to be done for 'info'.
make[3]: Leaving directory '/binutils-gdb/bfd/po'
make[3]: Entering directory '/binutils-gdb/bfd'
make[3]: Nothing to be done for 'info-am'.
make[3]: Leaving directory '/binutils-gdb/bfd'
Makefile:1711: recipe for target 'info-recursive' failed
make[2]: *** [info-recursive] Error 1
make[2]: Leaving directory '/binutils-gdb/bfd'
Makefile:2727: recipe for target 'all-bfd' failed
make[1]: *** [all-bfd] Error 2
make[1]: Leaving directory '/binutils-gdb'
Makefile:850: recipe for target 'all' failed
make: *** [all] Error 2
Comment 38 Jeffrey Walton 2016-06-24 16:59:41 UTC
(In reply to Jeffrey Walton from comment #37)
> (In reply to Pedro Alves from comment #33)
> > Created attachment 9360 [details]
> > Fix
> > 
> > Like this.  Can you give it a try?
> 
> (In reply to Pedro Alves from comment #33)
> > Created attachment 9360 [details]
> > Fix
> > 
> > Like this.  Can you give it a try?
> 
> OK, now I'm hitting the MAKEINFO bug briefly discussed at
> https://sourceware.org/bugzilla/show_bug.cgi?id=18987#c4.
> 

Confirmed with a:

    # make distclean
    # git reset --hard HEAD

    # ./configure MAKEINFO=false
Comment 39 Pedro Alves 2016-06-24 17:01:57 UTC
Confirmed that the patch fixes the x32 issue, or confirmed that you still observe the makeinfo issue?

BTW, I think the makeinfo workaround is MAKEINFO=true, not MAKEINFO=false.
Comment 40 Jeffrey Walton 2016-06-24 17:09:58 UTC
(In reply to Pedro Alves from comment #39)
> Confirmed that the patch fixes the x32 issue, or confirmed that you still
> observe the makeinfo issue?

My bad... Confirmed the MAKEINFO issue. X32 does not supply it. (Its the path of least resistance; I tried it first).

> BTW, I think the makeinfo workaround is MAKEINFO=true, not MAKEINFO=false.

That's very non-intuitive if I am parsing it correctly: when you *don't* want to build the info files, you specify `MAKEINFO=true`. And when you do want to build the info files, you say `MAKEINFO=false`. Is that correct?

I can't help but feel configure should be doing it since that is it's job. the `makeinfo` program is missing; there no sense trying to build the info files.
Comment 41 Pedro Alves 2016-06-24 17:14:04 UTC
MAKEINFO is not a boolean flag.  What this does is override the path to the "makeinfo" binary, to invoke /usr/bin/true instead.  
Maybe "MAKEINFO=/usr/bin/true" would have been clearer.
Comment 42 Jeffrey Walton 2016-06-24 17:38:03 UTC
(In reply to Pedro Alves from comment #41)
> MAKEINFO is not a boolean flag.  What this does is override the path to the
> "makeinfo" binary, to invoke /usr/bin/true instead.  
> Maybe "MAKEINFO=/usr/bin/true" would have been clearer.

Ah, thanks. That makes more sense.

So...

    # make distclean
    # git reset --hard HEAD

    # ls /bin/true 
    /bin/true

    # ./configure MAKEINFO=/bin/true
    ...
    # make
    ...

It ends with:

/binutils-gdb/missing: 81: /binutils-gdb/missing: makeinfo: not found
WARNING: 'makeinfo' is missing on your system.
         You should only need it if you modified a '.texi' file, or
         any other file indirectly affecting the aspect of the manual.
         You might want to install the Texinfo package:
         <http://www.gnu.org/software/texinfo/>
         The spurious makeinfo call might also be the consequence of
         using a buggy 'make' (AIX, DU, IRIX), in which case you might
         want to install GNU make:
         <http://www.gnu.org/software/make/>
Makefile:472: recipe for target 'bfd.info' failed
make[3]: *** [bfd.info] Error 127
make[3]: Leaving directory '/binutils-gdb/bfd/doc'
Making info in po
make[3]: Entering directory '/binutils-gdb/bfd/po'
( if test 'x.' != 'x.'; then \
    posrcprefix='../'; \
  else \
    posrcprefix="../"; \
  fi; \
  rm -f SRC-POTFILES-t SRC-POTFILES \
    && (sed -e '/^#/d' \
            -e '/^[ 	]*$/d' \
	    -e "s@.*@	$posrcprefix& \\\\@" < ./SRC-POTFILES.in \
	| sed -e '$s/\\$//') > SRC-POTFILES-t \
    && chmod a-w SRC-POTFILES-t \
    && mv SRC-POTFILES-t SRC-POTFILES )
( rm -f BLD-POTFILES-t BLD-POTFILES \
    && (sed -e '/^#/d' \
            -e '/^[ 	]*$/d' \
	    -e "s@.*@	../& \\\\@" < ./BLD-POTFILES.in \
	| sed -e '$s/\\$//') > BLD-POTFILES-t \
    && chmod a-w BLD-POTFILES-t \
    && mv BLD-POTFILES-t BLD-POTFILES )
cd .. \
  && CONFIG_FILES=po/Makefile.in:po/Make-in \
     CONFIG_HEADERS= /bin/bash ./config.status
config.status: creating po/Makefile.in
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing default-1 commands
config.status: executing bfd_stdint.h commands
config.status: executing default commands
make[3]: Nothing to be done for 'info'.
make[3]: Leaving directory '/binutils-gdb/bfd/po'
make[3]: Entering directory '/binutils-gdb/bfd'
make[3]: Nothing to be done for 'info-am'.
make[3]: Leaving directory '/binutils-gdb/bfd'
Makefile:1711: recipe for target 'info-recursive' failed
make[2]: *** [info-recursive] Error 1
make[2]: Leaving directory '/binutils-gdb/bfd'
Makefile:2727: recipe for target 'all-bfd' failed
make[1]: *** [all-bfd] Error 2
make[1]: Leaving directory '/binutils-gdb'
Makefile:850: recipe for target 'all' failed
make: *** [all] Error 2

Should I open another bug report for the MAKEINFO problems?
Comment 43 Jeffrey Walton 2016-06-24 17:40:19 UTC
> Should I open another bug report for the MAKEINFO problems?

For completeness, 'make distclean' appears to be doing its job:

# grep -IR 'MAKEINFO=false' *
#

# grep -IR 'MAKEINFO=/bin/true' *
config.log:  $ ./configure MAKEINFO=/bin/true
config.log:ac_cv_prog_MAKEINFO=/bin/true
config.log:TOPLEVEL_CONFIGURE_ARGUMENTS='./configure MAKEINFO=/bin/true'
config.status:  with options \"'MAKEINFO=/bin/true'\"
config.status:  set X '/bin/bash' './configure'  'MAKEINFO=/bin/true' $ac_configure_extra_args --no-create --no-recursion
config.status:S["TOPLEVEL_CONFIGURE_ARGUMENTS"]="./configure MAKEINFO=/bin/true"
Makefile:TOPLEVEL_CONFIGURE_ARGUMENTS=./configure MAKEINFO=/bin/true
#
Comment 44 hmb 2016-07-21 15:11:43 UTC
Hi 
any update on that issue?
Comment 45 Pedro Alves 2016-07-21 15:14:03 UTC
Waiting for someone to confirm that the patch (with the fix mentioned in comment 36 on top) fixes the x32 issue.
Comment 46 hmb 2016-07-26 11:13:57 UTC
Hi,

Now applying the patch and changing the
typedef x32_siginfo_t ptrace_siginfo_t to typedef compat_x32_siginfo_t ptrace_siginfo_t;

I can at least build the cross-complied gdbserver for x32 with build as i386-linux and target as i686-pc-linux-gnu

But gdbserver gives following warning,

gdbserver: linux_ptrace_test_ret_to_nx: Cannot PTRACE_PEEKUSER: Input/output error

and gives segmentation fault during debugging even on single instruction step command.

e.g

1> Launch gdbserver
./gdbserver :10000 test 
gdbserver: linux_ptrace_test_ret_to_nx: Cannot PTRACE_PEEKUSER: Input/output error
Process test created; pid = 473
Listening on port 10000
 
now after connecting to gdb and on si command it gives

Remote debugging from host 127.0.0.1
Segmentation fault (core dumped)
Comment 47 Walfred Tedeschi 2016-07-26 13:13:26 UTC
I am looking at it tomorrow 28.07.
Comment 48 Pedro Alves 2016-07-26 14:24:19 UTC
I installed Ubuntu 16.04 in a vm this morning to take a look at this.  Ubuntu has enough x32 runtime packages (glibc, libgcc, etc.) making it easy to build an x32 gdb.

I saw that the patch needs a couple tweaks for (remove casts through void *, for C++).
Comment 49 Pedro Alves 2016-07-26 15:00:19 UTC
> linux_ptrace_test_ret_to_nx: Cannot PTRACE_PEEKUSER: Input/output error

Filed Bug 20413 for this one.
Comment 50 Sourceware Commits 2016-07-26 18:40:36 UTC
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9cf12d57c58a82cfe3e6fee26d1ea55dfe49f9c4

commit 9cf12d57c58a82cfe3e6fee26d1ea55dfe49f9c4
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Jul 26 19:35:40 2016 +0100

    Fix PR gdb/20287 - x32 and "gdb_static_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t))"
    
    Building an x32 gdb trips on a static assertion:
    
      In file included from .../src/gdb/common/common-defs.h:71:0,
    		   from .../src/gdb/nat/amd64-linux-siginfo.c:21:
      .../src/gdb/common/gdb_assert.h:26:66: error: size of array ‘never_defined_just_used_for_checking’ is negative
         extern int never_defined_just_used_for_checking[(expr) ? 1 : -1]
    								    ^
      .../src/gdb/nat/amd64-linux-siginfo.c:113:1: note: in expansion of macro ‘gdb_static_assert’
       gdb_static_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t));
       ^
    
    The problem is that the way nat_siginfo_t is defined, it can only
    match the host's siginfo_t object when gdb is built as a 64-bit
    program.
    
    Several bits of nat_siginfo_t are off:
    
    - nat_siginfo_t's _pad field's definition is:
    
       int _pad[((128 / sizeof (int)) - 4)];
    
      while /usr/include/bits/siginfo.h has:
    
       # define __SI_MAX_SIZE     128
       # if __WORDSIZE == 64
       #  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 4)
       # else
       #  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 3)
       # endif
    
      and __WORDSIZE == 32 for x32.  This is what causes the size of
      nat_siginfo_t to be wrong and the assertion to fail.
    
    - the nat_clock_t type is incorrect for 64-bit.  We have this:
    
       /* For native 64-bit, clock_t in _sigchld is 64bit aligned at 4 bytes.  */
       typedef long __attribute__ ((__aligned__ (4))) nat_clock_t;
    
      however, /usr/include/bits/siginfo.h has:
    
       # if defined __x86_64__ && __WORDSIZE == 32
       /* si_utime and si_stime must be 4 byte aligned for x32 to match the
          kernel.  We align siginfo_t to 8 bytes so that si_utime and si_stime
          are actually aligned to 8 bytes since their offsets are multiple of
          8 bytes.  */
       typedef __clock_t __attribute__ ((__aligned__ (4))) __sigchld_clock_t;
       #  define __SI_ALIGNMENT __attribute__ ((__aligned__ (8)))
       # else
       typedef __clock_t __sigchld_clock_t;
       #  define __SI_ALIGNMENT
       # endif
    
      So we're currently forcing 4-byte alignment on clock_t, when it
      should only be so for x32, not 64-bit.
    
    The fix:
    
     - Leaves nat_siginfo_t strictly for the 64-bit ABI.
    
     - Adds a new typedef for the siginfo type that ptrace uses
       (ptrace_siginfo_t).  An x32 gdb always gets/sets an x32 siginfo_t
       type with PTRACE_GETSIGINFO/PTRACE_SETSIGINFO.
    
     - Uses this new ptrace_siginfo_t type instead of nat_siginfo_t as the
       intermediate conversion type.
    
    gdb/ChangeLog:
    2016-07-26  Pedro Alves  <palves@redhat.com>
    
    	* amd64-linux-nat.c (amd64_linux_siginfo_fixup): Rename 'native'
    	parameter to 'ptrace'.
    	* nat/amd64-linux-siginfo.c (GDB_SI_SIZE): New define.
    	(nat_uptr_t): New an unsigned long.
    	(nat_clock_t): Remove attribute __aligned__.
    	(struct nat_timeval): Delete.
    	(nat_siginfo_t): Remove attribute __aligned__.
    	(ptrace_siginfo_t): Define.
    	(compat_siginfo_from_siginfo, siginfo_from_compat_siginfo)
    	(compat_x32_siginfo_from_siginfo)
    	(siginfo_from_compat_x32_siginfo): Make 'from' parameter const.
    	Convert through a ptrace_siginfo_t instead of a nat_siginfo_t.
    	Remove casts.
    	(amd64_linux_siginfo_fixup_common): Rename 'native' parameter to
    	'ptrace'.  Remove static assertions.
    	(top level): New static assertions.
    
    gdb/gdbserver/ChangeLog:
    2016-07-26  Pedro Alves  <palves@redhat.com>
    
    	* linux-x86-low.c (x86_siginfo_fixup): Rename 'native' parameter
    	to 'ptrace'.
Comment 51 Pedro Alves 2016-07-26 18:41:45 UTC
Fixed in master.
Comment 52 Pedro Alves 2016-07-26 19:27:23 UTC
(In reply to hmb from comment #46)

> and gives segmentation fault during debugging even on single instruction
> step command.

Filed Bug 20414 for this one.
Comment 53 Pedro Alves 2016-07-26 21:25:54 UTC
All fixed.  Please file separate bugs for further issues you may find.
Comment 54 hmb 2016-07-27 11:11:50 UTC
Thanks Pedro for doing that.