-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Cannot inspect the content of STL containers in debugger #69
Comments
@hungys, sorry for the delayed response. Try typing "-exec set print pretty" in the debug console. This will turn on pretty printing for gdb. We turned it off by default because of performance issues. |
The option pretty print only affect the way how gdb print structures. |
I'm seeing the same thing, it would be really nice if VSCode could use the pretty printers when show STL variables in mouse hovers and the Watch window. |
Type "-exec -enable-pretty-printing" in the debug console. |
@delmyers @paulmaybee Thanks. It works now with |
Yes works for me too and I second the need for some way to set it as the default configuration or event some way to provide a list of command gdb at launch. I tried adding it my ~/.gdbinit file and it doesn't seem to work. |
You can setup initial gdb commands this way in the launch.json
|
@filipsky |
I found it here {just search for setupCommands on the page): I have added the setupCommands block in my OS specific ( Best, Honza |
Thank you, I figured out that it works if the OS specific block is in the Matt S. On Wed, Oct 26, 2016 at 9:27 AM filipsky notifications@github.com wrote:
|
macOS for lldb |
@yoyo930021 If you download our new version, |
This issue should be resolved as we have added the gdb pretty printer commands by default in the |
Hi, how do I set up pretty printing for VS Code? I'm running GDB on Cygwin (Windows 10) . Specifically, I don't understand what to do with said ".gdbinit" file. Thank you very much! |
@jhscsc If you are using the default pretty-printers you don't need to do anything with a In your
If not, then add that and it should tell |
If you expand the variable in your locals, does it show a formatted value? |
Installing |
I am using gdb 8.0.1 on my PC, and if I use gdb from command line, it can print the inner content of the STL classes correctly. But when I am using vscode, both OS: Arch Linux |
I tried all the steps in this github issue. I am using the MinGW compiler and I made sure to install the I have Python 3.6. Do I seriously need to install Python 2.7 ? IS there a solution that uses Python 3 ? :/ Update Also this is the command I am using to build the C++ executable : |
@DollarAkshay That looks correct. To be clear: Pretty printing is something that gdb provides, although from this thread it looks like it isn't the same across different implementations. Your question about which version of Python should probably be asked to MinGW as that is the tool set that you are using and they control the dependencies for the toolset? From searching online, it looks like the MinGW pretty-printing is a lot harder to setup and you will need to set The document I found that sort of explains some steps for MinGW is here, scroll to the section labeled "This is for MinGW users...". |
@Snape3058 The only documentation I found is this. I don't know if that is something you can check/verify/try but that might get you started in the right direction. |
@pieandcakes Okay. I finally switched to Cygwin GDB and installed the Now it shows only the basic array for a vector. If I want it to show like the capacity, size and other data members, like how VisualStudio does it, I will have to use a custom |
@DollarAkshay I assume so. We don't do anything special for visualization so it is whatever |
I've also encountered this problem on Debian, however, the solution is to install the GDB package which is linked to python2. When you install the On newer GCC/GDB versions (I'm using 8.2.0/8.1) you no longer need a .gdbinit file, unless you need something custom. |
@ismailhkose Can you include a log? This looks like a pretty printing issue within the debugger you are using but the log would show us what we are getting back from |
I'm getting this issue on MacOS 10.13.6 with Python 3.6.5, LLDB 1000.11.38.2 and C/C++ extension 0.21.0. When I put
I'm assuming this means my version of LLDB doesn't support pretty printing? Is there anything else I'd need to download? |
It is the |
@x6herbius the pretty printing command is a feature of |
@knayan111 Please run |
This also happens to me. I am using mac 10.14.6, with vscode 1.42, c/c++ plugin is 0.26.3, gdb 8.3. I cannot see the content of any STL containers, this is awful. |
@knayan111 @jinlingchristopher In reading this StackOverflow article it looks like you are missing the I would expect something like This article might also give you some hints on how to get it for macOS and its limitations depending on the compiler ( |
This issue is not resolved at all, please reopen. Even with the pretty printer setting in |
@jaques-sam Can you paste your output for |
Not working+1, my gdb launch.json looks like this: {
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/src/target",
"args": ["-x4", "-k12M"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
] can't not display the contents of stl, using vscode on winodows 10 using WSL 2 |
@yueyingjuesha From what source did you installed your gdb? I'm using Mingw-w64 8.1.0.0 with Windows 10 and VSCode stable + cpptools stable and have no issue. I'm also using WSL 2 and ArchLinux with all latest packages and still no issue. {
"name": "Clang++: Current file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"cwd": "${workspaceFolder}",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "clang++ build active file"
} |
For Windows: I found one valid solution, when installing MinGW in x64 Windows, install win32 version of MinGW download: More details, see: |
I was able to solve this issue for
Hope this helps someone. |
Using Windows 10, 64 bit, I tried @yanglr 's comment. That's all. |
Worked for me |
@ParkHaeChan Happy to know that. 😎 |
@DollarAkshay I have also installed cygwin since mingw didn't work with windows 64 for some reason, but mine is not even starting the debugging process. Could anyone please look into this and suggest what should I do to remove the error. gdb works fine outside vscode(i.e. in the terminal). Also it seems like the link given by @yanglr is broken. If anyone has a recent fix to pretty printing the contents of STL containers in windows 64, please let me know. Thanks in advance. |
If anyone happens to be in a conda/mamba environment, this did it for me (Using the micromamba extension):
Note that you don't need to adjust the cxx standard number above - this is presumably with the breaking ABI changes around C++11. |
It works for me, change the gcc version to the local one in ubuntu. |
very very thinks, it work for me |
@herrberk {
"description": "Enable pretty-printing for gdb",
"text": "python import sys;sys.path.insert(0, 'C:\\Users\\Administrator\\stlprettyprinter');from libstdcxx.v6.printers import register_libstdcxx_printers;register_libstdcxx_printers(None)",
"ignoreFailures": false
} |
How to address this issue in windows 11 |
Currently when I tried to inspect a STL container or a C++ string, the debugger are not able to provide useful information such as the content of a STL vector or string variable. As shown in the screenshot, I have a pretty printer registered to
.gdbinit
and I'm able to use-exec print v
to see the content of a vector (even a string), but it seems the VSCode debugger doesn't know them.It will be helpful when debugging if the debugger provides such features :)
The text was updated successfully, but these errors were encountered: