Closed philong6297 closed 6 years ago
You need to set up python pretty printers for C++ in the .gdbinit file.
Have a look here: https://sourceware.org/gdb/wiki/STLSupport
@philong6297 Also make sure you have the following block in your launch.json
to enable pretty printing:
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
For the record, you need both of those, and they can both be wrapped in the setupCommands
Modern OSes like Fedora and Ubuntu include the svn submodule, and you don't need to download them separately. For example, in Ubuntu 18.04
"setupCommands": [
{
"description": "Test",
"text": "python import sys;sys.path.insert(0, '/usr/share/gcc-8/python');from libstdcxx.v6.printers import register_libstdcxx_printers;register_libstdcxx_printers(None)",
"ignoreFailures": false
},
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
not sure why
{ "version": "0.2.0", "configurations": [ { "name": "(lldb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/helloworld.out", "args": ["-arg1", "-arg2"], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "lldb", "customLaunchSetupCommands": [ { "description": "Test", "text": "python import sys;sys.path.insert(0, '/Users/mingyeyang/gcc/python');from libstdcxx.v6.printers import register_libstdcxx_printers;register_libstdcxx_printers(None)", "ignoreFailures": false }, { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "logging": { "trace": true, "traceResponse": true, "engineLogging": true } } ] }
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (476) STDERR: error: 'logout' is not a valid command.\n"},"seq":44}
1: (476) STDERR: error: 'logout' is not a valid command.
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (477) STDERR: error: Unrecognized command 'logout'.\n"},"seq":46}
1: (477) STDERR: error: Unrecognized command 'logout'.
--> E (output): {"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/Launch","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"14.0.61023.1","VS.Diagnostics.Debugger.HostVersion":"14.0.61023.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.Launch.ErrorCode":1005,"VS.Diagnostics.Debugger.Launch.IsError":true}},"seq":48}
--> R (launch-2): {"type":"response","request_seq":2,"success":false,"command":"launch","message":"Unable to start debugging. Specified argument was out of the range of valid values.\nParameter name: options.TargetArchitecture","body":{"error":{"id":1005,"format":"Unable to start debugging. Specified argument was out of the range of valid values.\nParameter name: options.TargetArchitecture"}},"seq":50}
How do I do the same for Windows?
For the record, you need both of those, and they can both be wrapped in the
setupCommands
Modern OSes like Fedora and Ubuntu include the svn submodule, and you don't need to download them separately. For example, in Ubuntu 18.04
"setupCommands": [ { "description": "Test", "text": "python import sys;sys.path.insert(0, '/usr/share/gcc-8/python');from libstdcxx.v6.printers import register_libstdcxx_printers;register_libstdcxx_printers(None)", "ignoreFailures": false }, { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ]
Any idea why @andyneff 's suggestion can't be rolled into vscode-cpptools so that it works out of the box? I've been struggling with debugging STL in vscode for a while now, and this suggestion is going to make it a lot easier.
@WardenGnaw can we see if we can get a test matrix with @andyneff's suggestion above and wee where it works and where it doesn't? we would need to at the bare minimum set up Arch, Ubuntu, Centos and WSL1/2
I'm on Ubuntu 20.04 and none of the suggestions here are having any effect at all, though they do work on a RHEL system I have access to. Any suggestions?
Edit: It appears to be due to the fact that I'm using CUDA-gdb not GDB. If anyone has any suggestions I'd love them otherwise I'll go ask the NVIDIA people
On Ubuntu 22.04, this seemed to work:
"setupCommands": [
{
"description": "Test",
"text": "python import sys;sys.path.insert(0, '/usr/share/gcc/python');from libstdcxx.v6.printers import register_libstdcxx_printers;register_libstdcxx_printers(None)",
"ignoreFailures": false
},
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
hansfbaier
I'm using this set up in launch.json file. Before copying this command, I was seeing only implementation details of std::set but now it shows me {...} basically no information. I'm attaching the photo of what I'm seeing in debugger. I'm using Ubuntu 22.04.
@sajedehkebriti You need the libstdc++6
package to be installed
@sajedehkebriti You need the
libstdc++6
package to be installed I have already installed this package.
hansfbaier
I'm using this set up in launch.json file. Before copying this command, I was seeing only implementation details of std::set but now it shows me {...} basically no information. I'm attaching the photo of what I'm seeing in debugger. I'm using Ubuntu 22.04.
the same question in gdb 13.2 use gdb init from [https://github.com/cyrus-and/gdb-dashboard]. did u solve this problem?
hansfbaier
I'm using this set up in launch.json file. Before copying this command, I was seeing only implementation details of std::set but now it shows me {...} basically no information. I'm attaching the photo of what I'm seeing in debugger. I'm using Ubuntu 22.04.
the same question in gdb 13.2 use gdb init from [https://github.com/cyrus-and/gdb-dashboard]. did u solve this problem?
You can change your compiler from clang++
to g++
.
Work for me.
@WardenGnaw can we see if we can get a test matrix with @andyneff's suggestion above and wee where it works and where it doesn't? we would need to at the bare minimum set up Arch, Ubuntu, Centos and WSL1/2
@pieandcakes any progress on that front?
How do I do the same for Windows?
do you find how to do it for windows
For example with
std::vector<std::vector> v(10,vector<int>(5,-1))
. When I run the debug with GDB, i can only see the address of the first and last element. When i expand the_M_start_
or_M_finish_
, it still show the address, not the value i need to see. How can i see the value of elements in STL or arrays in debug: