mirror of
https://github.com/golang/go
synced 2024-11-19 16:54:44 -07:00
runtime: fix empty heap dump bug on windows.
Fixes #8119. LGTM=khr, rsc R=alex.brainman, khr, bradfitz, rsc CC=golang-codereviews https://golang.org/cl/93640044
This commit is contained in:
parent
3f66c0c07b
commit
a68b9be935
29
src/pkg/runtime/debug/heapdump_test.go
Normal file
29
src/pkg/runtime/debug/heapdump_test.go
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package debug
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWriteHeapDumpNonempty(t *testing.T) {
|
||||
f, err := ioutil.TempFile("", "heapdumptest")
|
||||
if err != nil {
|
||||
t.Fatalf("TempFile failed: %v", err)
|
||||
}
|
||||
defer os.Remove(f.Name())
|
||||
defer f.Close()
|
||||
WriteHeapDump(f.Fd())
|
||||
fi, err := f.Stat()
|
||||
if err != nil {
|
||||
t.Fatalf("Stat failed: %v", err)
|
||||
}
|
||||
const minSize = 1
|
||||
if size := fi.Size(); size < minSize {
|
||||
t.Fatalf("Heap dump size %d bytes, expected at least %d bytes", size, minSize)
|
||||
}
|
||||
}
|
@ -394,9 +394,9 @@ runtime·read(int32 fd, void *buf, int32 nbytes)
|
||||
}
|
||||
|
||||
int32
|
||||
runtime·write(int32 fd, void *buf, int32 nbytes)
|
||||
runtime·write(uintptr fd, void *buf, int32 nbytes)
|
||||
{
|
||||
return runtime·pwrite(fd, buf, nbytes, -1LL);
|
||||
return runtime·pwrite((int32)fd, buf, nbytes, -1LL);
|
||||
}
|
||||
|
||||
uintptr
|
||||
|
@ -570,7 +570,7 @@ runtime·usleep(uint32 us)
|
||||
}
|
||||
|
||||
int32
|
||||
runtime·write(int32 fd, void* buf, int32 nbyte)
|
||||
runtime·write(uintptr fd, void* buf, int32 nbyte)
|
||||
{
|
||||
return runtime·sysvicall6(libc·write, 3, (uintptr)fd, (uintptr)buf, (uintptr)nbyte);
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ runtime·exit(int32 code)
|
||||
}
|
||||
|
||||
int32
|
||||
runtime·write(int32 fd, void *buf, int32 n)
|
||||
runtime·write(uintptr fd, void *buf, int32 n)
|
||||
{
|
||||
void *handle;
|
||||
uint32 written;
|
||||
@ -180,7 +180,9 @@ runtime·write(int32 fd, void *buf, int32 n)
|
||||
handle = runtime·stdcall(runtime·GetStdHandle, 1, (uintptr)-12);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
// assume fd is real windows handle.
|
||||
handle = (void*)fd;
|
||||
break;
|
||||
}
|
||||
runtime·stdcall(runtime·WriteFile, 5, handle, buf, (uintptr)n, &written, (uintptr)0);
|
||||
return written;
|
||||
|
@ -838,7 +838,7 @@ int32 runtime·gotraceback(bool *crash);
|
||||
void runtime·goroutineheader(G*);
|
||||
int32 runtime·open(int8*, int32, int32);
|
||||
int32 runtime·read(int32, void*, int32);
|
||||
int32 runtime·write(int32, void*, int32);
|
||||
int32 runtime·write(uintptr, void*, int32); // use uintptr to accommodate windows.
|
||||
int32 runtime·close(int32);
|
||||
int32 runtime·mincore(void*, uintptr, byte*);
|
||||
void runtime·jmpdefer(FuncVal*, void*);
|
||||
|
Loading…
Reference in New Issue
Block a user