microsoft / microsoft/vscode-cpptools

Can we reference the expression being evaluated within the natvis rule?

Offen
#561 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

debugger question
Vorherrschende Sprache
TypeScript
Sterne
6.2k
Forks
1.7k
Ø Merge
14 Std. 46 Min.
Gemergte PRs (30 T.)
61

Beschreibung

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?

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Das Issue enthält keine Datei, keinen Test und keinen Einstiegspunkt. Beginne damit, das Repository nach der natvis-Behandlung von Type, DisplayString und Condition zu durchsuchen; als erledigt gilt die Aufgabe, wenn festgestellt wurde, ob ein self-expression sowohl in der C- als auch in der C++-natvis-Auswertung offengelegt werden kann, oder wenn dokumentiert wurde, warum dies nicht möglich ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
c, cpp
Bereich
devtools
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.