|
@@ -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 {
|
|
@@ -221,15 +223,10 @@ func parseCommandLine(input []string) ([]string, variables, error) {
|
221
|
223
|
c := pprofCommands[name]
|
222
|
224
|
if c == nil {
|
223
|
225
|
// Attempt splitting digits on abbreviated commands (eg top10)
|
224
|
|
- for i := len(name); i > 0; i-- {
|
225
|
|
- if !strings.ContainsAny(name[i-1:i], "0123456789") {
|
226
|
|
- if n, d := name[:i], name[i:]; n != "" && d != "" {
|
227
|
|
- cmd[0], args = n, append([]string{d}, args...)
|
228
|
|
- name = n
|
229
|
|
- c = pprofCommands[n]
|
230
|
|
- }
|
231
|
|
- break
|
232
|
|
- }
|
|
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]
|
233
|
230
|
}
|
234
|
231
|
}
|
235
|
232
|
if c == nil {
|