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)
|
return dbp.exitGuard(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
th.running = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ports, err := dbp.waitForStop()
|
ports, err := dbp.waitForStop()
|
||||||
|
|||||||
@ -240,8 +240,8 @@ func (dbp *Process) trapWait(pid int) (*Thread, error) {
|
|||||||
dbp.haltMu.Unlock()
|
dbp.haltMu.Unlock()
|
||||||
if halt {
|
if halt {
|
||||||
dbp.halt = false
|
dbp.halt = false
|
||||||
th.running = false
|
th.os.running = false
|
||||||
dbp.threads[int(wpid)].running = false
|
dbp.threads[int(wpid)].os.running = false
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
if err = th.Continue(); err != nil {
|
if err = th.Continue(); err != nil {
|
||||||
@ -267,12 +267,12 @@ func (dbp *Process) trapWait(pid int) (*Thread, error) {
|
|||||||
halt := dbp.halt
|
halt := dbp.halt
|
||||||
dbp.haltMu.Unlock()
|
dbp.haltMu.Unlock()
|
||||||
if halt && (status.StopSignal() == sys.SIGTRAP || status.StopSignal() == sys.SIGSTOP) {
|
if halt && (status.StopSignal() == sys.SIGTRAP || status.StopSignal() == sys.SIGSTOP) {
|
||||||
th.running = false
|
th.os.running = false
|
||||||
dbp.halt = false
|
dbp.halt = false
|
||||||
return th, nil
|
return th, nil
|
||||||
}
|
}
|
||||||
if status.StopSignal() == sys.SIGTRAP {
|
if status.StopSignal() == sys.SIGTRAP {
|
||||||
th.running = false
|
th.os.running = false
|
||||||
return th, nil
|
return th, nil
|
||||||
}
|
}
|
||||||
if th != nil {
|
if th != nil {
|
||||||
@ -425,7 +425,7 @@ func (dbp *Process) stop(trapthread *Thread) (err error) {
|
|||||||
for {
|
for {
|
||||||
allstopped := true
|
allstopped := true
|
||||||
for _, th := range dbp.threads {
|
for _, th := range dbp.threads {
|
||||||
if th.running {
|
if th.os.running {
|
||||||
allstopped = false
|
allstopped = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@ -404,7 +404,6 @@ func (dbp *Process) resume() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, thread := range dbp.threads {
|
for _, thread := range dbp.threads {
|
||||||
thread.running = true
|
|
||||||
_, err := _ResumeThread(thread.os.hThread)
|
_, err := _ResumeThread(thread.os.hThread)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -419,9 +418,6 @@ func (dbp *Process) stop(trapthread *Thread) (err error) {
|
|||||||
if dbp.exited {
|
if dbp.exited {
|
||||||
return &proc.ProcessExitedError{Pid: dbp.Pid()}
|
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
|
// While the debug event that stopped the target was being propagated
|
||||||
// other target threads could generate other debug events.
|
// 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 {
|
for _, thread := range dbp.threads {
|
||||||
thread.running = false
|
|
||||||
_, err := _SuspendThread(thread.os.hThread)
|
_, err := _SuspendThread(thread.os.hThread)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@ -18,7 +18,6 @@ type Thread struct {
|
|||||||
|
|
||||||
dbp *Process
|
dbp *Process
|
||||||
singleStepping bool
|
singleStepping bool
|
||||||
running bool
|
|
||||||
os *OSSpecificDetails
|
os *OSSpecificDetails
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,11 +48,9 @@ func (thread *Thread) Continue() error {
|
|||||||
// execute the instruction, and then replace the breakpoint.
|
// execute the instruction, and then replace the breakpoint.
|
||||||
// Otherwise we simply execute the next instruction.
|
// Otherwise we simply execute the next instruction.
|
||||||
func (thread *Thread) StepInstruction() (err error) {
|
func (thread *Thread) StepInstruction() (err error) {
|
||||||
thread.running = true
|
|
||||||
thread.singleStepping = true
|
thread.singleStepping = true
|
||||||
defer func() {
|
defer func() {
|
||||||
thread.singleStepping = false
|
thread.singleStepping = false
|
||||||
thread.running = false
|
|
||||||
}()
|
}()
|
||||||
pc, err := thread.PC()
|
pc, err := thread.PC()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -69,7 +69,6 @@ func (t *Thread) singleStep() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Thread) resume() error {
|
func (t *Thread) resume() error {
|
||||||
t.running = true
|
|
||||||
// TODO(dp) set flag for ptrace stops
|
// TODO(dp) set flag for ptrace stops
|
||||||
var err error
|
var err error
|
||||||
t.dbp.execPtraceFunc(func() { err = PtraceCont(t.dbp.pid, 0) })
|
t.dbp.execPtraceFunc(func() { err = PtraceCont(t.dbp.pid, 0) })
|
||||||
|
|||||||
@ -14,6 +14,7 @@ type WaitStatus sys.WaitStatus
|
|||||||
// process details.
|
// process details.
|
||||||
type OSSpecificDetails struct {
|
type OSSpecificDetails struct {
|
||||||
registers sys.PtraceRegs
|
registers sys.PtraceRegs
|
||||||
|
running bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Thread) halt() (err error) {
|
func (t *Thread) halt() (err error) {
|
||||||
@ -37,7 +38,7 @@ func (t *Thread) resume() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Thread) resumeWithSig(sig int) (err 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) })
|
t.dbp.execPtraceFunc(func() { err = PtraceCont(t.ID, sig) })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -86,7 +86,6 @@ func (t *Thread) singleStep() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Thread) resume() error {
|
func (t *Thread) resume() error {
|
||||||
t.running = true
|
|
||||||
var err error
|
var err error
|
||||||
t.dbp.execPtraceFunc(func() {
|
t.dbp.execPtraceFunc(func() {
|
||||||
//TODO: Note that we are ignoring the thread we were asked to continue and are continuing the
|
//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