service/debugger: Use PC instead of scope in Location.Find
This commit is contained in:
parent
3fc823b781
commit
af9e97b697
@ -502,12 +502,12 @@ func (d *Debugger) FindLocation(scope api.EvalScope, locStr string) ([]api.Locat
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
s, err := d.process.ConvertEvalScope(scope.GoroutineID, scope.Frame)
|
pc, err := d.process.PC()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
locs, err := loc.Find(d, s, locStr)
|
locs, err := loc.Find(d, pc, locStr)
|
||||||
for i := range locs {
|
for i := range locs {
|
||||||
file, line, fn := d.process.PCToLine(locs[i].PC)
|
file, line, fn := d.process.PCToLine(locs[i].PC)
|
||||||
locs[i].File = file
|
locs[i].File = file
|
||||||
|
@ -7,14 +7,13 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/derekparker/delve/proc"
|
|
||||||
"github.com/derekparker/delve/service/api"
|
"github.com/derekparker/delve/service/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxFindLocationCandidates = 5
|
const maxFindLocationCandidates = 5
|
||||||
|
|
||||||
type LocationSpec interface {
|
type LocationSpec interface {
|
||||||
Find(d *Debugger, scope *proc.EvalScope, locStr string) ([]api.Location, error)
|
Find(d *Debugger, pc uint64, locStr string) ([]api.Location, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type NormalLocationSpec struct {
|
type NormalLocationSpec struct {
|
||||||
@ -205,7 +204,7 @@ func (spec *FuncLocationSpec) Match(sym *gosym.Sym) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (loc *RegexLocationSpec) Find(d *Debugger, scope *proc.EvalScope, locStr string) ([]api.Location, error) {
|
func (loc *RegexLocationSpec) Find(d *Debugger, pc uint64, locStr string) ([]api.Location, error) {
|
||||||
funcs := d.process.Funcs()
|
funcs := d.process.Funcs()
|
||||||
matches, err := regexFilterFuncs(loc.FuncRegex, funcs)
|
matches, err := regexFilterFuncs(loc.FuncRegex, funcs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -221,7 +220,7 @@ func (loc *RegexLocationSpec) Find(d *Debugger, scope *proc.EvalScope, locStr st
|
|||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (loc *AddrLocationSpec) Find(d *Debugger, scope *proc.EvalScope, locStr string) ([]api.Location, error) {
|
func (loc *AddrLocationSpec) Find(d *Debugger, pc uint64, locStr string) ([]api.Location, error) {
|
||||||
return []api.Location{{PC: loc.Addr}}, nil
|
return []api.Location{{PC: loc.Addr}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +247,7 @@ func (ale AmbiguousLocationError) Error() string {
|
|||||||
return fmt.Sprintf("Location \"%s\" ambiguous: %s…", ale.Location, strings.Join(candidates, ", "))
|
return fmt.Sprintf("Location \"%s\" ambiguous: %s…", ale.Location, strings.Join(candidates, ", "))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (loc *NormalLocationSpec) Find(d *Debugger, scope *proc.EvalScope, locStr string) ([]api.Location, error) {
|
func (loc *NormalLocationSpec) Find(d *Debugger, pc uint64, locStr string) ([]api.Location, error) {
|
||||||
funcs := d.process.Funcs()
|
funcs := d.process.Funcs()
|
||||||
files := d.process.Sources()
|
files := d.process.Sources()
|
||||||
|
|
||||||
@ -304,11 +303,8 @@ func (loc *NormalLocationSpec) Find(d *Debugger, scope *proc.EvalScope, locStr s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (loc *OffsetLocationSpec) Find(d *Debugger, scope *proc.EvalScope, locStr string) ([]api.Location, error) {
|
func (loc *OffsetLocationSpec) Find(d *Debugger, pc uint64, locStr string) ([]api.Location, error) {
|
||||||
if scope == nil {
|
file, line, fn := d.process.PCToLine(pc)
|
||||||
return nil, fmt.Errorf("could not determine current location (scope is nil)")
|
|
||||||
}
|
|
||||||
file, line, fn := d.process.PCToLine(scope.PC)
|
|
||||||
if fn == nil {
|
if fn == nil {
|
||||||
return nil, fmt.Errorf("could not determine current location")
|
return nil, fmt.Errorf("could not determine current location")
|
||||||
}
|
}
|
||||||
@ -316,11 +312,8 @@ func (loc *OffsetLocationSpec) Find(d *Debugger, scope *proc.EvalScope, locStr s
|
|||||||
return []api.Location{{PC: addr}}, err
|
return []api.Location{{PC: addr}}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (loc *LineLocationSpec) Find(d *Debugger, scope *proc.EvalScope, locStr string) ([]api.Location, error) {
|
func (loc *LineLocationSpec) Find(d *Debugger, pc uint64, locStr string) ([]api.Location, error) {
|
||||||
if scope == nil {
|
file, _, fn := d.process.PCToLine(pc)
|
||||||
return nil, fmt.Errorf("could not determine current location (scope is nil)")
|
|
||||||
}
|
|
||||||
file, _, fn := d.process.PCToLine(scope.PC)
|
|
||||||
if fn == nil {
|
if fn == nil {
|
||||||
return nil, fmt.Errorf("could not determine current location")
|
return nil, fmt.Errorf("could not determine current location")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user