|
@@ -17,6 +17,7 @@ package driver
|
17
|
17
|
import (
|
18
|
18
|
"fmt"
|
19
|
19
|
"io"
|
|
20
|
+ "regexp"
|
20
|
21
|
"sort"
|
21
|
22
|
"strconv"
|
22
|
23
|
"strings"
|
|
@@ -27,6 +28,7 @@ import (
|
27
|
28
|
)
|
28
|
29
|
|
29
|
30
|
var commentStart = "//:" // Sentinel for comments on options
|
|
31
|
+var tailDigitsRE = regexp.MustCompile("[0-9]+$")
|
30
|
32
|
|
31
|
33
|
// interactive starts a shell to read pprof commands.
|
32
|
34
|
func interactive(p *profile.Profile, o *plugin.Options) error {
|
|
@@ -218,7 +220,15 @@ func parseCommandLine(input []string) ([]string, variables, error) {
|
218
|
220
|
cmd, args := input[:1], input[1:]
|
219
|
221
|
name := cmd[0]
|
220
|
222
|
|
221
|
|
- c := pprofCommands[cmd[0]]
|
|
223
|
+ c := pprofCommands[name]
|
|
224
|
+ if c == nil {
|
|
225
|
+ // Attempt splitting digits on abbreviated commands (eg top10)
|
|
226
|
+ if d := tailDigitsRE.FindString(name); d != "" && d != name {
|
|
227
|
+ name = name[:len(name)-len(d)]
|
|
228
|
+ cmd[0], args = name, append([]string{d}, args...)
|
|
229
|
+ c = pprofCommands[name]
|
|
230
|
+ }
|
|
231
|
+ }
|
222
|
232
|
if c == nil {
|
223
|
233
|
return nil, nil, fmt.Errorf("Unrecognized command: %q", name)
|
224
|
234
|
}
|