-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runc: replace debug-trace.go debug-flag.go
Signed-off-by: LEI WANG <[email protected]>
- Loading branch information
Showing
1 changed file
with
12 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,44 @@ | ||
diff --git a/Makefile b/Makefile | ||
index 7ce26c6..e424632 100644 | ||
index e3af9bc..059f3d1 100644 | ||
--- a/Makefile | ||
+++ b/Makefile | ||
@@ -136,6 +136,14 @@ shell: | ||
@@ -136,6 +136,14 @@ shell: runcimage | ||
-v $(CURDIR):/go/src/$(PROJECT) \ | ||
$(RUNC_IMAGE) bash | ||
|
||
+debug: | ||
+ mv debug-trace.go debug-trace.go.bak || echo "" | ||
+ mv debug-flag.go debug-flag.go.bak || echo "" | ||
+ make EXTRA_FLAGS='-gcflags="all=-N -l"' static | ||
+ mv runc runc-v1.1.11-debug | ||
+ mv debug-trace.go.bak debug-trace.go | ||
+ mv debug-flag.go.bak debug-flag.go | ||
+ make EXTRA_FLAGS='-gcflags="all=-N -l"' static | ||
+ mv runc runc-v1.1.11-debug-auto-wait-tracing | ||
+ mv runc runc-v1.1.11-debug-flag | ||
+ | ||
install: | ||
install -D -m0755 runc $(DESTDIR)$(BINDIR)/runc | ||
|
||
diff --git a/debug-trace.go b/debug-trace.go | ||
diff --git a/debug-flag.go b/debug-flag.go | ||
new file mode 100644 | ||
index 0000000..ca6cccb | ||
index 0000000..647ef4d | ||
--- /dev/null | ||
+++ b/debug-trace.go | ||
@@ -0,0 +1,45 @@ | ||
+++ b/debug-flag.go | ||
@@ -0,0 +1,18 @@ | ||
+package main | ||
+ | ||
+import ( | ||
+ "bufio" | ||
+ "os" | ||
+ "strings" | ||
+ "time" | ||
+) | ||
+ | ||
+func isBeingTraced() (tracing bool) { | ||
+ file, err := os.Open("/proc/self/status") | ||
+ if err != nil { | ||
+ panic(err) | ||
+ } | ||
+ defer file.Close() | ||
+ | ||
+ scanner := bufio.NewScanner(file) | ||
+ for scanner.Scan() { | ||
+ line := scanner.Text() | ||
+ if strings.HasPrefix(line, "TracerPid:") { | ||
+ tracerPidInfo := strings.Fields(line) | ||
+ if len(tracerPidInfo) == 2 && tracerPidInfo[1] != "0" { | ||
+ return true | ||
+ } | ||
+ break | ||
+ } | ||
+ } | ||
+ | ||
+ if err := scanner.Err(); err != nil { | ||
+ panic(err) | ||
+ } | ||
+ | ||
+ return | ||
+} | ||
+ | ||
+func init() { | ||
+ if len(os.Args) > 1 && os.Args[1] == "init" { | ||
+ var flag bool | ||
+ for { | ||
+ if isBeingTraced() { | ||
+ if flag { | ||
+ break | ||
+ } | ||
+ time.Sleep(time.Second) | ||
+ } | ||
+ } | ||
+} | ||
\ No newline at end of file |