-
Notifications
You must be signed in to change notification settings - Fork 618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add column numbers to profile.proto. #818
Changes from 4 commits
0531560
10a1914
a675f89
2120b2e
073c7cb
b8fe7fd
8f8a0f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ type config struct { | |
TagShow string `json:"tagshow,omitempty"` | ||
TagHide string `json:"taghide,omitempty"` | ||
NoInlines bool `json:"noinlines,omitempty"` | ||
Columns bool `json:"columns,omitempty"` | ||
|
||
// Output granularity | ||
Granularity string `json:"granularity,omitempty"` | ||
|
@@ -124,7 +125,7 @@ func init() { | |
// take on one of a bounded set of values. | ||
choices := map[string][]string{ | ||
"sort": {"cum", "flat"}, | ||
"granularity": {"functions", "filefunctions", "files", "lines", "addresses"}, | ||
"granularity": {"functions", "filefunctions", "files", "lines", "columns", "addresses"}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to instead make this an option like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did make this an option in internal/driver/commands.go. Can you take a look? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should remove it from the granularity list here then? |
||
} | ||
|
||
// urlparam holds the mapping from a config field name to the URL | ||
|
@@ -157,6 +158,7 @@ func init() { | |
"sort": "sort", | ||
"granularity": "g", | ||
"noinlines": "noinlines", | ||
"columns": "columns", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe name it "showcolumns" so that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
} | ||
|
||
def := defaultConfig() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,7 +231,7 @@ func dropEmptyStrings(in []string) (out []string) { | |
} | ||
|
||
func aggregate(prof *profile.Profile, cfg config) error { | ||
var function, filename, linenumber, address bool | ||
var function, filename, linenumber, columnnumber, address bool | ||
inlines := !cfg.NoInlines | ||
switch cfg.Granularity { | ||
case "addresses": | ||
|
@@ -246,6 +246,11 @@ func aggregate(prof *profile.Profile, cfg config) error { | |
function = true | ||
filename = true | ||
linenumber = true | ||
case "columns": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this shouldn't be in the granularity switch anymore and should be handled as option instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
function = true | ||
filename = true | ||
linenumber = true | ||
columnnumber = true | ||
case "files": | ||
filename = true | ||
case "functions": | ||
|
@@ -256,7 +261,7 @@ func aggregate(prof *profile.Profile, cfg config) error { | |
default: | ||
return fmt.Errorf("unexpected granularity") | ||
} | ||
return prof.Aggregate(inlines, function, filename, linenumber, address) | ||
return prof.Aggregate(inlines, function, filename, linenumber, columnnumber, address) | ||
} | ||
|
||
func reportOptions(p *profile.Profile, numLabelUnits map[string]string, cfg config) (*report.Options, error) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -242,23 +242,27 @@ func checkSymbolizedLocation(a uint64, got []profile.Line) error { | |
if g.Line != int64(w.Line) { | ||
return fmt.Errorf("want lineno: %d, got %d", w.Line, g.Line) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: "line" here or "columnno" below? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
} | ||
if g.Column != int64(w.Column) { | ||
return fmt.Errorf("want column: %d, got %d", w.Column, g.Column) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
var mockAddresses = map[uint64][]plugin.Frame{ | ||
1000: {frame("fun11", "file11.src", 10)}, | ||
2000: {frame("fun21", "file21.src", 20), frame("fun22", "file22.src", 20)}, | ||
3000: {frame("fun31", "file31.src", 30), frame("fun32", "file32.src", 30), frame("fun33", "file33.src", 30)}, | ||
4000: {frame("fun41", "file41.src", 40), frame("fun42", "file42.src", 40), frame("fun43", "file43.src", 40), frame("fun44", "file44.src", 40)}, | ||
5000: {frame("fun51", "file51.src", 50), frame("fun52", "file52.src", 50), frame("fun53", "file53.src", 50), frame("fun54", "file54.src", 50), frame("fun55", "file55.src", 50)}, | ||
1000: {frame("fun11", "file11.src", 10, 1)}, | ||
2000: {frame("fun21", "file21.src", 20, 2), frame("fun22", "file22.src", 20, 2)}, | ||
3000: {frame("fun31", "file31.src", 30, 3), frame("fun32", "file32.src", 30, 3), frame("fun33", "file33.src", 30, 3)}, | ||
4000: {frame("fun41", "file41.src", 40, 4), frame("fun42", "file42.src", 40, 4), frame("fun43", "file43.src", 40, 4), frame("fun44", "file44.src", 40, 4)}, | ||
5000: {frame("fun51", "file51.src", 50, 5), frame("fun52", "file52.src", 50, 5), frame("fun53", "file53.src", 50, 5), frame("fun54", "file54.src", 50, 5), frame("fun55", "file55.src", 50, 5)}, | ||
} | ||
|
||
func frame(fname, file string, line int) plugin.Frame { | ||
func frame(fname, file string, line int, column int) plugin.Frame { | ||
return plugin.Frame{ | ||
Func: fname, | ||
File: file, | ||
Line: line} | ||
Func: fname, | ||
File: file, | ||
Line: line, | ||
Column: column} | ||
} | ||
|
||
func TestDemangleSingleFunction(t *testing.T) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
ShowColumns
? See another comment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.