Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(431)

Delta Between Two Patch Sets: program/server/ptrace.go

Issue 78530044: code review 78530044: ogle/program: first cut of breakpoint support. (Closed)
Left Patch Set: diff -r ad2f0964d3f5 https://code.google.com/p/ogle Created 10 years ago
Right Patch Set: diff -r ad2f0964d3f5 https://code.google.com/p/ogle Created 10 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « program/proxyrpc/proxyrpc.go ('k') | program/server/server.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2014 The Go Authors. All rights reserved. 1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package server 5 package server
6 6
7 // TODO: syscall.PTRACE_O_TRACECLONE shenanigans to trace multi-threaded 7 // TODO: syscall.PTRACE_O_TRACECLONE shenanigans to trace multi-threaded
8 // programs. 8 // programs.
9 9
10 import ( 10 import (
11 "fmt" 11 "fmt"
12 "os" 12 "os"
13 "runtime" 13 "runtime"
14 "syscall" 14 "syscall"
15 ) 15 )
16 16
17 // ptraceRun runs all the closures from fc on a dedicated OS thread. Errors 17 // ptraceRun runs all the closures from fc on a dedicated OS thread. Errors
18 // are returned on ec. Both channels must be unbuffered. 18 // are returned on ec. Both channels must be unbuffered, to ensure that the
19 // resultant error is sent back to the same goroutine that sent the closure.
19 func ptraceRun(fc chan func() error, ec chan error) { 20 func ptraceRun(fc chan func() error, ec chan error) {
20 if cap(fc) != 0 || cap(ec) != 0 { 21 if cap(fc) != 0 || cap(ec) != 0 {
21 panic("ptraceRun was given unbuffered channels") 22 panic("ptraceRun was given unbuffered channels")
22 } 23 }
23 runtime.LockOSThread() 24 runtime.LockOSThread()
24 for f := range fc { 25 for f := range fc {
25 ec <- f() 26 ec <- f()
26 } 27 }
27 } 28 }
28 29
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 87
87 func (s *Server) wait() (err error) { 88 func (s *Server) wait() (err error) {
88 var status syscall.WaitStatus 89 var status syscall.WaitStatus
89 s.fc <- func() error { 90 s.fc <- func() error {
90 _, err1 := syscall.Wait4(-1, &status, 0, nil) 91 _, err1 := syscall.Wait4(-1, &status, 0, nil)
91 return err1 92 return err1
92 } 93 }
93 // TODO: do something with status. 94 // TODO: do something with status.
94 return <-s.ec 95 return <-s.ec
95 } 96 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b