terminal/command: stack command panics when stack has 1 frame
Insure that the digits function always returns at least 1. Fixes #354 (partial)
This commit is contained in:
parent
6c7ad4059b
commit
b94e2bd0ec
@ -819,6 +819,9 @@ func (c *Commands) sourceCommand(t *Term, args string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func digits(n int) int {
|
func digits(n int) int {
|
||||||
|
if n <= 0 {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
return int(math.Floor(math.Log10(float64(n)))) + 1
|
return int(math.Floor(math.Log10(float64(n)))) + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/derekparker/delve/proc/test"
|
"github.com/derekparker/delve/proc/test"
|
||||||
|
"github.com/derekparker/delve/service/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCommandDefault(t *testing.T) {
|
func TestCommandDefault(t *testing.T) {
|
||||||
@ -98,3 +99,8 @@ func TestExecuteFile(t *testing.T) {
|
|||||||
t.Fatalf("Wrong counts break: %d trace: %d\n", breakCount, traceCount)
|
t.Fatalf("Wrong counts break: %d trace: %d\n", breakCount, traceCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue354(t *testing.T) {
|
||||||
|
printStack([]api.Stackframe{ }, "")
|
||||||
|
printStack([]api.Stackframe{{api.Location{PC: 0, File: "irrelevant.go", Line: 10, Function: nil}, nil, nil}}, "")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user