Skip to content

Commit

Permalink
*: Go 1.14 support branch (go-delve#1727)
Browse files Browse the repository at this point in the history
* tests: misc test fixes for go1.14

- math.go is now ambiguous due to changes to the go runtime so specify
  that we mean our own math.go in _fixtures
- go list -m requires vendor-mode to be disabled so pass '-mod=' to it
  in case user has GOFLAGS=-mod=vendor
- update version of go/packages, required to work with go 1.14 (and
  executed go mod vendor)
- Increased goroutine migration in one development version of Go 1.14
  revealed a problem with TestCheckpoints in command_test.go and
  rr_test.go. The tests were always wrong because Restart(checkpoint)
  doesn't change the current thread but we can't assume that when the
  checkpoint was taken the current goroutine was running on the same
  thread.

* goversion: update maximum supported version

* Makefile: disable testing lldb-server backend on linux with Go 1.14

There seems to be some incompatibility with lldb-server version 6.0.0
on linux and Go 1.14.

* proc/gdbserial: better handling of signals

- if multiple signals are received simultaneously propagate all of them to the
  target threads instead of only one.
- debugserver will drop an interrupt request if a target thread simultaneously
  receives a signal, handle this situation.

* dwarf/line: normalize backslashes for windows executables

Starting with Go 1.14 the compiler sometimes emits backslashes as well
as forward slashes in debug_line, normalize everything to / for
conformity with the behavior of previous versions.

* proc/native: partial support for Windows async preempt mechanism

See golang/go#36494 for a description of why
full support for 1.14 under windows is problematic.

* proc/native: disable Go 1.14 async preemption on Windows

See golang/go#36494
  • Loading branch information
aarzilli committed Feb 11, 2020
1 parent 40d7983 commit 42a9da8
Show file tree
Hide file tree
Showing 22 changed files with 314 additions and 97 deletions.
2 changes: 1 addition & 1 deletion cmd/dlv/dlv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func projectRoot() string {
return filepath.Join(curpath, "src", "github.com", "go-delve", "delve")
}
}
val, err := exec.Command("go", "list", "-m", "-f", "{{ .Dir }}").Output()
val, err := exec.Command("go", "list", "-mod=", "-m", "-f", "{{ .Dir }}").Output()
if err != nil {
panic(err) // the Go tool was tested to work earlier
}
Expand Down
17 changes: 13 additions & 4 deletions pkg/dwarf/line/line_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/binary"
"path/filepath"
"strings"

"github.com/go-delve/delve/pkg/dwarf/util"
)
Expand Down Expand Up @@ -34,9 +35,12 @@ type DebugLineInfo struct {

// lastMachineCache[pc] is a state machine stopped at an address after pc
lastMachineCache map[uint64]*StateMachine

// staticBase is the address at which the executable is loaded, 0 for non-PIEs
staticBase uint64

// if normalizeBackslash is true all backslashes (\) will be converted into forward slashes (/)
normalizeBackslash bool
}

