OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 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 proc | 5 package proc |
6 | 6 |
7 // TODO(rsc): Imports here after to be in proc.go too in order | 7 // TODO(rsc): Imports here after to be in proc.go too in order |
8 // for deps.bash to get the right answer. | 8 // for deps.bash to get the right answer. |
9 import ( | 9 import ( |
10 "container/vector"; | 10 "container/vector"; |
11 "fmt"; | 11 "fmt"; |
12 » "io"; | 12 » "io/ioutil"; |
13 "os"; | 13 "os"; |
14 "runtime"; | 14 "runtime"; |
15 "strconv"; | 15 "strconv"; |
16 "strings"; | 16 "strings"; |
17 "sync"; | 17 "sync"; |
18 "syscall"; | 18 "syscall"; |
19 ) | 19 ) |
20 | 20 |
21 // This is an implementation of the process tracing interface using | 21 // This is an implementation of the process tracing interface using |
22 // Linux's ptrace(2) interface. The implementation is multi-threaded. | 22 // Linux's ptrace(2) interface. The implementation is multi-threaded. |
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 return err | 1208 return err |
1209 } | 1209 } |
1210 if _, ok := p.threads[tid]; ok { | 1210 if _, ok := p.threads[tid]; ok { |
1211 continue | 1211 continue |
1212 } | 1212 } |
1213 | 1213 |
1214 _, err = p.attachThread(tid); | 1214 _, err = p.attachThread(tid); |
1215 if err != nil { | 1215 if err != nil { |
1216 // There could have been a race, or | 1216 // There could have been a race, or |
1217 // this process could be a zobmie. | 1217 // this process could be a zobmie. |
1218 » » » » statFile, err2 := io.ReadFile(taskPath + "/" + t
idStr + "/stat"); | 1218 » » » » statFile, err2 := ioutil.ReadFile(taskPath + "/"
+ tidStr + "/stat"); |
1219 if err2 != nil { | 1219 if err2 != nil { |
1220 switch err2 := err2.(type) { | 1220 switch err2 := err2.(type) { |
1221 case *os.PathError: | 1221 case *os.PathError: |
1222 if err2.Error == os.ENOENT { | 1222 if err2.Error == os.ENOENT { |
1223 // Raced with thread exi
t | 1223 // Raced with thread exi
t |
1224 p.logTrace("raced with t
hread %d exit", tid); | 1224 p.logTrace("raced with t
hread %d exit", tid); |
1225 continue; | 1225 continue; |
1226 } | 1226 } |
1227 } | 1227 } |
1228 // Return the original error | 1228 // Return the original error |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 _, err := p.newThread(pid, syscall.SIGTRAP, false); | 1308 _, err := p.newThread(pid, syscall.SIGTRAP, false); |
1309 return err; | 1309 return err; |
1310 }); | 1310 }); |
1311 if err != nil { | 1311 if err != nil { |
1312 p.stopMonitor(err); | 1312 p.stopMonitor(err); |
1313 return nil, err; | 1313 return nil, err; |
1314 } | 1314 } |
1315 | 1315 |
1316 return p, nil; | 1316 return p, nil; |
1317 } | 1317 } |
OLD | NEW |