Skip to content

Commit 3d256cb

Browse files
authored
Add -all_frames flag that allows disabling the drop / keep frames logic. (#976)
This is occasionally useful for debugging and to inspect raw profile stacks.
1 parent 2866da1 commit 3d256cb

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

internal/driver/cli.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type source struct {
3737
HTTPHostport string
3838
HTTPDisableBrowser bool
3939
Comment string
40+
AllFrames bool
4041
}
4142

4243
// parseFlags parses the command lines through the specified flags package
@@ -51,7 +52,8 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
5152
flagSymbolize := flag.String("symbolize", "", "Options for profile symbolization")
5253
flagBuildID := flag.String("buildid", "", "Override build id for first mapping")
5354
flagTimeout := flag.Int("timeout", -1, "Timeout in seconds for fetching a profile")
54-
flagAddComment := flag.String("add_comment", "", "Annotation string to record in the profile")
55+
flagAddComment := flag.String("add_comment", "", "Free-form annotation to add to the profile")
56+
flagAllFrames := flag.Bool("all_frames", false, "Ignore drop_frames and keep_frames regexps")
5557
// CPU profile options
5658
flagSeconds := flag.Int("seconds", -1, "Length of time for dynamic profiles")
5759
// Heap profile options
@@ -145,6 +147,7 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
145147
HTTPHostport: *flagHTTP,
146148
HTTPDisableBrowser: *flagNoBrowser,
147149
Comment: *flagAddComment,
150+
AllFrames: *flagAllFrames,
148151
}
149152

150153
if err := source.addBaseProfiles(*flagBase, *flagDiffBase); err != nil {
@@ -338,6 +341,8 @@ var usageMsgVars = "\n\n" +
338341
" Port is optional and a randomly available port by default.\n" +
339342
" -no_browser Skip opening a browser for the interactive web UI.\n" +
340343
" -tools Search path for object tools\n" +
344+
" -all_frames Ignore drop_frames and keep_frames regexps in the profile\n" +
345+
" Rarely needed, mainly used for debugging pprof itself\n" +
341346
"\n" +
342347
" Legacy convenience options:\n" +
343348
" -inuse_space Same as -sample_index=inuse_space\n" +

internal/driver/driver_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func TestParse(t *testing.T) {
6161
{"text,files,flat", "heap"},
6262
{"text,files,flat,focus=[12]00,taghide=[X3]00", "heap"},
6363
{"text,inuse_objects,flat", "heap"},
64+
{"text,inuse_objects,flat,all_frames", "heap"},
6465
{"text,lines,cum,hide=line[X3]0", "cpu"},
6566
{"text,lines,cum,show=[12]00", "cpu"},
6667
{"text,lines,cum,hide=line[X3]0,focus=[12]00", "cpu"},
@@ -270,6 +271,7 @@ func solutionFilename(source string, f *testFlags) string {
270271
name = addString(name, f, []string{"seconds"})
271272
name = addString(name, f, []string{"call_tree"})
272273
name = addString(name, f, []string{"text", "tree", "callgrind", "dot", "svg", "tags", "dot", "traces", "disasm", "peek", "weblist", "topproto", "comments"})
274+
name = addString(name, f, []string{"all_frames"})
273275
if f.strings["focus"] != "" || f.strings["tagfocus"] != "" {
274276
name = append(name, "focus")
275277
}

internal/driver/fetch.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ func fetchProfiles(s *source, o *plugin.Options) (*profile.Profile, error) {
7777
}
7878
}
7979

80+
if s.AllFrames {
81+
p.DropFrames = ""
82+
p.KeepFrames = ""
83+
}
84+
8085
// Symbolize the merged profile.
8186
if err := o.Sym.Symbolize(s.Symbolize, m, p); err != nil {
8287
return nil, err
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Showing nodes accounting for 150, 100% of 150 total
2+
flat flat% sum% cum cum%
3+
120 80.00% 80.00% 150 100% operator new (inline)
4+
30 20.00% 100% 30 20.00% pruneme (inline)
5+
0 0% 100% 30 20.00% line1000
6+
0 0% 100% 50 33.33% line2000
7+
0 0% 100% 50 33.33% line2001 (inline)
8+
0 0% 100% 150 100% line3000
9+
0 0% 100% 110 73.33% line3001 (inline)
10+
0 0% 100% 130 86.67% line3002 (inline)
11+
0 0% 100% 30 20.00% malloc (inline)

0 commit comments

Comments
 (0)