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

[CPPVSDBG] Debugger truncates long strings when inspecting values #1786

Closed
ghost opened this issue Apr 4, 2018 · 30 comments
Closed

[CPPVSDBG] Debugger truncates long strings when inspecting values #1786

ghost opened this issue Apr 4, 2018 · 30 comments
Labels
bug debugger fixed Check the Milestone for the release in which the fix is or will be available.
Milestone

Comments

@ghost
Copy link

ghost commented Apr 4, 2018

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..

@pieandcakes
Copy link
Contributor

pieandcakes commented Apr 5, 2018

@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 pieandcakes self-assigned this Apr 5, 2018
@ghost
Copy link
Author

ghost commented Apr 5, 2018

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

@pieandcakes pieandcakes changed the title Debugger truncates long strings when inspecting values [CPPVSDBG] Debugger truncates long strings when inspecting values Apr 5, 2018
@callumdmay
Copy link

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

@jemmy512
Copy link

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

@pieandcakes
Copy link
Contributor

@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

@JoffreyAlto
Copy link

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 !

@pieandcakes
Copy link
Contributor

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

@laengand
Copy link

@pieandcakes Any updates on this issue? :-)

@tklajnscek
Copy link

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 :)

@Zvicii
Copy link

Zvicii commented Oct 29, 2021

run into this matter too, any update now?

@bartwalczak
Copy link

Same here. cppvsdbg

@eshulankina
Copy link

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

@mathforlife83
Copy link

@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?

@kushgh
Copy link

kushgh commented Sep 20, 2022

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

@handledexception
Copy link

handledexception commented Jan 3, 2023

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.

@vijay-563
Copy link

Any update on this issue? Any workaround for cppvsdbg?

@sean-mcmanus
Copy link
Contributor

@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.

@jay1975h
Copy link

@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

@sean-mcmanus
Copy link
Contributor

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

@JoffreyAlto
Copy link

JoffreyAlto commented Feb 17, 2023

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.

@abdelmaged
Copy link

Any updates ? Please prioritize this.

@swayhead
Copy link

Same issue here.

@mathforlife83
Copy link

@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.

@hharshada
Copy link

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.

@sean-mcmanus sean-mcmanus added this to the 1.18.0 milestone Sep 18, 2023
@bobbrow bobbrow added the fixed Check the Milestone for the release in which the fix is or will be available. label Oct 3, 2023
@sean-mcmanus
Copy link
Contributor

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

@tklajnscek
Copy link

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

@sean-mcmanus
Copy link
Contributor

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

@tklajnscek
Copy link

tklajnscek commented Apr 15, 2024

@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);
}

@sean-mcmanus
Copy link
Contributor

@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.

@tonyriviere88
Copy link

Any chance the original feature actually implemented?
For me, the main use case is primarily to be able to copy the whole string, like in Visual Studio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug debugger fixed Check the Milestone for the release in which the fix is or will be available.
Projects
None yet
Development

No branches or pull requests