Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions internal/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,10 @@ func PrintAssembly(w io.Writer, rpt *Report, obj plugin.ObjTool, maxFuncs int) e
// If the regexp source can be parsed as an address, also match
// functions that land on that address.
var address *uint64
if hex, err := strconv.ParseUint(o.Symbol.String(), 0, 64); err == nil {
address = &hex
if o.Symbol != nil {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think o.Symbol is nil in the described scenario, I think it points to a regexp for empty string.

If o.Symbol was nil, o.Symbol.String() would panic.

I don't think this PR fixes anything, so I'll close it.

if hex, err := strconv.ParseUint(o.Symbol.String(), 0, 64); err == nil {
address = &hex
}
}

fmt.Fprintln(w, "Total:", rpt.formatValue(rpt.total))
Expand Down Expand Up @@ -436,7 +438,11 @@ func PrintAssembly(w io.Writer, rpt *Report, obj plugin.ObjTool, maxFuncs int) e
if len(syms) == 0 {
// The symbol regexp case
if address == nil {
return fmt.Errorf("no matches found for regexp %s", o.Symbol)
symStr := ""
if o.Symbol != nil {
symStr = o.Symbol.String()
}
return fmt.Errorf("no matches found for regexp %s", symStr)
}

// The address case
Expand Down
14 changes: 11 additions & 3 deletions internal/report/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func printSource(w io.Writer, rpt *Report) error {
var functions graph.Nodes
functionNodes := make(map[string]graph.Nodes)
for _, n := range g.Nodes {
if !o.Symbol.MatchString(n.Info.Name) {
if o.Symbol != nil && !o.Symbol.MatchString(n.Info.Name) {
continue
}
if functionNodes[n.Info.Name] == nil {
Expand All @@ -60,7 +60,11 @@ func printSource(w io.Writer, rpt *Report) error {
functions.Sort(graph.NameOrder)

if len(functionNodes) == 0 {
return fmt.Errorf("no matches found for regexp: %s", o.Symbol)
symStr := ""
if o.Symbol != nil {
symStr = o.Symbol.String()
}
return fmt.Errorf("no matches found for regexp: %s", symStr)
}

sourcePath := o.SourcePath
Expand Down Expand Up @@ -251,7 +255,11 @@ func MakeWebList(rpt *Report, obj plugin.ObjTool, maxFiles int) (WebListData, er
}
sp := newSourcePrinter(rpt, obj, sourcePath)
if len(sp.interest) == 0 {
return WebListData{}, fmt.Errorf("no matches found for regexp: %s", rpt.options.Symbol)
symStr := ""
if rpt.options.Symbol != nil {
symStr = rpt.options.Symbol.String()
}
return WebListData{}, fmt.Errorf("no matches found for regexp: %s", symStr)
}
defer sp.close()
return sp.generate(maxFiles, rpt), nil
Expand Down
Loading