debugger/locations: prioritize exact matches of function names (#651)

If the location specification matches the name of a function exactly
return that function as a match event if the expression matches other
functions as well.

Without this some functions, like math/rand.Intn are unmatchable.
This commit is contained in:
Alessandro Arzilli
2016-10-22 07:04:03 +02:00
committed by Derek Parker
parent f6e8fb37a4
commit 6e882c50fa
3 changed files with 30 additions and 2 deletions

View File

@ -666,6 +666,18 @@ func TestClientServer_FindLocationsAddr(t *testing.T) {
})
}
func TestClientServer_FindLocationsExactMatch(t *testing.T) {
// if an expression matches multiple functions but one of them is an exact
// match it should be used anyway.
// In this example "math/rand.Intn" would normally match "math/rand.Intn"
// and "math/rand.(*Rand).Intn" but since the first match is exact it
// should be prioritized.
withTestClient2("locationsprog3", t, func(c service.Client) {
<-c.Continue()
findLocationHelper(t, c, "math/rand.Intn", false, 1, 0)
})
}
func TestClientServer_EvalVariable(t *testing.T) {
withTestClient2("testvariables", t, func(c service.Client) {
state := <-c.Continue()