提交 23dc9f92 编写于 作者: A a 提交者: Derek Parker

proc/gdbserial: disable async preemption on macOS

Disables async preemption on macOS

Fixes #1905
上级 241f2422
......@@ -390,6 +390,10 @@ func LLDBLaunch(cmd []string, wd string, foreground bool, debugInfoDirs []string
process.SysProcAttr = sysProcAttr(foreground)
if runtime.GOOS == "darwin" {
process.Env = proc.DisableAsyncPreemptEnv()
}
err := process.Start()
if err != nil {
return nil, err
......@@ -406,7 +410,7 @@ func LLDBLaunch(cmd []string, wd string, foreground bool, debugInfoDirs []string
if err != nil {
return nil, err
}
return proc.NewTarget(p, false), nil
return proc.NewTarget(p, runtime.GOOS == "darwin"), nil
}
// LLDBAttach starts an instance of lldb-server and connects to it, asking
......@@ -655,7 +659,6 @@ continueLoop:
var err error
var sig uint8
tu.Reset()
//TODO: pass thread list to resume, which should use it to pass the correct signals
threadID, sig, err = p.conn.resume(p.threads, &tu)
if err != nil {
if _, exited := err.(proc.ErrProcessExited); exited {
......
......@@ -7,7 +7,6 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"
"syscall"
"unsafe"
......@@ -56,14 +55,7 @@ func Launch(cmd []string, wd string, foreground bool, _ []string) (*proc.Target,
}
closer.Close()
env := os.Environ()
for i := range env {
if strings.HasPrefix(env[i], "GODEBUG=") {
// Go 1.14 asynchronous preemption mechanism is incompatible with
// debuggers, see: https://github.com/golang/go/issues/36494
env[i] += ",asyncpreemptoff=1"
}
}
env := proc.DisableAsyncPreemptEnv()
var p *os.Process
dbp := New(0)
......
......@@ -7,8 +7,10 @@ import (
"go/ast"
"go/constant"
"go/token"
"os"
"path/filepath"
"strconv"
"strings"
"github.com/go-delve/delve/pkg/goversion"
)
......@@ -845,3 +847,17 @@ func setAsyncPreemptOff(p *Target, v int64) {
err = scope.setValue(asyncpreemptoffv, newConstant(constant.MakeInt64(v), scope.Mem), "")
logger.Warnf("could not set asyncpreemptoff %v", err)
}
// DisableAsyncPreemptEnv returns a process environment (like os.Environ)
// where asyncpreemptoff is set to 1.
func DisableAsyncPreemptEnv() []string {
env := os.Environ()
for i := range env {
if strings.HasPrefix(env[i], "GODEBUG=") {
// Go 1.14 asynchronous preemption mechanism is incompatible with
// debuggers, see: https://github.com/golang/go/issues/36494
env[i] += ",asyncpreemptoff=1"
}
}
return env
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册