Skip to content

Commit

Permalink
pkg/config: add max-variable-recurse parameter (go-delve#1626)
Browse files Browse the repository at this point in the history
* add max-variable-recurse parameter
  • Loading branch information
msaf1980 authored and derekparker committed Jul 23, 2019
1 parent dd3e9e9 commit 38bf1f8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ type Config struct {
// MaxArrayValues is the maximum number of array items that the commands
// print, locals, args and vars should read (in verbose mode).
MaxArrayValues *int `yaml:"max-array-values,omitempty"`
// MaxVariableRecurse is output evaluation depth of nested struct members, array and
// slice items and dereference pointers
MaxVariableRecurse *int `yaml:"max-variable-recurse,omitempty"`

// If ShowLocationExpr is true whatis will print the DWARF location
// expression for its argument.
Expand Down Expand Up @@ -216,6 +219,9 @@ substitute-path:
# Maximum loaded string length.
# max-string-len: 64
# Output evaluation.
# max-variable-recurse: 1
# Uncomment the following line to make the whatis command also print the DWARF location expression of its argument.
# show-location-expr: true
Expand Down
10 changes: 10 additions & 0 deletions pkg/terminal/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,16 @@ func TestConfig(t *testing.T) {
if *term.conf.MaxStringLen != 10 {
t.Fatalf("expected MaxStringLen 10, got: %d", *term.conf.MaxStringLen)
}
err = configureCmd(&term, callContext{}, "max-variable-recurse 4")
if err != nil {
t.Fatalf("error executing configureCmd(max-variable-recurse): %v", err)
}
if term.conf.MaxVariableRecurse == nil {
t.Fatalf("expected MaxVariableRecurse 4, got nil")
}
if *term.conf.MaxVariableRecurse != 4 {
t.Fatalf("expected MaxVariableRecurse 4, got: %d", *term.conf.MaxVariableRecurse)
}

err = configureCmd(&term, callContext{}, "substitute-path a b")
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/terminal/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ func (t *Term) loadConfig() api.LoadConfig {
if t.conf != nil && t.conf.MaxArrayValues != nil {
r.MaxArrayValues = *t.conf.MaxArrayValues
}
if t.conf != nil && t.conf.MaxVariableRecurse != nil {
r.MaxVariableRecurse = *t.conf.MaxVariableRecurse
}

return r
}
Expand Down

0 comments on commit 38bf1f8

Please sign in to comment.