aboutsummaryrefslogtreecommitdiff
path: root/libgo
AgeCommit message (Collapse)AuthorFilesLines
2017-08-18misc/cgo/test: make cgo tests run on AIXIan Lance Taylor2-1/+3
Reviewed-on: https://go-review.googlesource.com/56910 From-SVN: r251182
2017-08-18cmd/go: pass -funwind-tables when compiling C codeIan Lance Taylor1-0/+6
Using -funwind-tables is necessary to permit Go code to correctly throw a panic through C code. This hasn't been necessary in the past as -funwind-tables is the default on x86. However, it is not the default for PPC AIX. Reviewed-on: https://go-review.googlesource.com/56650 From-SVN: r251179
2017-08-16runtime: better implementation of netpoll for AIXIan Lance Taylor1-65/+96
Reviewed-on: https://go-review.googlesource.com/54170 From-SVN: r251133
2017-08-16runtime: improvements for signal registersIan Lance Taylor1-13/+49
Fix dumpregs on i386, implement dumpregs for PPC Linux/AIX, get PC on AIX. Reviewed-on: https://go-review.googlesource.com/56170 From-SVN: r251127
2017-08-09compiler: handle >32bit exponent in LdexpIan Lance Taylor1-2/+7
Libgo's implementation of math.Ldexp declared the libc "ldexp" as taking an 'int' exponent argument, which is not quite right for 64-bit platforms (exp arg is always int32); this could yield incorrect results for exponent values outside the range of Minint32/Maxint32. Fix by upating the type for the libc version of ldexp, and adding guards to screen for out-of-range exponents. Fixes #21323. Reviewed-on: https://go-review.googlesource.com/54250 From-SVN: r250992
2017-08-04runtime: dump registers for AlphaIan Lance Taylor1-0/+41
Patch from Uros Bizjak. Reviewed-on: https://go-review.googlesource.com/53350 From-SVN: r250873
2017-08-03re PR go/81617 (mksigtab.sh fails to resolve NSIG with glibc 2.26)Ian Lance Taylor1-0/+13
PR go/81617 libgo: change mksigtab to recognize glibc 2.26 NSIG expression Fixes golang/go#21147 Fixes GCC PR 81617 Reviewed-on: https://go-review.googlesource.com/52611 From-SVN: r250858
2017-07-26runtime: handle Alpha GNU/Linux in getSiginfoIan Lance Taylor1-0/+5
Patch by Uros Bizjak. Reviewed-on: https://go-review.googlesource.com/51370 From-SVN: r250588
2017-07-21syscall: call f?statfs64 on GNU/LinuxIan Lance Taylor1-2/+2
We unconditionally set _FILE_OFFSET_BITS to 64 in configure.ac, so we should unconditionally call the statfs64 and fstatfs64 functions. These functions should be available on all versions of GNU/Linux since 2.6. On 64-bit systems they are aliased to statfs/fstatfs, and on 32-bit systems they use the 64-bit data structures. Fixes golang/go#20922 Reviewed-on: https://go-review.googlesource.com/50635 From-SVN: r250443
2017-07-21runtime: don't use runtime_lock in __go_get_backtrace_stateIan Lance Taylor1-3/+11
If getSiginfo does not know how to determine the PC, it will call runtime_callers. That can happen in a thread that was started by non-Go code, in which case the TLS variable g will not be set, in which case runtime_lock will crash. Avoid the problem by using atomic operations for the lock. This is OK since creating a backtrace state is fast and never blocks. The test case is TestCgoExternalThreadSIGPROF in the runtime package on a system that getSiginfo doesn't handle specially. Updates golang/go#20931 Reviewed-on: https://go-review.googlesource.com/50650 From-SVN: r250439
2017-07-21runtime: handle PPC/PPC64 GNU/Linux in getSiginfoIan Lance Taylor1-0/+5
Updates golang/go#20931 Reviewed-on: https://go-review.googlesource.com/50631 From-SVN: r250436
2017-07-21runtime: allocate more stack space in CgoCallbackGC testIan Lance Taylor1-1/+3
Allocate enough stack space so that the test will work on a system that does not support split stacks. This test is actually not very meaningful for gccgo at present, but it doesn't hurt to keep running it. Updates golang/go#20931 Reviewed-on: https://go-review.googlesource.com/50630 From-SVN: r250433
2017-07-18re PR go/81451 (missing futex check - libgo/runtime/thread-linux.c:12:0 ↵Ian Lance Taylor9-89/+19
futex.h:13:12: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘long’) PR go/81451 runtime: inline runtime_osinit We had two identical copies of runtime_osinit. They set runtime_ncpu, a variable that is no longer used. Removing that leaves us with two lines. Inline those two lines in the two places the function was called. This fixes GCC PR 81451. Reviewed-on: https://go-review.googlesource.com/48862 From-SVN: r250326
2017-07-18re PR go/81324 (libgo does not build with glibc 2.18)Ian Lance Taylor1-0/+4
PR go/81324 sysinfo.c: ignore ptrace_peeksiginfo_args from <linux/ptrace.h> With some versions of glibc and GNU/Linux ptrace_pseeksiginfo_args is defined in both <sys/ptrace.h> and <linux/ptrace.h>. We don't actually care about the struct, so use a #define to avoid a redefinition error. This fixes https://gcc.gnu.org/PR81324. Reviewed-on: https://go-review.googlesource.com/49290 From-SVN: r250324
2017-07-14libgo: don't copy semt into runtime.incIan Lance Taylor3-3/+7
https://gcc.gnu.org/PR81449 reports a problem with the definition semt in runtime.inc on some systems. Since the C code in libgo/runtime doesn't need semt, just don't copy it into runtime.inc. Reviewed-on: https://go-review.googlesource.com/48593 From-SVN: r250217
2017-07-14cmd/go: use gccSupportsFlag for -fsplit-stackIan Lance Taylor1-4/+2
Don't assume that all (or only) 386/amd64 compilers support -fsplit-stack. Reviewed-on: https://go-review.googlesource.com/48592 From-SVN: r250216
2017-07-13re PR go/81393 (Bootstrap failure on s390x-linux while building libgo ↵Ian Lance Taylor2-6/+45
against recent glibc) PR go/81393 syscall: don't use GETREGS/SETREGS on s390 They were removed in recent glibc. Patch by Andreas Krebbel for GCC PR 81393. Reviewed-on: https://go-review.googlesource.com/48231 From-SVN: r250174
2017-06-29misc/cgo/testcarchive: fix test to work for gccgoIan Lance Taylor2-10/+63
This test is not yet run, but it will be soon. Reviewed-on: https://go-review.googlesource.com/47038 From-SVN: r249795
2017-06-29cmd/go: fix -buildmode={c-archive,c-shared,pie} for gccgoIan Lance Taylor1-14/+24
The tests are misc/cgo tests that are not currently run but will be run soon. Reviewed-on: https://go-review.googlesource.com/47037 From-SVN: r249794
2017-06-27runtime: adapt memory management to AIX mmapIan Lance Taylor3-1/+17
On AIX: * mmap does not allow to map an already mapped range, * mmap range start at 0x30000000 for 32 bits processes, * mmap range start at 0x70000000_00000000 for 64 bits processes This is adapted from change 37845. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/46772 From-SVN: r249713
2017-06-27syscall: ptrace fixes for s390Ian Lance Taylor3-15/+6
Fixes required now that we #include <linux/ptrace.h> in sysinfo.c. Patch by Andreas Krebbel. Reviewed-on: https://go-review.googlesource.com/46839 From-SVN: r249712
2017-06-27libgo: add misc/cgo filesIan Lance Taylor269-0/+13743
Copy all the misc/cgo files from the gc toolchain into libgo/misc. These will be used for testing purposes by later changes to the gotools directory. Reviewed-on: https://go-review.googlesource.com/46721 From-SVN: r249674
2017-06-26syscall: don't define PtraceRegs for AlphaIan Lance Taylor1-32/+0
It's now defined by mksysinfo.sh. Patch by Uros Bizjak. Reviewed-on: https://go-review.googlesource.com/46712 From-SVN: r249663
2017-06-26libgo: redefine ia64 struct names around linux/ptrace.hIan Lance Taylor1-0/+5
Avoid https://sourceware.org/bugzilla/show_bug.cgi?id=762. Patch by Andreas Schwab. Reviewed-on: https://go-review.googlesource.com/46711 From-SVN: r249662
2017-06-23runtime: complete defer handling in CgocallBackDoneIan Lance Taylor2-10/+36
When C code calls a Go function, it actually calls a function generated by cgo. That function is written in Go, and, among other things, it calls the real Go function like this: CgocallBack() defer CgocallBackDone() RealGoFunction() The deferred CgocallBackDone function enters syscall mode as we return to C. Typically the C function will then eventually return to Go. However, in the case where the C function is running on a thread created in C, it will not return to Go. For that case we will have allocated an m struct, with an associated g struct, for the duration of the Go code, and when the Go is complete we will return the m and g to a free list. That all works, but we are running in a deferred function, which means that we have been invoked by deferreturn, and deferreturn expects to do a bit of cleanup to record that the defer has been completed. Doing that cleanup while using an m and g that have already been returned to the free list is clearly a bad idea. It was kind of working because deferreturn was holding the g pointer in a local variable, but there were races with some other thread picking up and using the newly freed g. It was also kind of working because of a special check in freedefer; that check is no longer necessary. This patch changes the special case of releasing the m and g to do the defer cleanup in CgocallBackDone itself. This patch also checks for the special case of a panic through CgocallBackDone. In that special case, we don't want to release the m and g. Since we are returning to C code that was not called by Go code, we know that the panic is not going to be caught and we are going to exit the program. So for that special case we keep the m and g structs so that the rest of the panic code can use them. Reviewed-on: https://go-review.googlesource.com/46530 From-SVN: r249611
2017-06-23cmd/go: don't require GOROOT to exist for gccgoIan Lance Taylor1-2/+7
Reviewed-on: https://go-review.googlesource.com/46590 From-SVN: r249609
2017-06-23os: align siginfo argument to waitidIan Lance Taylor1-1/+1
Backport https://golang.org/cl/46511 from gc trunk, as it may fix a bug reported for gccgo running on MIPS (https://groups.google.com/d/msg/golang-dev/sDg-t1_DPw0/-AJmLxgPBQAJ). Reviewed-on: https://go-review.googlesource.com/46571 From-SVN: r249599
2017-06-23runtime: don't crash if no p in kickoffIan Lance Taylor1-0/+18
The kickoff function for g0 can be invoked without a p, for example from mcall(exitsyscall0) in exitsyscall after exitsyscall has cleared the p field. The assignment gp.param = nil will invoke a write barrier. If gp.param is not already nil, this will require a p. Avoid the problem for a specific case that is known to be OK: when the value in gp.param is a *g. Reviewed-on: https://go-review.googlesource.com/46512 From-SVN: r249595
2017-06-23runtime: improve handling of panic during deferred functionIan Lance Taylor2-31/+85
When a panic occurs while processing a deferred function that recovered an earlier panic, we shouldn't report the recovered panic in the panic stack trace. Stop doing so by keeping track of the panic that triggered a defer, marking it as aborted if we see the defer again, and discarding aborted panics when a panic is recovered. This is what the gc runtime does. The test for this is TestRecursivePanic in runtime/crash_test.go. We don't run that test yet, but we will soon. Reviewed-on: https://go-review.googlesource.com/46461 From-SVN: r249590
2017-06-22runtime: uncomment check for gchelper on g0 stackIan Lance Taylor1-4/+3
Now that systemstack changes to the g0 stack, this check passes. Reviewed-on: https://go-review.googlesource.com/46460 From-SVN: r249578
2017-06-22runtime: mark dropm and callees nowritebarrierrecIan Lance Taylor3-0/+7
The CgocallbackDone function calls dropm after it calls entersyscall, which means that dropm must not have any write barriers. Mark it accordingly. Reviewed-on: https://go-review.googlesource.com/46464 From-SVN: r249577
2017-06-22runtime: export getm functionIan Lance Taylor1-0/+3
Use go:linkname to export the getm function. This makes it visible to runtime/testdata/testprogcgo/dropm_stub.go, which uses it as part of the TestEnsureDropM test in runtime/crash_cgo_test.go. That test is not run today, but it will be soon. Reviewed-on: https://go-review.googlesource.com/46462 From-SVN: r249576
2017-06-22runtime: fix type cast in assignment to gcnextsp in C codeIan Lance Taylor1-1/+1
Patch from Rainer Orth. Reviewed-on: https://go-review.googlesource.com/46459 From-SVN: r249575
2017-06-22runtime: make NumGoroutine wait for system goroutines to registerIan Lance Taylor5-0/+29
In libgo system goroutines register themselves after they start. That means that there is a small race between the goroutine being seen by the scheduler and the scheduler knowing that the goroutine is a system goroutine. That in turn means that runtime.NumGoroutines can overestimate the number of goroutines at times. This patch fixes the overestimate by counting the number of system goroutines waiting to start, and pausing NumGoroutines until those goroutines have all registered. This is kind of a lot of mechanism for this not very important problem, but I couldn't think of a better approach. The test for this is TestNumGoroutine in runtime/proc_test.go. The test is not currently run, but it will be soon. Reviewed-on: https://go-review.googlesource.com/46457 From-SVN: r249565
2017-06-22runtime: don't assume that _ = *s will panic if s is nilIan Lance Taylor2-4/+6
With the gc toolchain apparently var s *string _ = *s is enough to panic with a nil pointer dereference. The gccgo compiler will simply discard the dereference, which I think is a reasonable and acceptable optimization. Change the tests to use an exported variable instead. The tests are not currently run, but they will be with a later patch to gotools. Reviewed-on: https://go-review.googlesource.com/46450 From-SVN: r249562
2017-06-22runtime: change some stack fields to uintptrIan Lance Taylor4-26/+28
Because of how gccgo implements cgo calls, the code in dropm may not have any write barriers. As a step toward implementing that, change the gcstack, gcnextsegment, and gcnextsp fields of the g struct to uintptr, so that assignments to them do not require write barriers. The gcinitialsp field remains unsafe.Pointer, as on 32-bit systems that do not support split stack it points to a heap allocated space used for the goroutine stack. The test for this is runtime tests like TestCgoCallbackGC, which are not run today but will be run with a future gotools patch. Reviewed-on: https://go-review.googlesource.com/46396 From-SVN: r249561
2017-06-22runtime: avoid write barriers when calling deferred functionIan Lance Taylor1-4/+4
Calling a deferred function currently requires changing from a uintptr to the function code to a Go function value. That is done by setting the value of a func local variable using unsafe.Pointer. The local variable will always be on the stack. Adjust the code that sets the local variable to avoid generating a write barrier. A write barrier is never needed here. Also, for deferreturn, we must avoid write barriers entirely when called from a cgo function; that requires more than just this, but this is a start. The test for this is runtime tests that use the go tool; these are not currently run, but they will be in the future. Reviewed-on: https://go-review.googlesource.com/46455 From-SVN: r249559
2017-06-22runtime: rename _defer struct _panic field to panicStackIan Lance Taylor2-10/+10
The gc version of the _defer struct has a _panic field that has a completely different meaning. We are going to want that bring that new meaning into the gofrontend to improve panic reports with nested panic calls. Simplify that by first renaming the existing _panic field. Reviewed-on: https://go-review.googlesource.com/46454 From-SVN: r249558
2017-06-22runtime: adjust tests for gofrontendIan Lance Taylor3-3/+29
- don't run tests that depend on SetCgoTraceback - don't expect a '(' after the function name in a traceback - change the expected name of nested functions in a traceback These tests are not currently run, but they will be soon. Reviewed-on: https://go-review.googlesource.com/46453 From-SVN: r249557
2017-06-22runtime: don't build test files that use SetCgoTraceback for gccgoIan Lance Taylor6-0/+10
The gofrontend doesn't support the runtime.SetCgoTraceback function, which is specifically for handling mixed Go and C tracebacks. Use a build tag to avoid compiling the runtime/testdata/testprogcgo files that refer to SetCgoTraceback. These files are not currently compiled anyhow, but they will be with a future gotools patch. Reviewed-on: https://go-review.googlesource.com/46452 From-SVN: r249556
2017-06-22runtime: build testprogcgo with -pthreadIan Lance Taylor1-0/+3
Building this test with gccgo requires an explicit -pthread option to be passed to the C compiler, so that it links against -lpthread. This test is not built today, but it will be soon with a future patch. Reviewed-on: https://go-review.googlesource.com/46451 From-SVN: r249555
2017-06-22runtime: in traceback, print panic rather than runtime.gopanicIan Lance Taylor1-1/+5
The gc toolchain does the same thing, in gentraceback in runtime/traceback.go. The test for this is TestPanicTraceback in runtime/crash_test.go. We don't yet run that test, but we will in a future change. Reviewed-on: https://go-review.googlesource.com/46397 From-SVN: r249495
2017-06-22compiler, runtime: better stack trace for `go f()` where f is nilIan Lance Taylor1-1/+10
The test for this is TestGoNil in the runtime package, which we don't run yet but will run with a subsequent gotools patch. Updates golang/go#8045 Reviewed-on: https://go-review.googlesource.com/46392 From-SVN: r249494
2017-06-21debug/elf: handle Alpha relocsIan Lance Taylor1-0/+51
Patch by Uros Bizjak. Reviewed-on: https://go-review.googlesource.com/46391 From-SVN: r249487
2017-06-21Forgot to remove this file in the last libgo commit.Ian Lance Taylor1-11/+0
libgo: remove old MIPS architecture names This removes the old names for the 3 main MIPS ABIs: mipso32, mipsn32 and mipsn64. It also removes the mipso64 ABI which has no equivalent architecture name in go. This ABI has been dead for sometime and I doubt anyone will miss it. Change-Id: I087b243784edf6705fdaf9c32e3233da5e387283 From-SVN: r249485
2017-06-21libgo: remove old MIPS architecture namesIan Lance Taylor14-45/+18
This removes the old names for the 3 main MIPS ABIs: mipso32, mipsn32 and mipsn64. It also removes the mipso64 ABI which has no equivalent architecture name in go. This ABI has been dead for sometime and I doubt anyone will miss it. Reviewed-on: https://go-review.googlesource.com/46154 From-SVN: r249477
2017-06-21libgo: use gc's arch names as the default GOARCHs on MIPSIan Lance Taylor2-8/+10
This means that the gc tools and gofrontend agree on the architecture names for the 3 MIPS ABIs which should allow a gofrontend compiler to build go. Reviewed-on: https://go-review.googlesource.com/46153 From-SVN: r249476
2017-06-21cmd/cgo: add mips64p32* to ptrSizeMap and intSizeMapIan Lance Taylor1-42/+46
Reviewed-on: https://go-review.googlesource.com/46152 From-SVN: r249475
2017-06-21internal/syscall/unix: implement randomTrap on mips64p32*Ian Lance Taylor1-1/+1
Rename getrandom_linux_mipsn32.go to use the new architecture name for the n32 ABI and enable building it on mips64p32 and mips64p32le. Reviewed-on: https://go-review.googlesource.com/46151 From-SVN: r249474
2017-06-21libgo, syscall: fix ptrace implementation on MIPSIan Lance Taylor1-20/+0
On MIPS, the correct structure for PtraceRegs is 'struct pt_regs' which is declared in linux/ptrace.h. Previously no PtraceRegs structure was created on MIPS because 'struct user_regs_struct' doesn't exist there. Fallback to using pt_regs when the PtraceRegs structure is generated in mksysinfo.sh, then adjust syscall_linux_mipsx.go to read the program counter from the correct field. In addition, implement PtraceGetRegs and PtraceSetRegs on all 3 ABI variants. syscall_linux_mips64x.go can now be removed since the ptrace code on all 3 ABIs is identical. Reviewed-on: https://go-review.googlesource.com/46150 From-SVN: r249473