Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix starlark map iteration for maps > 64 entries #1699

Merged
merged 2 commits into from
Oct 7, 2019

Conversation

alxn
Copy link
Contributor

@alxn alxn commented Sep 24, 2019

I discovered that dlv wasn't correctly iterating over maps larger than 64 elements.

Ref: https://github.com/go-delve/delve/blob/master/Documentation/cli/expr.md#elements-limit

For arrays, slices, strings and maps delve will only return a maximum of 64 elements at a time:

package main

import (
	"runtime"
	"strconv"
)

func main() {
	m := make(map[string]int)
	for i := 0; i < 256; i++ {
		m[strconv.Itoa(i)] = i
	}
	runtime.Breakpoint()
}
i = 0
m = eval(None, "m")
print(m.Variable.Len)
for item in m.Variable.Value:
	i = i + 1
print(i)
(dlv) source iterate.star
256
128

This was because in mapVariableAsStarlarkValueIterator.Next(), we are iterating in 2s, but we are not resuming /2 for the next offset.

Copy link
Member

@aarzilli aarzilli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you.

Copy link
Member

@derekparker derekparker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derekparker derekparker merged commit 36d688b into go-delve:master Oct 7, 2019
@alxn alxn deleted the alun/iterate-map branch October 7, 2019 18:09
cgxxv pushed a commit to cgxxv/delve that referenced this pull request Mar 25, 2022
…lve#1699)

* Fix starlark map iteration for maps > 64 entries

* Fix TestMapEvaluation
abner-chenc pushed a commit to loongson/delve that referenced this pull request Mar 1, 2024
…lve#1699)

* Fix starlark map iteration for maps > 64 entries

* Fix TestMapEvaluation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants