go-delve/delve · error
too many arguments to trace
Error message
too many arguments to trace
What it means
The 'trace'/'tracepoint' terminal command in Delve is being used with a positional argument while inside an 'on <bp>' breakpoint context. In 'on' mode the command takes no arguments because it only toggles the tracepoint flag on the existing breakpoint; extra text cannot be interpreted, so Delve rejects it with this error.
Source
Thrown at pkg/terminal/command.go:2010
})
if err != nil {
return nil, err
}
}
}
}
return created, nil
}
func breakpoint(t *Term, ctx callContext, args string) error {
_, err := setBreakpoint(t, ctx, false, args)
return err
}
func tracepoint(t *Term, ctx callContext, args string) error {
if ctx.Prefix == onPrefix {
if args != "" {
return errors.New("too many arguments to trace")
}
ctx.Breakpoint.Tracepoint = true
return nil
}
_, err := setBreakpoint(t, ctx, true, args)
return err
}
func getEditorName() (string, []string, error) {
var editor string
if editor = os.Getenv("DELVE_EDITOR"); editor == "" {
if editor = os.Getenv("EDITOR"); editor == "" {
return "", nil, errors.New("Neither DELVE_EDITOR or EDITOR is set")
}
}
editorParts := strings.Fields(editor)
editor = editorParts[0]View on GitHub (pinned to a23773e6c3)
Solutions
- Remove all arguments: use 'on <bp> trace' with nothing after 'trace'.
- If you meant to create a new tracepoint at a location, drop the 'on' prefix and run 'trace <file:line>' instead.
- If you wanted breakpoint variables printed on hit, use 'on <bp> print <expr>' rather than passing args to trace.
Example fix
// before (dlv) on 1 trace main.myVar // after (dlv) on 1 trace
Defensive patterns
Strategy: validation
Validate before calling
// in scripts driving the dlv terminal (batch/file mode)
func validateOnTrace(cmd string) error {
if strings.HasPrefix(cmd, "on ") && strings.HasSuffix(cmd, "trace") &&
len(strings.Fields(cmd)) != 3 {
return fmt.Errorf("'on <bp> trace' takes no arguments: %q", cmd)
}
return nil
} Type guard
// Go: narrow a parsed command line before executing
func isBareTrace(ctxPrefix, args string) bool {
return ctxPrefix == "on" && args == ""
} Try / catch
if err := term.Cmd.Tracepoint(ctx, args); err != nil {
if err.Error() == "too many arguments to trace" {
// retry with bare command
return term.Cmd.Tracepoint(ctx, "")
}
return err
} Prevention
- Never append arguments to 'trace' inside 'on <bp>' blocks
- Use 'trace <loc>' without the on-prefix to create a new tracepoint
- Check 'help on' / 'help trace' for the no-arg form
- Automate terminal scripts with argument-count validation
When it happens
Trigger: Running 'on <breakpoint-id> trace <something>' with non-empty args, i.e. typing 'trace' with any extra argument while ctx.Prefix == onPrefix in the tracepoint handler (pkg/terminal/command.go tracepoint).
Common situations: Users habitually appending an expression or file:line to 'trace' the way they do with plain 'break', not realizing that inside an 'on' block trace takes no target.
Related errors
- filter not supported on breakpoint
- argument of deferred must be a number greater than 0 (use 's
- too many arguments to restart
- Invalid next count
- missing filename after -save flag
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/ed52e81e479d87d6.
Report an issue: GitHub.