Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show the entire value in VSCode debug mode

Tags:

I have been having trouble seeing the entire value of variables while debugging in Go. When I click on a rather long value, it shows me ... +# more. But I can't find a way to see the rest of that value. Even in watch mode it does the same thing, even when I click copy value it copies the ...+# more. Here is an example below. Anyone know how to see the rest of the +114 more?

"Some really really long string..+114 more"

like image 402
coloradoman Avatar asked Jan 15 '20 17:01

coloradoman


People also ask

How can I see value while debugging in Visual Studio?

When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable. If the variable is an object, you can expand the object by clicking on the arrow to see the elements of that object.

How do I show a variable in VS Code debugger?

Start debugging. Execution pauses at the breakpoint. Select the variable a in the code. Select Debug > QuickWatch, press Shift+F9, or right-click and select QuickWatch.


2 Answers

You can configure delve in the vscode settings.json.

There is a parameter called "maxStringLen" you can set it to a higher value. I do not recommend setting the values to high. The debugger can get very slow if you set the maxStringLen, maxArrayValues, etc. to high. So if you play arround with these delve settings and your debugger gets slow, better chose lower values again.

Here is an example showing maxStringLen and some other possible values:

"go.delveConfig": {
    "useApiV1": false,
    "dlvLoadConfig": {
        "followPointers": true,
        "maxVariableRecurse": 3,
        "maxStringLen": 400,
        "maxArrayValues": 400,
        "maxStructFields": -1
    }
}
like image 68
Tobias Theel Avatar answered Oct 29 '22 14:10

Tobias Theel


I needed this answer for my go programming. The answer is a little different than the one provided by Tobias (perhaps I have a newer version of the debugger).

Here's how to change the length of the strings you can see in the debugger:

  1. Set up your go program for debugging (install the go extension for vs code)

  2. In your workspace, there will be a .vscode directory. In there is a file called launch.json. If one does not exist, then when you are about to launch the debugger, you can create one.

  3. Edit the launch.json file. It will have a simple JSON conf in it. Extend that JSON so that it looks like this (I extended the maximum length to 400):

    {
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
    
        {
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceFolder}",
            "apiVersion": 2,
            "dlvLoadConfig": {
                "followPointers": true,
                "maxVariableRecurse": 1,
                "maxStringLen": 400,
                "maxArrayValues": 64,
                "maxStructFields": -1
            }
        }
        ]
    }
    
like image 21
CaptainNickSilver Avatar answered Oct 29 '22 15:10

CaptainNickSilver