go-delve / delve

Delve is a debugger for the Go programming language.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Printing a slice at non-0 base shows wrong "more"

thockin opened this issue · comments

(dlv) call len(c.variables)
> k8s.io/kubernetes/test/instrumentation.(*metricDecoder).decodeString() ./test/instrumentation/decode_metric.go:201 (PC: 0xaab677)
Values returned:
	: 29
(dlv) p c.variables[28:]
map[string]go/ast.Expr [
	"compbasemetrics.processStartTime": *go/ast.CallExpr {
		Fun: go/ast.Expr(*go/ast.Ident) *{
			NamePos: 651,
			Name: "NewGaugeVec",
			Obj: *go/ast.Object nil,},
		Lparen: 662,
		Args: []go/ast.Expr len: 2, cap: 2, [
			...,
			...,
		],
		Ellipsis: NoPos (0),
		Rparen: 843,}, 
	...+28 more
]

Note the "+28 more".

Delve Debugger
Version: 1.22.0
Build: $Id: 61ecdbbe1b574f0dd7d7bad8b6a5d564cce981e9 $
go version go1.22.0 linux/amd64

You mean 'map' not 'slice' right?

Oh. Interesting point. Why did it let me do slice indexing? Is that new? Is it sorted, and if so by what?

(dlv) l
> main.main() ./file.go:11 (PC: 0x4960ba)
     1:	package main
     2:	
     3:	import "fmt"
     4:	
     5:	func main() {
     6:	... s := []string{"zero", "one", "two", "three", "four", "five"}
     7:	... m := map[string]int{
     8:	... ... "zero": 100, "one": 101, "two": 102,
     9:	... ... "three": 103, "four": 104, "five": 105,
    10:	... }
=>  11:	... fmt.Println(s, m)
    12:	}
(dlv) p s[4:]
[]string len: 2, cap: 2, ["four","five"]
(dlv) p m[4:]
map[string]int [
	"four": 104, 
	"five": 105, 
	...+4 more
]

It appears to be sorted in insert order - is that a quarantee?

Why did it let me do slice indexing? Is that new?

Incremental load, it's been there for years.

Is it sorted, and if so by what? It appears to be sorted in insert order - is that a quarantee?

The order is an implementation detail: it's the order you will get from for range minus the starting point randomization.

Cool! I did not know this worked. Thanks.