diff --git a/internal/driver/webui_test.go b/internal/driver/webui_test.go index 4a7b31d324..59622eac04 100644 --- a/internal/driver/webui_test.go +++ b/internal/driver/webui_test.go @@ -91,6 +91,8 @@ func TestWebInterface(t *testing.T) { []string{"300ms.*F1", "200ms.*300ms.*F2"}, false}, {"/disasm?f=" + url.QueryEscape("F[12]"), []string{"f1:asm", "f2:asm"}, false}, + {"/disasm?f=" + url.QueryEscape("^F2$"), + []string{"ROUTINE ======================== F2"}, false}, {"/flamegraph", []string{ "File: testbin", // Check that interesting frames are included. @@ -168,7 +170,7 @@ func (f fakeObj) SourceLine(addr uint64) ([]plugin.Frame, error) { return nil, fmt.Errorf("SourceLine unimplemented") } func (f fakeObj) Symbols(r *regexp.Regexp, addr uint64) ([]*plugin.Sym, error) { - return []*plugin.Sym{ + syms := []*plugin.Sym{ { Name: []string{"F1"}, File: fakeSource, Start: addrBase, End: addrBase + 10, @@ -181,7 +183,17 @@ func (f fakeObj) Symbols(r *regexp.Regexp, addr uint64) ([]*plugin.Sym, error) { Name: []string{"F3"}, File: fakeSource, Start: addrBase + 20, End: addrBase + 30, }, - }, nil + } + if r == nil { + return syms, nil + } + var matched []*plugin.Sym + for _, sym := range syms { + if r.MatchString(sym.Name[0]) { + matched = append(matched, sym) + } + } + return matched, nil } type fakeObjTool struct{} diff --git a/internal/report/report.go b/internal/report/report.go index 73a601c3e3..951bb16908 100644 --- a/internal/report/report.go +++ b/internal/report/report.go @@ -523,7 +523,7 @@ func symbolsFromBinaries(prof *profile.Profile, g *graph.Graph, rx *regexp.Regex // samples and are matched to the regexp. fileHasSamplesAndMatched := make(map[string]bool) for _, n := range g.Nodes { - if name := n.Info.PrintableName(); rx.MatchString(name) && n.Info.Objfile != "" { + if n.Info.Objfile != "" && (rx.MatchString(n.Info.Name) || rx.MatchString(n.Info.PrintableName())) { fileHasSamplesAndMatched[n.Info.Objfile] = true } }