1
0
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:
Shenghou Ma 2014-05-31 01:09:48 -07:00
parent 3f66c0c07b
commit a68b9be935
5 changed files with 37 additions and 6 deletions

View 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)
}
}

View File

@ -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

View File

@ -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);
}

View File

@ -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;

View File

@ -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*);