public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* libgo patch committed: Fix ptrace implementation on MIPS
@ 2017-06-21 21:42 Ian Lance Taylor
  2017-06-22  7:55 ` Andreas Schwab
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Lance Taylor @ 2017-06-21 21:42 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 254 bytes --]

This patch from James Cowgill fixes the libgo ptrace implementation
for MIPS by modifying mksysinfo.sh to look for the pt_regs struct.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu, which
admittedly proves little.  Committed to mainline.

Ian

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3846 bytes --]

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 249208)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-6449e2832eef94eacf89c88fa16bede637f729ba
+b2bebba1f8a8185546c47f8460a3d5c2e31d0434
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/configure.ac
===================================================================
--- libgo/configure.ac	(revision 249205)
+++ libgo/configure.ac	(working copy)
@@ -580,7 +580,7 @@ AC_C_BIGENDIAN
 
 GCC_CHECK_UNWIND_GETIPINFO
 
-AC_CHECK_HEADERS(port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/reboot.h netinet/icmp6.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h)
+AC_CHECK_HEADERS(port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/icmp6.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h)
 
 AC_CHECK_HEADERS([linux/filter.h linux/if_addr.h linux/if_ether.h linux/if_tun.h linux/netlink.h linux/rtnetlink.h], [], [],
 [#ifdef HAVE_SYS_SOCKET_H
Index: libgo/go/syscall/syscall_linux_mipsx.go
===================================================================
--- libgo/go/syscall/syscall_linux_mipsx.go	(revision 249205)
+++ libgo/go/syscall/syscall_linux_mipsx.go	(working copy)
@@ -3,10 +3,24 @@
 // license that can be found in the LICENSE file.
 
 // +build linux
-// +build mips mipsle
+// +build mips mipsle mips64 mips64le mips64p32 mips64p32le
 
 package syscall
 
-func (r *PtraceRegs) PC() uint64 { return uint64(r.Regs[64]) }
+import "unsafe"
 
-func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = uint32(pc) }
+func (r *PtraceRegs) PC() uint64 {
+	return r.Cp0_epc
+}
+
+func (r *PtraceRegs) SetPC(pc uint64) {
+	r.Cp0_epc = pc
+}
+
+func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
+	return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
+}
+
+func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) {
+	return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
+}
Index: libgo/mksysinfo.sh
===================================================================
--- libgo/mksysinfo.sh	(revision 249205)
+++ libgo/mksysinfo.sh	(working copy)
@@ -317,9 +317,13 @@ if test "$regs" = ""; then
     upcase_fields "__user_psw_struct" "PtracePsw" >> ${OUT} || true
     upcase_fields "__user_fpregs_struct" "PtraceFpregs" >> ${OUT} || true
     upcase_fields "__user_per_struct" "PtracePer" >> ${OUT} || true
+  else
+    # mips*
+    regs=`grep '^type _pt_regs struct' gen-sysinfo.go || true`
   fi
 fi
 if test "$regs" != ""; then
+  regs=`echo $regs | sed -e 's/type _pt_regs struct//'`
   regs=`echo $regs |
     sed -e 's/type __*user_regs_struct struct //' -e 's/[{}]//g'`
   regs=`echo $regs | sed -e s'/^ *//'`
Index: libgo/sysinfo.c
===================================================================
--- libgo/sysinfo.c	(revision 249205)
+++ libgo/sysinfo.c	(working copy)
@@ -102,6 +102,9 @@
 #if defined(HAVE_LINUX_NETLINK_H)
 #include <linux/netlink.h>
 #endif
+#if defined(HAVE_LINUX_PTRACE_H)
+#include <linux/ptrace.h>
+#endif
 #if defined(HAVE_LINUX_RTNETLINK_H)
 #include <linux/rtnetlink.h>
 #endif

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: libgo patch committed: Fix ptrace implementation on MIPS
  2017-06-21 21:42 libgo patch committed: Fix ptrace implementation on MIPS Ian Lance Taylor
@ 2017-06-22  7:55 ` Andreas Schwab
  2017-06-22 19:59   ` Ian Lance Taylor
  0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2017-06-22  7:55 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-patches, gofrontend-dev

On Jun 21 2017, Ian Lance Taylor <iant@golang.org> wrote:

> Index: libgo/sysinfo.c
> ===================================================================
> --- libgo/sysinfo.c	(revision 249205)
> +++ libgo/sysinfo.c	(working copy)
> @@ -102,6 +102,9 @@
>  #if defined(HAVE_LINUX_NETLINK_H)
>  #include <linux/netlink.h>
>  #endif
> +#if defined(HAVE_LINUX_PTRACE_H)
> +#include <linux/ptrace.h>
> +#endif
>  #if defined(HAVE_LINUX_RTNETLINK_H)
>  #include <linux/rtnetlink.h>
>  #endif

That breaks ia64:

In file included from /usr/include/asm/ptrace.h:58:0,
                 from /usr/include/linux/ptrace.h:69,
                 from ../../../libgo/sysinfo.c:106:
/usr/include/asm/fpu.h:57:8: error: redefinition of 'struct ia64_fpreg'
 struct ia64_fpreg {
        ^~~~~~~~~~
In file included from /usr/include/signal.h:339:0,
                 from /usr/local/gcc/gcc-20170622/Build/gcc/include-fixed/sys/ucontext.h:32,
                 from /usr/include/ucontext.h:27,
                 from ../../../libgo/sysinfo.c:17:
/usr/include/bits/sigcontext.h:32:8: note: originally defined here
 struct ia64_fpreg
        ^~~~~~~~~~
In file included from /usr/include/linux/ptrace.h:69:0,
                 from ../../../libgo/sysinfo.c:106:
/usr/include/asm/ptrace.h:208:8: error: redefinition of 'struct pt_all_user_regs'
 struct pt_all_user_regs {
        ^~~~~~~~~~~~~~~~
In file included from ../../../libgo/sysinfo.c:66:0:
/usr/include/sys/ptrace.h:116:8: note: originally defined here
 struct pt_all_user_regs
        ^~~~~~~~~~~~~~~~

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: libgo patch committed: Fix ptrace implementation on MIPS
  2017-06-22  7:55 ` Andreas Schwab
