Skip to content

Conversation

gentoo90
Copy link
Contributor

@gentoo90 gentoo90 commented May 20, 2017

Replace own value parser with GDB's variable objects interface.
This improves variables view and allows to show values from custom pretty-printers loaded into GDB.

Before After
C++ cpp_before cpp_after
Rust rust_before rust_after

Tested with vscode-1.12.2 and GDB-7.12 on Gentoo Linux

@WebFreak001
Copy link
Owner

WebFreak001 commented May 21, 2017

Wow thanks, I didn't know about that one, that surely will improve the quality of the variable output. Also I didn't know typescript supported that fancy async syntax there.

But I found an issue here where it tries to expand something on a null pointer (it thinks there is still data and showing the arrow but there isn't actually anything there):
https://i.webfreak.org/fABlw8.png

Currently trying to figure out how to best fix this.

@WebFreak001
Copy link
Owner

hm the empty variable looks exactly the same as normal variables so I don't really know how to fix that, well maybe not really that big of an issue.

However arrays (length prefixed length + ptr objects) are now broken with this new code. I tried doing the simple thing by adding [0] to the variable name like var1[0] and also var1.ptr[0] but both didn't really work. Also strings would be nicer if they were directly inlined without the long pointer value before them. (doing all the tests for this in D)

@gentoo90
Copy link
Contributor Author

I've never used D. Can you post the piece of code which gives this?
Arrays in C++ and Rust work fine.

@WebFreak001
Copy link
Owner

WebFreak001 commented May 21, 2017

Here just some test code where both the issues can be observed if you just halt anywhere in the main:

import std.stdio;

struct A
{
	string b;
	A* child;
}

void main()
{
	string str = "abc"; // strings are char arrays
	int[] arr = [1, 2, 3];
	writeln(str);
	writeln(arr);
	A a;
	a.b = "def";
	writeln(a);
}

build with dmd -g filename.d

gentoo90 added 2 commits May 25, 2017 23:02
Use GDB's stask frames number as its id in vscode
Same variables now have same ids in each VariablesResponse.
This allows vscode to keep track of changes properly and prevents
collapsing of all variables after every step.
@gentoo90
Copy link
Contributor Author

gentoo90 commented May 25, 2017

Var objects for local variables now have the same names as that variables. So adding to watchlist by right click should work better. But according to GDB's documentation expressions can't work with dynamic objects.

exp
The expression to be shown to the user by the front end to designate this child. For example this may be the name of a structure member.
For a dynamic varobj, this value cannot be used to form an expression. There is no way to do this at all with a dynamic varobj.
For C/C++ structures there are several pseudo children returned to designate access qualifiers. For these pseudo children exp is ‘public’, ‘private’, or ‘protected’. In this case the type and value are not present.
A dynamic varobj will not report the access qualifying pseudo-children, regardless of the language. This information is not available at all with a dynamic varobj.

@WebFreak001
Copy link
Owner

I think this should be available through some pretty_print value in the launch config and it shouldn't be enabled by default as pretty printing in languages without any pretty printer is quite ugly (as seen in my comment). I think this change is quite useful but without having proper pretty printers it is more a drop in the debugging quality.

@gentoo90
Copy link
Contributor Author

gentoo90 commented May 26, 2017

I added launch config parameter valuesFormatting with 3 possible values:

  • disabled - use variable objects but don't enable pretty-printers (they can be buggy so it may be useful to disable them)
  • parseText (default) - use the current way and parse result of data-evaluate-expression with expandValue()
  • prettyPrinters - use variable objects and enable pretty-printers

@WebFreak001
Copy link
Owner

yeah thats perfect, thanks for this contribution. Code quality and your responsiveness were great. Gonna merge this and push a new version to the marketplace in a minute.

Also the main reason why I want it to work with D out of the box is that I listed this extension on the D wiki as debugger plus I always recommend it to D people using vscode and I am always mostly testing it with D.

@WebFreak001 WebFreak001 merged commit 73473e1 into WebFreak001:master May 26, 2017
@gentoo90 gentoo90 deleted the gdb-var-objects branch May 28, 2017 09:43
@gentoo90 gentoo90 mentioned this pull request Jun 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants