mirror of
https://github.com/go-delve/delve.git
synced 2025-11-03 22:08:33 +08:00
@ -161,8 +161,8 @@ func (dbp *Process) LoadInformation(path string) error {
|
||||
}
|
||||
|
||||
// FindFileLocation returns the PC for a given file:line.
|
||||
// Assumes that `file` is normailzed to lower case and '/' on Windows.
|
||||
func (dbp *Process) FindFileLocation(fileName string, lineno int) (uint64, error) {
|
||||
fileName = filepath.ToSlash(fileName)
|
||||
pc, _, err := dbp.goSymTable.LineToPC(fileName, lineno)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
||||
@ -7,8 +7,9 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Fixture is a test binary.
|
||||
@ -64,6 +65,9 @@ func BuildFixture(name string) Fixture {
|
||||
|
||||
source, _ := filepath.Abs(path)
|
||||
source = filepath.ToSlash(source)
|
||||
if runtime.GOOS == "windows" {
|
||||
source = strings.ToLower(source)
|
||||
}
|
||||
|
||||
Fixtures[name] = Fixture{Name: name, Path: tmpfile, Source: source}
|
||||
return Fixtures[name]
|
||||
|
||||
@ -149,7 +149,7 @@ func (d *Debugger) CreateBreakpoint(requestedBp *api.Breakpoint) (*api.Breakpoin
|
||||
)
|
||||
switch {
|
||||
case len(requestedBp.File) > 0:
|
||||
addr, err = d.process.FindFileLocation(requestedBp.File, requestedBp.Line)
|
||||
addr, err = d.process.FindFileLocation(normalizePath(requestedBp.File), requestedBp.Line)
|
||||
case len(requestedBp.FunctionName) > 0:
|
||||
if requestedBp.Line >= 0 {
|
||||
addr, err = d.process.FindFunctionLocation(requestedBp.FunctionName, false, requestedBp.Line)
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"go/constant"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@ -49,6 +50,13 @@ type FuncLocationSpec struct {
|
||||
BaseName string
|
||||
}
|
||||
|
||||
func normalizePath(path string) string {
|
||||
if runtime.GOOS != "windows" {
|
||||
return path
|
||||
}
|
||||
return strings.ToLower(filepath.ToSlash(path))
|
||||
}
|
||||
|
||||
func parseLocationSpec(locStr string) (LocationSpec, error) {
|
||||
rest := locStr
|
||||
|
||||
@ -98,7 +106,7 @@ func parseLocationSpecDefault(locStr, rest string) (LocationSpec, error) {
|
||||
v := strings.Split(rest, ":")
|
||||
if len(v) > 2 {
|
||||
// On Windows, path may contain ":", so split only on last ":"
|
||||
v = []string { strings.Join(v[0:len(v)-1], ":"), v[len(v)-1] }
|
||||
v = []string{strings.Join(v[0:len(v)-1], ":"), v[len(v)-1]}
|
||||
}
|
||||
|
||||
if len(v) == 1 {
|
||||
@ -111,7 +119,6 @@ func parseLocationSpecDefault(locStr, rest string) (LocationSpec, error) {
|
||||
spec := &NormalLocationSpec{}
|
||||
|
||||
spec.Base = v[0]
|
||||
spec.Base = filepath.ToSlash(spec.Base)
|
||||
spec.FuncBase = parseFuncLocationSpec(spec.Base)
|
||||
|
||||
if len(v) < 2 {
|
||||
@ -284,6 +291,8 @@ func (loc *NormalLocationSpec) FileMatch(path string) bool {
|
||||
}
|
||||
|
||||
func partialPathMatch(expr, path string) bool {
|
||||
expr = normalizePath(expr)
|
||||
path = normalizePath(path)
|
||||
if len(expr) < len(path)-1 {
|
||||
return strings.HasSuffix(path, expr) && (path[len(path)-len(expr)-1] == '/')
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user