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

Long strings in variable inspection get truncated #868

Closed
sirikon opened this issue Mar 16, 2017 · 6 comments
Closed

Long strings in variable inspection get truncated #868

sirikon opened this issue Mar 16, 2017 · 6 comments
Labels
Milestone

Comments

@sirikon
Copy link

sirikon commented Mar 16, 2017

When trying to debug a long string, it gets truncated, and trying to copy it using the right-click context menu, returns the actual truncated value, with "...74 more" string.

VSCode itself adds ellipsis in that element when it's too long, maybe should directly print here the full length variable. Or, at least, when using the "Copy value" context menu, copy the real (and full length) one.

image

Seems like this happens because Delve returns a 'Len' prop shorter than the actual one, and this is like this by design: https://github.com/derekparker/delve/issues/659#issuecomment-256945278

@michaelmello
Copy link

michaelmello commented Mar 18, 2017

So it looks like vscode uses v1 of the delve API: https://github.com/derekparker/delve/blob/master/service/rpc1/server.go

Unfortunately, v1 does not allow the client to change the default length of the variable value, which is set to 64 bytes.
image
image
image

As a workaround, we can simply change the source of delve to return more than 64 bytes.

1.) Navigate to %GOPATH%\src\github.com\derekparker\delve\service\rpc1\server.go
2.) Look for the defaultLoadConfig variable and change the third argument value of 64, which is the field: MaxStringLen. I set mine to 500.
image
image

3.) Compile and install your modified version of delve. Navigate to %GOPATH%\src\github.com\derekparker\delve\cmd\dlv, and then run the command: go install.

@edburns
Copy link
Member

edburns commented Mar 2, 2018

Any idea why this hasn't been merged yet?

@lggomez
Copy link
Contributor

lggomez commented Mar 3, 2018

@edburns this is a hack in the delve debugger rather than a fix on the extension side

To fix this on the extension we have to use the delve v2 api call instead of the old one:
https://godoc.org/github.com/derekparker/delve/service/rpc2#RPCServer.ListLocalVars
https://godoc.org/github.com/derekparker/delve/service/api#LoadConfig

The place to make the change is here. I'm trying to take a look at it

@jgfet
Copy link

jgfet commented May 30, 2018

Why isn't there debug string length key with a value for this in settings that we can just set instead?

@lggomez
Copy link
Contributor

lggomez commented May 30, 2018

@jgfet because the original delve API did not support this in an explicit way and the vs debug adapter used that version, hence the need to add support to v2 as explained in #1555

The work is already merged to master (still to be released) and the new launch.json configuration options can be seen here: https://github.com/Microsoft/vscode-go/blob/master/package.json#L421-L464

@ramya-rao-a
Copy link
Contributor

With #1555 now complete (thanks to @lggomez!), this bug can be fixed when using the latest update to the Go extension (0.6.81)

Just update your debug configuration as per #1555 (comment)

@ramya-rao-a ramya-rao-a added this to the 0.6.81 milestone Jun 4, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants