Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Debugger does not display values in array of struct on VARIABLES pane and debug: Evaluate command. #1010

Closed
ghost opened this issue May 27, 2017 · 6 comments · Fixed by #2301
Assignees
Labels

Comments

@ghost
Copy link

ghost commented May 27, 2017

I would like to inspect variables in array of struct.
I know 'Add to Watch' works fine for this request. but this is not a convenient way.

Here is the sample I wrote.

package main

import (
	"fmt"
)

// ItemStruct is item
type ItemStruct struct {
	Num1 int
	Num2 int
}

// OwnerStruct holds item list and pointer list
type OwnerStruct struct {
	ItemList        []ItemStruct
	ItemPointerList []*ItemStruct
}

func main() {
	// initialize part
	list := make([]ItemStruct, 0, 2)
	plist := make([]*ItemStruct, 0, 2)
	for i := 0; i < 2; i++ {
		item := ItemStruct{Num1: i, Num2: i + 1}
		list = append(list, item)
		plist = append(plist, &item)
	}
	owner := OwnerStruct{
		ItemList:        list,
		ItemPointerList: plist}

	// watch variable here on debugger
	fmt.Println(owner)
}

and the screenshot.
image

@ramya-rao-a
Copy link
Contributor

Thanks for reporting @yoskeoka
And thanks for the sample code as well, I can repro this.

@roblourens Can this be done?

@roblourens
Copy link
Member

roblourens commented May 31, 2017

Looking at the code, it's not obvious whether we can do it without evaluating all the variables like the watches window does. I'm not sure what other info we can get out of Delve. Would have to investigate some more.

@RealVidy
Copy link

RealVidy commented Feb 9, 2018

Hi, I am bumping this up because being able to see the content of the variables we are debugging is actually important :)

Thanks for taking the time to look into this!

@christian-boks
Copy link

Getting this fixed would be really nice. It is one of the small things that would make Go debugging support feel as complete as the Javascript debugging support. Which is just incredible.

@ramya-rao-a
Copy link
Contributor

If anyone wants to take a stab at this, the place to get started is the variablesRequest method in the goDebug.ts file. For setup, please see the simple instructions in the README for debugging

@ramya-rao-a
Copy link
Contributor

Nested content is now shown in the latest update (0.9.0) to the Go extension.
Huge thanks to @jhendrixMSFT who made this happen!

@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@roblourens @RealVidy @jhendrixMSFT @christian-boks @ramya-rao-a and others