From 42f56e28622ead9a393ca337e52419954f5653c0 Mon Sep 17 00:00:00 2001 From: Andrei Matei Date: Mon, 16 Nov 2020 11:55:59 -0500 Subject: [PATCH] proc: add minor comments (#2228) This patch adds some comments around RequestManualStop(). --- pkg/proc/interface.go | 1 + pkg/proc/native/proc.go | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/proc/interface.go b/pkg/proc/interface.go index f785480f..90632790 100644 --- a/pkg/proc/interface.go +++ b/pkg/proc/interface.go @@ -98,6 +98,7 @@ type ThreadInfo interface { // ProcessManipulation is an interface for changing the execution state of a process. type ProcessManipulation interface { + // RequestManualStop attempts to stop all the process' threads. RequestManualStop() error // CheckAndClearManualStopRequest returns true the first time it's called // after a call to RequestManualStop. diff --git a/pkg/proc/native/proc.go b/pkg/proc/native/proc.go index 6509bf54..4dbaf11d 100644 --- a/pkg/proc/native/proc.go +++ b/pkg/proc/native/proc.go @@ -27,11 +27,14 @@ type nativeProcess struct { os *osProcessDetails firstStart bool - stopMu sync.Mutex resumeChan chan<- struct{} ptraceChan chan func() ptraceDoneChan chan interface{} childProcess bool // this process was launched, not attached to + stopMu sync.Mutex // protects manualStopRequested + // manualStopRequested is set if all the threads in the process were + // signalled to stop as a result of a Halt API call. Used to disambiguate + // why a thread is found to have stopped. manualStopRequested bool // Controlling terminal file descriptor for @@ -176,7 +179,7 @@ func (dbp *nativeProcess) Breakpoints() *proc.BreakpointMap { return &dbp.breakpoints } -// RequestManualStop sets the `halt` flag and +// RequestManualStop sets the `manualStopRequested` flag and // sends SIGSTOP to all threads. func (dbp *nativeProcess) RequestManualStop() error { if dbp.exited {