Open higaski opened 6 years ago
vscode's built-in extension? I haven't really used pretty printers yet so I can't give you any advice apart from changing valuesFormatting which should work. What language are you debugging and what pretty printers are defined?
Oops my bad, there is no "built-in" GDB integration. I meant Microsoft's own C/C++ extension which comes with debugging features. Using that one pretty-printing "just works" out of the box.
I honestly never paid too much attention on how GDB must be configured for using pretty-printing so I have no clue how or where those pretty printers are defined. A quick search on my file system shows me that every toolchain I have installed actually brings its python printer files...
./usr/share/gcc-arm-none-eabi/libstdcxx/v6/printers.py
./usr/share/gcc-8.2.1/python/libstdcxx/v6/printers.py
./usr/share/gdb/python/gdb/command/type_printers.py
./usr/share/gdb/python/gdb/command/pretty_printers.py
./opt/esp/xtensa-esp32-elf/share/gdb/python/gdb/command/type_printers.py
./opt/esp/xtensa-esp32-elf/share/gdb/python/gdb/command/pretty_printers.py
./opt/esp/xtensa-esp32-elf/share/gcc-5.2.0/python/libstdcxx/v6/printers.py
can you send screenshots how it looks like and what you were expecting?
Sure thing. All the examples below were running with GCC 8.2.1, GDB 8.2 and LLDB 6.0.1
So this is what the variable view should look like when pretty-printing is enabled. I've tested this with Microsoft's C/C++ extension with both, GDB and LLDB and they both give me the same result: https://imgur.com/a/8Zf5hni
This is what I get from Native Debug and LLDB. That LLDB also screws with the local view is new for me as well. Looks like I only tested globals before... https://imgur.com/a/Hx5RLK9
And this is what I get from Native Debug with GDB. For some reason the local view actually works here, while the global one still doesn't. https://imgur.com/a/dF9dJyB
Here is the complete launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb-mi",
"request": "launch",
"name": "Native Debug lldb",
"target": "${workspaceFolder}/main",
"cwd": "${workspaceFolder}",
"valuesFormatting": "prettyPrinters"
},
{
"type": "gdb",
"request": "launch",
"name": "Native Debug gdb",
"target": "${workspaceFolder}/main",
"cwd": "${workspaceFolder}",
"valuesFormatting": "prettyPrinters"
},
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/main",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
the watch view will never work because code-debug doesn't implement pretty printing here so that is intended. The LLDB part is weird but it could happen because of differences in the implementation of the protocol.
Would it be a troublesome to make pretty printing work in the watch view? This would be a great help for people who do a lot of embedded stuff where globals/statics are pretty common.
it wouldn't really be a problem but I kept it like this because when the output is broken you can still see the simple view in the watch window. Also you can enter more complex expressions than just variables which I don't think I can parse the output for iirc
Hello
I've got a little trouble getting pretty printing to work properly. The "valuesFormatting" option does not seem to have much of an effect on my test project.
{ "type": "lldb-mi", "request": "launch", "name": "Native Debug lldb", "target": "${workspaceFolder}/main", "cwd": "${workspaceFolder}", "valuesFormatting": "prettyPrinters", "autorun": [ "-enable-pretty-printing" ] }
For some strange reason using VSCode built-in extension combined with LLDB works with prettyprinting. They seem to pass an additional argument by using
"setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ]
I'm sorry that I can't offer any more information. I'm not really familiar on how GDB interacts with python... Let me know if I should post some debug output or anything.