type FileEntry struct {
Expand All @@ -49,23 +53,23 @@ type FileEntry struct {
type DebugLines []*DebugLineInfo

// ParseAll parses all debug_line segments found in data
func ParseAll(data []byte, logfn func(string, ...interface{}), staticBase uint64) DebugLines {
func ParseAll(data []byte, logfn func(string, ...interface{}), staticBase uint64, normalizeBackslash bool) DebugLines {
var (
lines = make(DebugLines, 0)
buf = bytes.NewBuffer(data)
)

// We have to parse multiple file name tables here.
for buf.Len() > 0 {
lines = append(lines, Parse("", buf, logfn, staticBase))
lines = append(lines, Parse("", buf, logfn, staticBase, normalizeBackslash))
}

return lines
}

// Parse parses a single debug_line segment from buf. Compdir is the
// DW_AT_comp_dir attribute of the associated compile unit.
func Parse(compdir string, buf *bytes.Buffer, logfn func(string, ...interface{}), staticBase uint64) *DebugLineInfo {
func Parse(compdir string, buf *bytes.Buffer, logfn func(string, ...interface{}), staticBase uint64, normalizeBackslash bool) *DebugLineInfo {
dbl := new(DebugLineInfo)
dbl.Logf = logfn
dbl.staticBase = staticBase
Expand All @@ -76,6 +80,7 @@ func Parse(compdir string, buf *bytes.Buffer, logfn func(string, ...interface{})

dbl.stateMachineCache = make(map[uint64]*StateMachine)
dbl.lastMachineCache = make(map[uint64]*StateMachine)
dbl.normalizeBackslash = normalizeBackslash

parseDebugLinePrologue(dbl, buf)
parseIncludeDirs(dbl, buf)
Expand Down Expand Up @@ -139,6 +144,10 @@ func readFileEntry(info *DebugLineInfo, buf *bytes.Buffer, exitOnEmptyPath bool)
return entry
}

if info.normalizeBackslash {
entry.Path = strings.Replace(entry.Path, "\\", "/", -1)
}

entry.DirIdx, _ = util.DecodeULEB128(buf)
entry.LastModTime, _ = util.DecodeULEB128(buf)
entry.Length, _ = util.DecodeULEB128(buf)
Expand Down
6 changes: 3 additions & 3 deletions pkg/dwarf/line/line_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const (

func testDebugLinePrologueParser(p string, t *testing.T) {
data := grabDebugLineSection(p, t)
debugLines := ParseAll(data, nil, 0)
debugLines := ParseAll(data, nil, 0, true)

mainFileFound := false

Expand Down Expand Up @@ -164,7 +164,7 @@ func BenchmarkLineParser(b *testing.B) {

b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = ParseAll(data, nil, 0)
_ = ParseAll(data, nil, 0, true)
}
}

Expand All @@ -179,7 +179,7 @@ func loadBenchmarkData(tb testing.TB) DebugLines {
tb.Fatal("Could not read test data", err)
}

return ParseAll(data, nil, 0)
return ParseAll(data, nil, 0, true)
}

func BenchmarkStateMachine(b *testing.B) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/dwarf/line/state_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestGrafana(t *testing.T) {
}
cuname, _ := e.Val(dwarf.AttrName).(string)

lineInfo := Parse(e.Val(dwarf.AttrCompDir).(string), debugLineBuffer, t.Logf, 0)
lineInfo := Parse(e.Val(dwarf.AttrCompDir).(string), debugLineBuffer, t.Logf, 0, false)
sm := newStateMachine(lineInfo, lineInfo.Instructions)

lnrdr, err := data.LineReader(e)
Expand Down
2 changes: 1 addition & 1 deletion pkg/goversion/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var (
MinSupportedVersionOfGoMajor = 1
MinSupportedVersionOfGoMinor = 11
MaxSupportedVersionOfGoMajor = 1
MaxSupportedVersionOfGoMinor = 13
MaxSupportedVersionOfGoMinor = 14
goTooOldErr = fmt.Errorf("Version of Go is too old for this version of Delve (minimum supported version %d.%d, suppress this error with --check-go-version=false)", MinSupportedVersionOfGoMajor, MinSupportedVersionOfGoMinor)
dlvTooOldErr = fmt.Errorf("Version of Delve is too old for this version of Go (maximum supported version %d.%d, suppress this error with --check-go-version=false)", MaxSupportedVersionOfGoMajor, MaxSupportedVersionOfGoMinor)
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/proc/bininfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ func (bi *BinaryInfo) loadDebugInfoMaps(image *Image, debugLineBytes []byte, wg
logger.Printf(fmt, args)
}
}
cu.lineInfo = line.Parse(compdir, bytes.NewBuffer(debugLineBytes[lineInfoOffset:]), logfn, image.StaticBase)
cu.lineInfo = line.Parse(compdir, bytes.NewBuffer(debugLineBytes[lineInfoOffset:]), logfn, image.StaticBase, bi.GOOS == "windows")
}
cu.producer, _ = entry.Val(dwarf.AttrProducer).(string)
if cu.isgo && cu.producer != "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/proc/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func OpenCore(corePath, exePath string, debugInfoDirs []string) (*proc.Target, e
return nil, err
}

return proc.NewTarget(p), nil
return proc.NewTarget(p, false), nil
}

// initialize for core files doesn't do much
Expand Down
Loading

0 comments on commit 42a9da8

Please sign in to comment.