microsoft / microsoft/vscode-cpptools
Can we reference the expression being evaluated within the natvis rule?
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Are there any way to reference the expression being evaluated from the natvis rule?
Here are some examples what I am talking about.
Consider we have color_t type defined as typedef uint32_t color_t;, also let's suppose we have a special variable $_self which references current expression. Now we can write natvis rule:
<Type Name="color_t">
<DisplayString>A:{$_self >> 24} R:{($_self>>16) & 0xFF} G:{($_self>>8) & 0xFF} B: {$_self & 0xFF}</DisplayString>
</Type>
So we can see color information in a human readable format.
Another example. Consider we have some struct in C:
typedef struct
{
int state;
//other fields follow
}TCB;
Also there is global variable:
TCB* Running;
I want to make natvis rules that will show the state of the object based on the `state` field and `Running` global variable. If we would have a special variable `$_self` (as above). We could write:
<Type Name="TCB">
<DisplayString Condition="state==0">Empty</DisplayString>
<DisplayString Condition="state==0x80 && Running!=&$_self">Ready</DisplayString>
<DisplayString Condition="state==0x80 && Running==&$_self">Running</DisplayString>
</Type>
The last example could be realized for C++ language using this keyword, but not for C (or I just do not know how).
So are there any way to make such natvis rules? A there any possibility to add some special variable?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue provides no file, test, or entry point. Start by searching the repository for natvis handling of Type, DisplayString, and Condition; done means determining whether a self-expression can be exposed in both C and C++ natvis evaluation, or documenting why it cannot.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100