proc/native: move Thread.running to os struct
Windows and macOS aren't using this field so move it to the os-specific thread struct and remove it from everything except linux.
This commit is contained in:
parent
f26bb0b875
commit
8561db8c2c
@ -435,7 +435,6 @@ func (dbp *Process) stop(trapthread *Thread) (err error) {
|
||||
return dbp.exitGuard(err)
|
||||
}
|
||||
}
|
||||
th.running = false
|
||||
}
|
||||
|
||||
ports, err := dbp.waitForStop()
|
||||
|
||||
@ -240,8 +240,8 @@ func (dbp *Process) trapWait(pid int) (*Thread, error) {
|
||||
dbp.haltMu.Unlock()
|
||||
if halt {
|
||||
dbp.halt = false
|
||||
th.running = false
|
||||
dbp.threads[int(wpid)].running = false
|
||||
th.os.running = false
|
||||
dbp.threads[int(wpid)].os.running = false
|
||||
return nil, nil
|
||||
}
|
||||
if err = th.Continue(); err != nil {
|
||||
@ -267,12 +267,12 @@ func (dbp *Process) trapWait(pid int) (*Thread, error) {
|
||||
halt := dbp.halt
|
||||
dbp.haltMu.Unlock()
|
||||
if halt && (status.StopSignal() == sys.SIGTRAP || status.StopSignal() == sys.SIGSTOP) {
|
||||
th.running = false
|
||||
th.os.running = false
|
||||
dbp.halt = false
|
||||
return th, nil
|
||||
}
|
||||
if status.StopSignal() == sys.SIGTRAP {
|
||||
th.running = false
|
||||
th.os.running = false
|
||||
return th, nil
|
||||
}
|
||||
if th != nil {
|
||||
@ -425,7 +425,7 @@ func (dbp *Process) stop(trapthread *Thread) (err error) {
|
||||
for {
|
||||
allstopped := true
|
||||
for _, th := range dbp.threads {
|
||||
if th.running {
|
||||
if th.os.running {
|
||||
allstopped = false
|
||||
break
|
||||
}
|
||||
|
||||
@ -404,7 +404,6 @@ func (dbp *Process) resume() error {
|
||||
}
|
||||
|
||||
for _, thread := range dbp.threads {
|
||||
thread.running = true
|
||||
_, err := _ResumeThread(thread.os.hThread)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -419,9 +418,6 @@ func (dbp *Process) stop(trapthread *Thread) (err error) {
|
||||
if dbp.exited {
|
||||
return &proc.ProcessExitedError{Pid: dbp.Pid()}
|
||||
}
|
||||
for _, th := range dbp.threads {
|
||||
th.running = false
|
||||
}
|
||||
|
||||
// While the debug event that stopped the target was being propagated
|
||||
// other target threads could generate other debug events.
|
||||
@ -439,7 +435,6 @@ func (dbp *Process) stop(trapthread *Thread) (err error) {
|
||||
}
|
||||
|
||||
for _, thread := range dbp.threads {
|
||||
thread.running = false
|
||||
_, err := _SuspendThread(thread.os.hThread)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -18,7 +18,6 @@ type Thread struct {
|
||||
|
||||
dbp *Process
|
||||
singleStepping bool
|
||||
running bool
|
||||
os *OSSpecificDetails
|
||||
}
|
||||
|
||||
@ -49,11 +48,9 @@ func (thread *Thread) Continue() error {
|
||||
// execute the instruction, and then replace the breakpoint.
|
||||
// Otherwise we simply execute the next instruction.
|
||||
func (thread *Thread) StepInstruction() (err error) {
|
||||
thread.running = true
|
||||
thread.singleStepping = true
|
||||
defer func() {
|
||||
thread.singleStepping = false
|
||||
thread.running = false
|
||||
}()
|
||||
pc, err := thread.PC()
|
||||
if err != nil {
|
||||
|
||||
@ -69,7 +69,6 @@ func (t *Thread) singleStep() error {
|
||||
}
|
||||
|
||||
func (t *Thread) resume() error {
|
||||
t.running = true
|
||||
// TODO(dp) set flag for ptrace stops
|
||||
var err error
|
||||
t.dbp.execPtraceFunc(func() { err = PtraceCont(t.dbp.pid, 0) })
|
||||
|
||||
@ -14,6 +14,7 @@ type WaitStatus sys.WaitStatus
|
||||
// process details.
|
||||
type OSSpecificDetails struct {
|
||||
registers sys.PtraceRegs
|
||||
running bool
|
||||
}
|
||||
|
||||
func (t *Thread) halt() (err error) {
|
||||
@ -37,7 +38,7 @@ func (t *Thread) resume() error {
|
||||
}
|
||||
|
||||
func (t *Thread) resumeWithSig(sig int) (err error) {
|
||||
t.running = true
|
||||
t.os.running = true
|
||||
t.dbp.execPtraceFunc(func() { err = PtraceCont(t.ID, sig) })
|
||||
return
|
||||
}
|
||||
|
||||
@ -86,7 +86,6 @@ func (t *Thread) singleStep() error {
|
||||
}
|
||||
|
||||
func (t *Thread) resume() error {
|
||||
t.running = true
|
||||
var err error
|
||||
t.dbp.execPtraceFunc(func() {
|
||||
//TODO: Note that we are ignoring the thread we were asked to continue and are continuing the
|
||||
|
||||
Loading…
Reference in New Issue
Block a user