Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into windows
Browse files Browse the repository at this point in the history
Conflicts:
	proc/proc.go
  • Loading branch information
lukehoban committed Jan 21, 2016
2 parents ce025fe + 98ae684 commit 0e447db
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 26 deletions.
25 changes: 11 additions & 14 deletions proc/proc.go
Expand Up @@ -4,6 +4,7 @@ import (
"debug/dwarf"
"debug/gosym"
"encoding/binary"
"errors"
"fmt"
"go/constant"
"os"
Expand Down Expand Up @@ -408,22 +409,18 @@ func (dbp *Process) pickCurrentThread(trapthread *Thread) error {
return dbp.SwitchThread(trapthread.ID)
}

// Step will continue the debugged process for exactly
// one instruction.
// Step will continue the current thread for exactly
// one instruction. This method affects only the thread
// asssociated with the selected goroutine. All other
// threads will remain stopped.
func (dbp *Process) Step() (err error) {
fn := func() error {
for _, th := range dbp.Threads {
if th.blocked() || !th.canStep() {
continue
}
if err := th.Step(); err != nil {
return err
}
}
return nil
if dbp.SelectedGoroutine == nil {
return errors.New("cannot single step: no selected goroutine")
}

return dbp.run(fn)
if dbp.SelectedGoroutine.thread == nil {
return fmt.Errorf("cannot single step: no thread associated with goroutine %d", dbp.SelectedGoroutine.ID)
}
return dbp.run(dbp.SelectedGoroutine.thread.Step)
}

// SwitchThread changes from current thread to the thread specified by `tid`.
Expand Down
4 changes: 0 additions & 4 deletions proc/threads_darwin.go
Expand Up @@ -89,10 +89,6 @@ func (t *Thread) stopped() bool {
return C.thread_blocked(t.os.threadAct) > C.int(0)
}

func (t *Thread) canStep() bool {
return true
}

func (t *Thread) writeMemory(addr uintptr, data []byte) (int, error) {
if len(data) == 0 {
return 0, nil
Expand Down
4 changes: 0 additions & 4 deletions proc/threads_linux.go
Expand Up @@ -39,10 +39,6 @@ func (t *Thread) resume() (err error) {
return
}

func (thread *Thread) canStep() bool {
return true
}

func (t *Thread) singleStep() (err error) {
for {
t.dbp.execPtraceFunc(func() { err = sys.PtraceSingleStep(t.ID) })
Expand Down
4 changes: 0 additions & 4 deletions proc/threads_windows.go
Expand Up @@ -134,10 +134,6 @@ func (t *Thread) stopped() bool {
return true
}

func (t *Thread) canStep() bool {
return t.dbp.os.breakThread == t.ID
}

func (t *Thread) writeMemory(addr uintptr, data []byte) (int, error) {
var (
vmData = C.LPCVOID(unsafe.Pointer(&data[0]))
Expand Down
2 changes: 2 additions & 0 deletions terminal/command.go
Expand Up @@ -235,6 +235,8 @@ func goroutines(t *Term, argstr string) error {
fgl = fglRuntimeCurrent
case "-g":
fgl = fglGo
case "":
// nothing to do
default:
return fmt.Errorf("wrong argument: '%s'", args[0])
}
Expand Down

0 comments on commit 0e447db

Please sign in to comment.