@ 2017-06-22 19:59   ` Ian Lance Taylor
  2017-06-23  9:34     ` James Cowgill
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Lance Taylor @ 2017-06-22 19:59 UTC (permalink / raw)
  To: James Cowgill; +Cc: gcc-patches, gofrontend-dev, Andreas Schwab

James, any thoughts?

Ian

On Thu, Jun 22, 2017 at 12:55 AM, Andreas Schwab <schwab@suse.de> wrote:
> On Jun 21 2017, Ian Lance Taylor <iant@golang.org> wrote:
>
>> Index: libgo/sysinfo.c
>> ===================================================================
>> --- libgo/sysinfo.c   (revision 249205)
>> +++ libgo/sysinfo.c   (working copy)
>> @@ -102,6 +102,9 @@
>>  #if defined(HAVE_LINUX_NETLINK_H)
>>  #include <linux/netlink.h>
>>  #endif
>> +#if defined(HAVE_LINUX_PTRACE_H)
>> +#include <linux/ptrace.h>
>> +#endif
>>  #if defined(HAVE_LINUX_RTNETLINK_H)
>>  #include <linux/rtnetlink.h>
>>  #endif
>
> That breaks ia64:
>
> In file included from /usr/include/asm/ptrace.h:58:0,
>                  from /usr/include/linux/ptrace.h:69,
>                  from ../../../libgo/sysinfo.c:106:
> /usr/include/asm/fpu.h:57:8: error: redefinition of 'struct ia64_fpreg'
>  struct ia64_fpreg {
>         ^~~~~~~~~~
> In file included from /usr/include/signal.h:339:0,
>                  from /usr/local/gcc/gcc-20170622/Build/gcc/include-fixed/sys/ucontext.h:32,
>                  from /usr/include/ucontext.h:27,
>                  from ../../../libgo/sysinfo.c:17:
> /usr/include/bits/sigcontext.h:32:8: note: originally defined here
>  struct ia64_fpreg
>         ^~~~~~~~~~
> In file included from /usr/include/linux/ptrace.h:69:0,
>                  from ../../../libgo/sysinfo.c:106:
> /usr/include/asm/ptrace.h:208:8: error: redefinition of 'struct pt_all_user_regs'
>  struct pt_all_user_regs {
>         ^~~~~~~~~~~~~~~~
> In file included from ../../../libgo/sysinfo.c:66:0:
> /usr/include/sys/ptrace.h:116:8: note: originally defined here
>  struct pt_all_user_regs
>         ^~~~~~~~~~~~~~~~
>
> Andreas.
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: libgo patch committed: Fix ptrace implementation on MIPS
  2017-06-22 19:59   ` Ian Lance Taylor
@ 2017-06-23  9:34     ` James Cowgill
  2017-06-23 13:52       ` Ian Lance Taylor
  0 siblings, 1 reply; 7+ messages in thread
From: James Cowgill @ 2017-06-23  9:34 UTC (permalink / raw)
  To: Ian Lance Taylor, Andreas Schwab; +Cc: gcc-patches, gofrontend-dev


[-- Attachment #1.1: Type: text/plain, Size: 1976 bytes --]

Hi,

On 22/06/17 20:59, Ian Lance Taylor wrote:
> James, any thoughts?
> 
> Ian
> 
> On Thu, Jun 22, 2017 at 12:55 AM, Andreas Schwab <schwab@suse.de> wrote:
>> On Jun 21 2017, Ian Lance Taylor <iant@golang.org> wrote:
>>
>>> Index: libgo/sysinfo.c
>>> ===================================================================
>>> --- libgo/sysinfo.c   (revision 249205)
>>> +++ libgo/sysinfo.c   (working copy)
>>> @@ -102,6 +102,9 @@
>>>  #if defined(HAVE_LINUX_NETLINK_H)
>>>  #include <linux/netlink.h>
>>>  #endif
>>> +#if defined(HAVE_LINUX_PTRACE_H)
>>> +#include <linux/ptrace.h>
>>> +#endif
>>>  #if defined(HAVE_LINUX_RTNETLINK_H)
>>>  #include <linux/rtnetlink.h>
>>>  #endif
>>
>> That breaks ia64:
>>
>> In file included from /usr/include/asm/ptrace.h:58:0,
>>                  from /usr/include/linux/ptrace.h:69,
>>                  from ../../../libgo/sysinfo.c:106:
>> /usr/include/asm/fpu.h:57:8: error: redefinition of 'struct ia64_fpreg'
>>  struct ia64_fpreg {
>>         ^~~~~~~~~~
>> In file included from /usr/include/signal.h:339:0,
>>                  from /usr/local/gcc/gcc-20170622/Build/gcc/include-fixed/sys/ucontext.h:32,
>>                  from /usr/include/ucontext.h:27,
>>                  from ../../../libgo/sysinfo.c:17:
>> /usr/include/bits/sigcontext.h:32:8: note: originally defined here
>>  struct ia64_fpreg
>>         ^~~~~~~~~~
>> In file included from /usr/include/linux/ptrace.h:69:0,
>>                  from ../../../libgo/sysinfo.c:106:
>> /usr/include/asm/ptrace.h:208:8: error: redefinition of 'struct pt_all_user_regs'
>>  struct pt_all_user_regs {
>>         ^~~~~~~~~~~~~~~~
>> In file included from ../../../libgo/sysinfo.c:66:0:
>> /usr/include/sys/ptrace.h:116:8: note: originally defined here
>>  struct pt_all_user_regs
>>         ^~~~~~~~~~~~~~~~

This looks like this glibc bug which was fixed in 2.19.
https://sourceware.org/bugzilla/show_bug.cgi?id=762

James


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: libgo patch committed: Fix ptrace implementation on MIPS
  2017-06-23  9:34     ` James Cowgill
@ 2017-06-23 13:52       ` Ian Lance Taylor
  2017-06-24  7:05         ` Andreas Schwab
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Lance Taylor @ 2017-06-23 13:52 UTC (permalink / raw)
  To: James Cowgill; +Cc: Andreas Schwab, gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 2156 bytes --]

On Fri, Jun 23, 2017 at 2:34 AM, James Cowgill <James.Cowgill@imgtec.com> wrote:
> Hi,
>
> On 22/06/17 20:59, Ian Lance Taylor wrote:
>> James, any thoughts?
>>
>> Ian
>>
>> On Thu, Jun 22, 2017 at 12:55 AM, Andreas Schwab <schwab@suse.de> wrote:
>>> On Jun 21 2017, Ian Lance Taylor <iant@golang.org> wrote:
>>>
>>>> Index: libgo/sysinfo.c
>>>> ===================================================================
>>>> --- libgo/sysinfo.c   (revision 249205)
>>>> +++ libgo/sysinfo.c   (working copy)
>>>> @@ -102,6 +102,9 @@
>>>>  #if defined(HAVE_LINUX_NETLINK_H)
>>>>  #include <linux/netlink.h>
>>>>  #endif
>>>> +#if defined(HAVE_LINUX_PTRACE_H)
>>>> +#include <linux/ptrace.h>
>>>> +#endif
>>>>  #if defined(HAVE_LINUX_RTNETLINK_H)
>>>>  #include <linux/rtnetlink.h>
>>>>  #endif
>>>
>>> That breaks ia64:
>>>
>>> In file included from /usr/include/asm/ptrace.h:58:0,
>>>                  from /usr/include/linux/ptrace.h:69,
>>>                  from ../../../libgo/sysinfo.c:106:
>>> /usr/include/asm/fpu.h:57:8: error: redefinition of 'struct ia64_fpreg'
>>>  struct ia64_fpreg {
>>>         ^~~~~~~~~~
>>> In file included from /usr/include/signal.h:339:0,
>>>                  from /usr/local/gcc/gcc-20170622/Build/gcc/include-fixed/sys/ucontext.h:32,
>>>                  from /usr/include/ucontext.h:27,
>>>                  from ../../../libgo/sysinfo.c:17:
>>> /usr/include/bits/sigcontext.h:32:8: note: originally defined here
>>>  struct ia64_fpreg
>>>         ^~~~~~~~~~
>>> In file included from /usr/include/linux/ptrace.h:69:0,
>>>                  from ../../../libgo/sysinfo.c:106:
>>> /usr/include/asm/ptrace.h:208:8: error: redefinition of 'struct pt_all_user_regs'
>>>  struct pt_all_user_regs {
>>>         ^~~~~~~~~~~~~~~~
>>> In file included from ../../../libgo/sysinfo.c:66:0:
>>> /usr/include/sys/ptrace.h:116:8: note: originally defined here
>>>  struct pt_all_user_regs
>>>         ^~~~~~~~~~~~~~~~
>
> This looks like this glibc bug which was fixed in 2.19.
> https://sourceware.org/bugzilla/show_bug.cgi?id=762

Thanks.

Andreas, can we avoid the problem for earlier glibc versions with a
patch like the appended?

Ian

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 436 bytes --]

diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
index a1afc7d1..80407443 100644
--- a/libgo/sysinfo.c
+++ b/libgo/sysinfo.c
@@ -38,7 +38,10 @@
 #if defined(HAVE_NETINET_IF_ETHER_H)
 #include <netinet/if_ether.h>
 #endif
+/* Avoid https://sourceware.org/bugzilla/show_bug.cgi?id=762 .  */
+#define ia64_fpreg pt_ia64_fpreg
 #include <signal.h>
+#undef ia64_fpreg
 #include <sys/ioctl.h>
 #include <termios.h>
 #if defined(HAVE_SYSCALL_H)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: libgo patch committed: Fix ptrace implementation on MIPS
  2017-06-23 13:52       ` Ian Lance Taylor
@ 2017-06-24  7:05         ` Andreas Schwab
  2017-06-26 17:56           ` Ian Lance Taylor
  0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2017-06-24  7:05 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: James Cowgill, gcc-patches, gofrontend-dev

On Jun 23 2017, Ian Lance Taylor <iant@golang.org> wrote:

> Andreas, can we avoid the problem for earlier glibc versions with a
> patch like the appended?
>
> Ian
>
> diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
> index a1afc7d1..80407443 100644
> --- a/libgo/sysinfo.c
> +++ b/libgo/sysinfo.c
> @@ -38,7 +38,10 @@
>  #if defined(HAVE_NETINET_IF_ETHER_H)
>  #include <netinet/if_ether.h>
>  #endif
> +/* Avoid https://sourceware.org/bugzilla/show_bug.cgi?id=762 .  */
> +#define ia64_fpreg pt_ia64_fpreg
>  #include <signal.h>
> +#undef ia64_fpreg

That doesn't work, but this does:

diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
index a1afc7d119c..1ba27b1a093 100644
--- a/libgo/sysinfo.c
+++ b/libgo/sysinfo.c
@@ -103,7 +103,12 @@
 #include <linux/netlink.h>
 #endif
 #if defined(HAVE_LINUX_PTRACE_H)
+/* Avoid https://sourceware.org/bugzilla/show_bug.cgi?id=762 .  */
+#define ia64_fpreg pt_ia64_fpreg
+#define pt_all_user_regs pt_ia64_all_user_regs
 #include <linux/ptrace.h>
+#undef ia64_fpreg
+#undef pt_all_user_regs
 #endif
 #if defined(HAVE_LINUX_RTNETLINK_H)
 #include <linux/rtnetlink.h>

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: libgo patch committed: Fix ptrace implementation on MIPS
  2017-06-24  7:05         ` Andreas Schwab
@ 2017-06-26 17:56           ` Ian Lance Taylor
  0 siblings, 0 replies; 7+ messages in thread
From: Ian Lance Taylor @ 2017-06-26 17:56 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: James Cowgill, gcc-patches, gofrontend-dev

On Sat, Jun 24, 2017 at 12:04 AM, Andreas Schwab <schwab@suse.de> wrote:
> On Jun 23 2017, Ian Lance Taylor <iant@golang.org> wrote:
>
>> Andreas, can we avoid the problem for earlier glibc versions with a
>> patch like the appended?
>>
>> Ian
>>
>> diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
>> index a1afc7d1..80407443 100644
>> --- a/libgo/sysinfo.c
>> +++ b/libgo/sysinfo.c
>> @@ -38,7 +38,10 @@
>>  #if defined(HAVE_NETINET_IF_ETHER_H)
>>  #include <netinet/if_ether.h>
>>  #endif
>> +/* Avoid https://sourceware.org/bugzilla/show_bug.cgi?id=762 .  */
>> +#define ia64_fpreg pt_ia64_fpreg
>>  #include <signal.h>
>> +#undef ia64_fpreg
>
> That doesn't work, but this does:
>
> diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
> index a1afc7d119c..1ba27b1a093 100644
> --- a/libgo/sysinfo.c
> +++ b/libgo/sysinfo.c
> @@ -103,7 +103,12 @@
>  #include <linux/netlink.h>
>  #endif
>  #if defined(HAVE_LINUX_PTRACE_H)
> +/* Avoid https://sourceware.org/bugzilla/show_bug.cgi?id=762 .  */
> +#define ia64_fpreg pt_ia64_fpreg
> +#define pt_all_user_regs pt_ia64_all_user_regs
>  #include <linux/ptrace.h>
> +#undef ia64_fpreg
> +#undef pt_all_user_regs
>  #endif
>  #if defined(HAVE_LINUX_RTNETLINK_H)
>  #include <linux/rtnetlink.h>


Thanks.

Committed to mainline.

Ian

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-06-26 17:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-21 21:42 libgo patch committed: Fix ptrace implementation on MIPS Ian Lance Taylor
2017-06-22  7:55 ` Andreas Schwab
2017-06-22 19:59   ` Ian Lance Taylor
2017-06-23  9:34     ` James Cowgill
2017-06-23 13:52       ` Ian Lance Taylor
2017-06-24  7:05         ` Andreas Schwab
2017-06-26 17:56           ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).