microsoft / microsoft/vscode-cpptools

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

Aperta
#561 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

debugger question
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

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?

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

L’issue non fornisce alcun file, test o punto di ingresso. Inizia cercando nel repository la gestione natvis di Type, DisplayString e Condition; il lavoro è completato quando si è determinato se una self-expression può essere esposta sia nella valutazione natvis di C sia in quella di C++, oppure si è documentato perché non è possibile.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
c, cpp
Ambito
devtools
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.