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

Delta Between Two Patch Sets: demo/ptrace-linux-amd64/tracee/main.go

Issue 85300043: code review 85300043: ogle/demo/ptrace-linux-amd64: new programs. (Closed)
Left Patch Set: Created 9 years, 11 months ago
Right Patch Set: diff -r 83f9669082bb https://code.google.com/p/ogle Created 9 years, 11 months 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:
Right: Side by side diff | Download
« no previous file with change/comment | « demo/ptrace-linux-amd64/main.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // This program prints to stdout from multiple goroutines multiplexed onto
6 // multiple threads. It is used as the tracee program by the debugger (tracer)
7 // program in the parent directory.
8 package main
9
10 import (
11 "fmt"
12 "runtime"
13 "syscall"
14 "time"
15 )
16
17 // ansiColor is whether to display ANSI color codes in the program's output.
18 // This distinguishes this program's output (the tracee's) from the debugger
19 // program's output (the tracer's).
20 const ansiColor = false
21
22 var prefix, suffix string
23
24 func run(base int, sleep time.Duration, lockOSThread bool) {
25 if lockOSThread {
26 runtime.LockOSThread()
27 }
28 for i := 0; ; i++ {
29 fmt.Printf("%sx=%5d tid=%d%s\n", prefix, base+i, syscall.Gettid( ), suffix)
30 time.Sleep(sleep)
31 }
32 }
33
34 func main() {
35 if ansiColor {
36 prefix, suffix = "\x1b[36m", "\x1b[0m"
37 }
38 go run(0, 300*time.Millisecond, false)
39 go run(100, 500*time.Millisecond, false)
40 go run(10000, 700*time.Millisecond, true)
41 time.Sleep(5 * time.Second)
42 }
LEFTRIGHT

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