Skip to content
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

TreeItems' LeftPointer and RightPointer are not evaluated #1426

Open
ahfakt opened this issue Nov 19, 2023 · 0 comments
Open

TreeItems' LeftPointer and RightPointer are not evaluated #1426

ahfakt opened this issue Nov 19, 2023 · 0 comments

Comments

@ahfakt
Copy link

ahfakt commented Nov 19, 2023

Based on this issue I assume VSCode C/C++ extension uses this implementation. I tried to define a simple TreeItems. When debugging on Linux with GDB, even though natvis.xsd says so, LeftPointer and RightPointer is not evaluated. And I think the problem is the implementation of the GetTraverse function. It's also used by LinkedListItems's NextPointer, I haven't tried it but it may affect that too.

Example C++ code

template <typename T>
struct Tree {
	struct Node {
		Node* left = nullptr;
		Node* right = nullptr;
		T val;
	} n1, n2, n3;
	Node* head;
	int size = 3;
};

int main()
{

	Tree<int> tree;
	tree.n1.val = 11;
	tree.n2.val = 22;
	tree.n3.val = 33;
	tree.head = &tree.n2;
	tree.n2.left = &tree.n1;
	tree.n2.right = &tree.n3;

	return 0;
}

.natvis definition

<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
	<Type Name="Tree&lt;*&gt;">
		<DisplayString>{size}</DisplayString>
		<Expand HideRawView="1">
			<TreeItems>
 				<!-- "size+0" OK-->
				<Size>size</Size>

 				<!-- "head+0" OK-->
				<HeadPointer>head</HeadPointer>

 				<!-- "left+0" ERR-->
				<LeftPointer>left</LeftPointer>

 				<!-- "right+0" ERR-->
				<RightPointer>right</RightPointer>

 				<!-- "*($T1*)(&amp;val+0)" OK-->
				<ValueNode>val</ValueNode>
			</TreeItems>
		</Expand>
	</Type>
</AutoVisualizer>

and related launch configuration

	"launch": {
		"version": "0.2.0",
		"configurations": [
			{
				"name": "Launch",
				"type": "cppdbg",
				"MIMode": "gdb",
				"request": "launch",
				"cwd": "${command:cmake.launchTargetDirectory}",
				"program": "${command:cmake.launchTargetPath}",
				"args": [],
				"externalConsole": false,
				"stopAtEntry": true,
				"visualizerFile": [
					"${workspaceFolder}/.natvis"
				],
				"showDisplayString": true
			}
		]
	}
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

No branches or pull requests

1 participant