proc/gdbserial: disable async preemption on macOS
Disables async preemption on macOS Fixes #1905
This commit is contained in:
parent
241f242231
commit
23dc9f92c2
@ -390,6 +390,10 @@ func LLDBLaunch(cmd []string, wd string, foreground bool, debugInfoDirs []string
|
|||||||
|
|
||||||
process.SysProcAttr = sysProcAttr(foreground)
|
process.SysProcAttr = sysProcAttr(foreground)
|
||||||
|
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
process.Env = proc.DisableAsyncPreemptEnv()
|
||||||
|
}
|
||||||
|
|
||||||
err := process.Start()
|
err := process.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -406,7 +410,7 @@ func LLDBLaunch(cmd []string, wd string, foreground bool, debugInfoDirs []string
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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
|
// LLDBAttach starts an instance of lldb-server and connects to it, asking
|
||||||
@ -655,7 +659,6 @@ continueLoop:
|
|||||||
var err error
|
var err error
|
||||||
var sig uint8
|
var sig uint8
|
||||||
tu.Reset()
|
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)
|
threadID, sig, err = p.conn.resume(p.threads, &tu)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, exited := err.(proc.ErrProcessExited); exited {
|
if _, exited := err.(proc.ErrProcessExited); exited {
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
@ -56,14 +55,7 @@ func Launch(cmd []string, wd string, foreground bool, _ []string) (*proc.Target,
|
|||||||
}
|
}
|
||||||
closer.Close()
|
closer.Close()
|
||||||
|
|
||||||
env := os.Environ()
|
env := proc.DisableAsyncPreemptEnv()
|
||||||
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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var p *os.Process
|
var p *os.Process
|
||||||
dbp := New(0)
|
dbp := New(0)
|
||||||
|
|||||||
@ -7,8 +7,10 @@ import (
|
|||||||
"go/ast"
|
"go/ast"
|
||||||
"go/constant"
|
"go/constant"
|
||||||
"go/token"
|
"go/token"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/go-delve/delve/pkg/goversion"
|
"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), "")
|
err = scope.setValue(asyncpreemptoffv, newConstant(constant.MakeInt64(v), scope.Mem), "")
|
||||||
logger.Warnf("could not set asyncpreemptoff %v", err)
|
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
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user