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

debug: incorrect expression for loading map children results in evaluation error #1052

Closed
polinasok opened this issue Dec 23, 2020 · 2 comments
Assignees
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge

Comments

@polinasok
Copy link
Contributor

Code:

nestedmap := map[string]interface{}{
		"issuer": map[string]interface{}{
			"foo1": map[string]interface{}{
				"foo2": "bar2",
			},
		},
	}
runtime.Breakpoint()

Launch configuration:

           "trace":"verbose",
           "dlvLoadConfig": {
                "followPointers": true,
                "maxVariableRecurse": 0, // <=================== change from default 1
                "maxStringLen": 64,
                "maxArrayValues": 64,
                "maxStructFields": -1
            }

At breakpoint, expand nestedmap in VARIABLES pane.
Logging output:

From client: variables({"variablesReference":1000})
To client: {"seq":0,"type":"response","request_seq":12,"command":"variables","success":true,"body":{"variables":[{"name":"nestedmap","value":"<map[string]interface {}> (length: 1)","evaluateName":"nestedmap","variablesReference":1001}]}}
VariablesResponse [
 {
  "name": "nestedmap",
  "value": "<map[string]interface {}> (length: 1)",
  "evaluateName": "nestedmap",
  "variablesReference": 1001
 }
]
// Expanding "nestedmap" triggers another variables request
From client: variables({"variablesReference":1001})
Failed to eval expression:  {
 "Expr": "nestedmap.nestedmap[\"issuer\"]",
 "Scope": {
  "goroutineID": -1,
  "frame": 0
 },
 "Cfg": {
  "followPointers": true,
  "maxVariableRecurse": 0,
  "maxStringLen": 64,
  "maxArrayValues": 64,
  "maxStructFields": -1
 }
} 

Eval error: nestedmap (type map[string]interface {}) is not a struct
Failed to evaluate expression - nestedmap (type map[string]interface {}) is not a struct
To client: {"seq":0,"type":"response","request_seq":13,"command":"variables","success":true,"body":{"variables":[{"name":"\"issuer\"","value":"<interface {}(map[string]interface {})>)","evaluateName":"nestedmap[\"issuer\"]","variablesReference":1002}]}}
VariablesResponse [
 {
  "name": "\"issuer\"",
  "value": "<interface {}(map[string]interface {})>)",
  "evaluateName": "nestedmap[\"issuer\"]",
  "variablesReference": 1002
 }
]

Even though evaluateName looks correct (and would trigger the right expression loading behavior if used with "Add to Watch"), the corresponding expression used as part of variable loading is incorrect (nestedmap.nestedmap[\"issuer\"]). The expression logic treats fullyQualifiedName as the parent prefix that must be combined with the variable name for a full evaluate name while in other instances throughout the code it is treated as the full evaluate name (example, example). Moreover, unlike for arrays/slices and structs, this expression does not follow the delve spec.

@polinasok
Copy link
Contributor Author

This will need to be addressed in dlv-dap when we add on-demand variable loading for maps.

@polinasok
Copy link
Contributor Author

image

@golang golang locked and limited conversation to collaborators May 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

3 participants