diff options
| author | Ondřej Surý <ondrej@sury.org> | 2011-04-26 09:55:32 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2011-04-26 09:55:32 +0200 |
| commit | 7b15ed9ef455b6b66c6b376898a88aef5d6a9970 (patch) | |
| tree | 3ef530baa80cdf29436ba981f5783be6b4d2202b /src/pkg/debug | |
| parent | 50104cc32a498f7517a51c8dc93106c51c7a54b4 (diff) | |
| download | golang-7b15ed9ef455b6b66c6b376898a88aef5d6a9970.tar.gz | |
Imported Upstream version 2011.04.13upstream/2011.04.13
Diffstat (limited to 'src/pkg/debug')
| -rw-r--r-- | src/pkg/debug/elf/file.go | 8 | ||||
| -rw-r--r-- | src/pkg/debug/gosym/Makefile | 6 | ||||
| -rw-r--r-- | src/pkg/debug/gosym/pclntab_test.go | 3 | ||||
| -rw-r--r-- | src/pkg/debug/macho/file.go | 2 | ||||
| -rw-r--r-- | src/pkg/debug/pe/file.go | 10 | ||||
| -rw-r--r-- | src/pkg/debug/proc/proc_darwin.go | 2 | ||||
| -rw-r--r-- | src/pkg/debug/proc/proc_freebsd.go | 2 | ||||
| -rw-r--r-- | src/pkg/debug/proc/proc_linux.go | 20 | ||||
| -rw-r--r-- | src/pkg/debug/proc/proc_windows.go | 2 |
9 files changed, 32 insertions, 23 deletions
diff --git a/src/pkg/debug/elf/file.go b/src/pkg/debug/elf/file.go index e69317a75..6fdcda6d4 100644 --- a/src/pkg/debug/elf/file.go +++ b/src/pkg/debug/elf/file.go @@ -144,7 +144,7 @@ func (e *FormatError) String() string { // Open opens the named file using os.Open and prepares it for use as an ELF binary. func Open(name string) (*File, os.Error) { - f, err := os.Open(name, os.O_RDONLY, 0) + f, err := os.Open(name) if err != nil { return nil, err } @@ -228,7 +228,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) { switch f.Class { case ELFCLASS32: hdr := new(Header32) - sr.Seek(0, 0) + sr.Seek(0, os.SEEK_SET) if err := binary.Read(sr, f.ByteOrder, hdr); err != nil { return nil, err } @@ -243,7 +243,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) { shstrndx = int(hdr.Shstrndx) case ELFCLASS64: hdr := new(Header64) - sr.Seek(0, 0) + sr.Seek(0, os.SEEK_SET) if err := binary.Read(sr, f.ByteOrder, hdr); err != nil { return nil, err } @@ -269,7 +269,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) { names := make([]uint32, shnum) for i := 0; i < shnum; i++ { off := shoff + int64(i)*int64(shentsize) - sr.Seek(off, 0) + sr.Seek(off, os.SEEK_SET) s := new(Section) switch f.Class { case ELFCLASS32: diff --git a/src/pkg/debug/gosym/Makefile b/src/pkg/debug/gosym/Makefile index 3c0d8c440..4f420e729 100644 --- a/src/pkg/debug/gosym/Makefile +++ b/src/pkg/debug/gosym/Makefile @@ -11,3 +11,9 @@ GOFILES=\ include ../../../Make.pkg +test: make-pclinetest + +testshort: make-pclinetest + +make-pclinetest: + @if [ "`uname`-`uname -m`" = Linux-x86_64 -a $(GOARCH) = amd64 ]; then mkdir -p _test && $(AS) pclinetest.s && $(LD) -E main -o _test/pclinetest pclinetest.$O; fi diff --git a/src/pkg/debug/gosym/pclntab_test.go b/src/pkg/debug/gosym/pclntab_test.go index 908702173..c83e64eab 100644 --- a/src/pkg/debug/gosym/pclntab_test.go +++ b/src/pkg/debug/gosym/pclntab_test.go @@ -143,9 +143,6 @@ func TestLineAline(t *testing.T) { } } -// gotest: if [ "$(uname)-$(uname -m)" = Linux-x86_64 -a "$GOARCH" = amd64 ]; then -// gotest: mkdir -p _test && $AS pclinetest.s && $LD -E main -o _test/pclinetest pclinetest.$O -// gotest: fi func TestPCLine(t *testing.T) { if !dotest() { return diff --git a/src/pkg/debug/macho/file.go b/src/pkg/debug/macho/file.go index fd8da9449..a777d873c 100644 --- a/src/pkg/debug/macho/file.go +++ b/src/pkg/debug/macho/file.go @@ -159,7 +159,7 @@ func (e *FormatError) String() string { // Open opens the named file using os.Open and prepares it for use as a Mach-O binary. func Open(name string) (*File, os.Error) { - f, err := os.Open(name, os.O_RDONLY, 0) + f, err := os.Open(name) if err != nil { return nil, err } diff --git a/src/pkg/debug/pe/file.go b/src/pkg/debug/pe/file.go index 1bcbdc5e9..6a14e50f9 100644 --- a/src/pkg/debug/pe/file.go +++ b/src/pkg/debug/pe/file.go @@ -87,7 +87,7 @@ func (e *FormatError) String() string { // Open opens the named file using os.Open and prepares it for use as a PE binary. func Open(name string) (*File, os.Error) { - f, err := os.Open(name, os.O_RDONLY, 0) + f, err := os.Open(name) if err != nil { return nil, err } @@ -132,7 +132,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) { } else { base = int64(0) } - sr.Seek(base, 0) + sr.Seek(base, os.SEEK_SET) if err := binary.Read(sr, binary.LittleEndian, &f.FileHeader); err != nil { return nil, err } @@ -140,7 +140,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) { return nil, os.NewError("Invalid PE File Format.") } // get symbol string table - sr.Seek(int64(f.FileHeader.PointerToSymbolTable+18*f.FileHeader.NumberOfSymbols), 0) + sr.Seek(int64(f.FileHeader.PointerToSymbolTable+18*f.FileHeader.NumberOfSymbols), os.SEEK_SET) var l uint32 if err := binary.Read(sr, binary.LittleEndian, &l); err != nil { return nil, err @@ -149,9 +149,9 @@ func NewFile(r io.ReaderAt) (*File, os.Error) { if _, err := r.ReadAt(ss, int64(f.FileHeader.PointerToSymbolTable+18*f.FileHeader.NumberOfSymbols)); err != nil { return nil, err } - sr.Seek(base, 0) + sr.Seek(base, os.SEEK_SET) binary.Read(sr, binary.LittleEndian, &f.FileHeader) - sr.Seek(int64(f.FileHeader.SizeOfOptionalHeader), 1) //Skip OptionalHeader + sr.Seek(int64(f.FileHeader.SizeOfOptionalHeader), os.SEEK_CUR) //Skip OptionalHeader f.Sections = make([]*Section, f.FileHeader.NumberOfSections) for i := 0; i < int(f.FileHeader.NumberOfSections); i++ { sh := new(SectionHeader32) diff --git a/src/pkg/debug/proc/proc_darwin.go b/src/pkg/debug/proc/proc_darwin.go index 7caf3a21a..49f0a5361 100644 --- a/src/pkg/debug/proc/proc_darwin.go +++ b/src/pkg/debug/proc/proc_darwin.go @@ -12,6 +12,6 @@ func Attach(pid int) (Process, os.Error) { return nil, os.NewError("debug/proc not implemented on OS X") } -func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*os.File) (Process, os.Error) { +func StartProcess(argv0 string, argv []string, attr *os.ProcAttr) (Process, os.Error) { return Attach(0) } diff --git a/src/pkg/debug/proc/proc_freebsd.go b/src/pkg/debug/proc/proc_freebsd.go index f6474ce80..4df07c365 100644 --- a/src/pkg/debug/proc/proc_freebsd.go +++ b/src/pkg/debug/proc/proc_freebsd.go @@ -12,6 +12,6 @@ func Attach(pid int) (Process, os.Error) { return nil, os.NewError("debug/proc not implemented on FreeBSD") } -func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*os.File) (Process, os.Error) { +func StartProcess(argv0 string, argv []string, attr *os.ProcAttr) (Process, os.Error) { return Attach(0) } diff --git a/src/pkg/debug/proc/proc_linux.go b/src/pkg/debug/proc/proc_linux.go index f0cc43a10..17c8fa529 100644 --- a/src/pkg/debug/proc/proc_linux.go +++ b/src/pkg/debug/proc/proc_linux.go @@ -1184,7 +1184,7 @@ func (p *process) attachThread(tid int) (*thread, os.Error) { // attachAllThreads attaches to all threads in a process. func (p *process) attachAllThreads() os.Error { taskPath := "/proc/" + strconv.Itoa(p.pid) + "/task" - taskDir, err := os.Open(taskPath, os.O_RDONLY, 0) + taskDir, err := os.Open(taskPath) if err != nil { return err } @@ -1279,25 +1279,31 @@ func Attach(pid int) (Process, os.Error) { return p, nil } -// ForkExec forks the current process and execs argv0, stopping the -// new process after the exec syscall. See os.ForkExec for additional +// StartProcess forks the current process and execs argv0, stopping the +// new process after the exec syscall. See os.StartProcess for additional // details. -func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*os.File) (Process, os.Error) { +func StartProcess(argv0 string, argv []string, attr *os.ProcAttr) (Process, os.Error) { + sysattr := &syscall.ProcAttr{ + Dir: attr.Dir, + Env: attr.Env, + Ptrace: true, + } p := newProcess(-1) // Create array of integer (system) fds. - intfd := make([]int, len(fd)) - for i, f := range fd { + intfd := make([]int, len(attr.Files)) + for i, f := range attr.Files { if f == nil { intfd[i] = -1 } else { intfd[i] = f.Fd() } } + sysattr.Files = intfd // Fork from the monitor thread so we get the right tracer pid. err := p.do(func() os.Error { - pid, errno := syscall.PtraceForkExec(argv0, argv, envv, dir, intfd) + pid, _, errno := syscall.StartProcess(argv0, argv, sysattr) if errno != 0 { return &os.PathError{"fork/exec", argv0, os.Errno(errno)} } diff --git a/src/pkg/debug/proc/proc_windows.go b/src/pkg/debug/proc/proc_windows.go index dc22faef8..661474b67 100644 --- a/src/pkg/debug/proc/proc_windows.go +++ b/src/pkg/debug/proc/proc_windows.go @@ -12,6 +12,6 @@ func Attach(pid int) (Process, os.Error) { return nil, os.NewError("debug/proc not implemented on windows") } -func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*os.File) (Process, os.Error) { +func StartProcess(argv0 string, argv []string, attr *os.ProcAttr) (Process, os.Error) { return Attach(0) } |
