vscode-debug-visualizer
vscode-debug-visualizer copied to clipboard
C/C++ visualization
Hello,
I am so happy that something like this exists! Unfortunately, I cannot make it work for C++ (cppvsdbg). I took the example form demo code and implemented it like this:
std::string visualize = "{\
\"kind\":{ \"plotly\": true },\
\"data\":[\
{ \"y\": [1, 2, 4, 8, 16] },\
{ \"y\": [14, 3, 0, 15, 10] }\
]\
}";
The result is as following:
How to create a JSON string in C++ that would be parsed as expected?
Related to #108
Interesting, that should work.
What does the debug console say when evaluating this expression there?
"{ \"kind\":{ \"plotly\": true }, \"data\":[ { \"y\": [1, 2, 4, 8, 16] }, { \"y\": [14, 3, 0, 15, 10] } ] }"
Is that a bug, or am I doing something incorrectly?
I'm sorry, I did not find time to look into it... But I really want to.
I think this might be a bug. If it is not a bug, the extension is not doing a great job at showing what is wrong, so in both cases, I need to look into it.
May I help somehow?
Yeah sure, you should be able to debug the extension (see contributing).
I think this is a good code pointer: https://github.com/hediet/vscode-debug-visualizer/blob/master/extension/src/VisualizationBackend/GenericVisualizationSupport.ts#L60
I ran into the same issue and I think I found the problem and a solution.
The problem seems to be that evaluating 'visualise', just outputs the STL container and not the actual string. Enabling pretty printing solves that issue. ( -exec -enable-pretty-printing
)
A second issue in the example above is that there are a lot of spaces in the string. GDB will shorten this to say <repeated 12 times>
which the JSON parser cannot read. The easiest solution is to remove the spaces, although a different printing method may be necessary for things like "aaaaa".
This is related to https://github.com/microsoft/vscode-cpptools/issues/201
Do you have ideas how to improve this generally?
I noticed that debug adapters change their output from time to time. I think it should be easier to debug that.
I don't really know.
Getting the full string is easier if you additionally use the commands:
-exec set print elements 0
-exec set print repeats 0
But that's not a true solution either. I think the best you can do in this library is add a warning in the cpp example about gdb's behaviour and these three commands that hopefully make it better.