vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

[CPPVSDBG] Debugger truncates long strings when inspecting values

Open ghost opened this issue 7 years ago • 14 comments

When inspecting values in the debugger, long strings are truncated, which, for example, makes it impossible to see the rest of this exception message here:

image

The value is also truncated if I right-click the message on the "variables" window and click "Copy Value". The value also gets truncated in the debug console, if I try printing it there. I don't think there's currently any way to view this string without it getting truncated.

I have the latest stable of VS Code (1.21.1) and vscode-cpptools (0.16.1) installed.

Right now I'm working around this by modifying the code to print the message to std::cout before throwing, but that's obviously not ideal..

ghost avatar Apr 04 '18 10:04 ghost

@aleksijuvani I assume you are using gdb. This looks like the default setting for gdb which is 200 characters. You can add a command to increase it to unlimited by using set print elements <size> where size is the number of elements and 0 being unlimited.

So in your launch.json, add the following block to the "setupCommands": array:

                {
                    "text": "-interpreter-exec console \"set print elements 0\"",
                    "ignoreFailures": true
                }

to make it unlimited.

pieandcakes avatar Apr 05 '18 01:04 pieandcakes

@pieandcakes Sorry, I forgot to mention this. I'm using the cppvsdbg debugger.

ghost avatar Apr 05 '18 09:04 ghost

Was there ever a solution to this issue? Seems like the answer above is for gdb and not cppvsdbg. The truncation is a real issue when trying to copy long strings or byte arrays in the local variables list

callumdmay avatar Sep 20 '19 17:09 callumdmay

@pieandcakes Is there any solution? LLDB also meets this problem, this is unacceptable

jemmy512 avatar Oct 12 '19 17:10 jemmy512

@JemmyWong Any solution for truncation in cppvsdbg will be in the debugger itself and will not apply to lldb. You can try the solution for gdb for lldb

pieandcakes avatar Oct 14 '19 22:10 pieandcakes

Hello @pieandcakes : Is there any update about this issue ? I've also been using CPPVSDBG for a while and still can't copy large string values. Since I'm not using GDB, I couldn't figure out any kind of parameter that would allow to extend that characters limit.

This is really annoying, since copying and analyzing data from the variables tab is one of the major features for a real-time debugger. Thanks in advance for your response !

JoffreyAlto avatar Feb 11 '20 15:02 JoffreyAlto

@JoffreyAlto I haven't had time to investigate yet, but it is on my list.

pieandcakes avatar Feb 11 '20 18:02 pieandcakes

@pieandcakes Any updates on this issue? :-)

laengand avatar Jan 22 '21 07:01 laengand

Just hit this issue myself. It's pretty bad that VS Code doesn't seem to have a nice multi-line string view, but then this just makes it completely useless when debugging strings :)

tklajnscek avatar Sep 24 '21 08:09 tklajnscek

run into this matter too, any update now?

Zvicii avatar Oct 29 '21 02:10 Zvicii

Same here. cppvsdbg

bartwalczak avatar Nov 07 '21 12:11 bartwalczak

Hi, Do you have any updates for this issue regarding cppvsdbg?

eshulankina avatar Dec 13 '21 14:12 eshulankina

@pieandcakes This is an important feature that is not working, first reported in 2018, what's the status update on it, and would it be possible to prioritize this bug?

mathforlife83 avatar Jul 05 '22 13:07 mathforlife83

Solution that worked for me : start debugger, in your debug console write: -exec set print elements 1000

You can modify 1000 to any other number. 0 signifies no limit(not recommended as some variables can be nasty).

image

kushgh avatar Sep 20 '22 10:09 kushgh

Is there a solution to this on Windows when debugging with cppvsdbg using the MSVC debugger? I am running VSCode 1.74.2 on Windows 10.

I tried the suggested solution of typing -exec set print elements 1000 into the Debug Console, after starting the debugger, but that resulted in an error: identifier "exec" is undefined

image

NOTE: That I am trying to debug pure C code using the MSVC debugger components installed from Visual Studio 2019.

handledexception avatar Jan 03 '23 07:01 handledexception

Any update on this issue? Any workaround for cppvsdbg?

vijay-563 avatar Jan 16 '23 15:01 vijay-563

@vijay-563 We don't have an update on this issue. One "workaround" may be to log the string value to stdout or a file.

sean-mcmanus avatar Feb 03 '23 01:02 sean-mcmanus

@sean-mcmanus Any chance to prioritize this issue, a debugger should be able to inspect long strings. For me, it feels like a high-priority bug

jay1975h avatar Feb 16 '23 07:02 jay1975h

@jay1975h I'll let the debugger team know that this bug is the most upvoted debugger bug.

sean-mcmanus avatar Feb 16 '23 20:02 sean-mcmanus

To people here still looking for a resolution, since there's no update on the issue I figured out some kind of way to get copy large strings. Using the "Watch" or "Variable" tab when in debugging feature, identify the string you want to copy then click on the "View binary data" icon, at the right of the string value as showed below.

CPPVSDBG - 01

Then now the tab "memory.bin" is open, just copy your value from the "Decoded text" section using your mouse cursor or a simple click at the beginning of the string, and shift+click at the ending of your string.

CPPVSDBG - 02

Copy it, then you will be able to paste the string value to another text support. I hope it helps.

JoffreyAlto avatar Feb 17 '23 08:02 JoffreyAlto

Any updates ? Please prioritize this.

abdelmaged avatar May 02 '23 14:05 abdelmaged

Same issue here.

swayhead avatar May 28 '23 15:05 swayhead

@pieandcakes @sean-mcmanus @vscode @Colengms

I don't understand this at all, you wrote that this is most upvoted debugger bug yet nothing happens. The bug was open Apr 4, 2018, why is not being fixed, how can the developers at Microsoft do nothing?

You are committed all kinds of useless stuff, for example -> Fix change "eg." to "e.g.". Fix the things that are important instead.

mathforlife83 avatar Jun 27 '23 06:06 mathforlife83

We have determined that your valuable suggestion has a broad community impact and will improve the product experience. We have added the feature to our roadmap and will keep you updated soon as we make progress. We highly appreciate your contribution in making our product better.

hharshada avatar Jul 05 '23 21:07 hharshada

Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.18.0

sean-mcmanus avatar Oct 13 '23 17:10 sean-mcmanus

Is this actually fixed? I still see strings truncated to ~200 characters in hovers, watch & when evaluating the string in the debug console...

VSCode: 1.88.1 CppTools: 1.19.9

tklajnscek avatar Apr 12 '24 09:04 tklajnscek

@tklajnscek Are you using cppvsdbg or cppdbg? It's working for me with cppvsdbg. Are you referring to std::string? Which implemention? MSVC?

sean-mcmanus avatar Apr 12 '24 20:04 sean-mcmanus

@sean-mcmanus

  • cppvsdbg
  • either std::string or a just a plain char*
  • compiled with CMake/Ninja using MSVC 19.37.32824.0

image image image image

It's literally this:

# CMakeLists.txt
cmake_minimum_required(VERSION 3.20)
project(string_test)

add_executable(string_test main.cpp)

and:

// main.cpp
#include <stdio.h>
#include <string>

void main() {
    std::string str = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
    const char* cstr = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
    printf("str: %s\n", str.c_str());
    printf("cstr: %s\n", cstr);
}

tklajnscek avatar Apr 15 '24 15:04 tklajnscek

@tklajnscek I see -- I was looking at the data as an array of characters and the characters are all visible in the debugger that way. I'm not sure if that is intentional or not.

sean-mcmanus avatar Apr 16 '24 00:04 sean-mcmanus