Jump to content

  • Log In with Google      Sign In   
  • Create Account


Visual Studio 2012 Natvis files


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 brx   Members   -  Reputation: 626

Like
0Likes
Like

Posted 17 December 2012 - 01:26 PM

So... this is my final attempt.

I've tried stackoverflow:
http://stackoverflow.com/questions/13748209/visual-studio-2012-natvis-skip-indexlistitems

I've tried the msdn forums:
http://social.msdn.microsoft.com/Forums/en-US/Offtopic/thread/5b788606-1dfc-4bdd-a67c-451f1dba8dcb
but so far I've received no help...

So, with VS2012 the new concept of natvis files for visualizations inside the debugger has been introduced... So far the Qt developers have failed to update their VS-plugin to work with VS2012, so I am trying to roll my own... It seems like I've gotten most of what I need to work, but I'm having a big problem with the QHash class. This is what I have so far:

<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">

  <Type Name="QString">
<DisplayString>{d->data,su}</DisplayString>
<StringView>d->data,su</StringView>
  </Type>

  <Type Name="QByteArray">
<DisplayString>{d->data,s}</DisplayString>
  </Type>

  <Type Name="QList&amp;amp;lt;*&amp;amp;gt;">
    <AlternativeType Name="QQueue&amp;amp;lt;*&amp;amp;gt;" />
<DisplayString>{{size = {d->end - d->begin}}}</DisplayString>
<Expand>
<Item Name="[size]">d->end - d->begin</Item>
<IndexListItems>
  <Size>d->end - d->begin</Size>
  <ValueNode>($T1*)((d->array + d->begin)[$i])</ValueNode>
</IndexListItems>
</Expand>
  </Type>

<Type Name="QVector&amp;amp;lt;*&amp;amp;gt;">
<DisplayString>{{size = {d->size}}}</DisplayString>
<Expand>
<Item Name="[size]">d->size</Item>
<Item Name="[capacity]">d->alloc</Item>
<IndexListItems>
  <Size>d->size</Size>
  <ValueNode>(p->array[$i])</ValueNode>
</IndexListItems>
</Expand>
  </Type>
<Type Name="QHashNode&amp;amp;lt;*,*&amp;amp;gt;">
<DisplayString Condition="next->next == 0">{{ key={key} value={value} h={h}}}</DisplayString>
<DisplayString>{{ key={key} value={value} h={h} withCollision }}</DisplayString>
<Expand>
  <Item Name="NextNode">reinterpret_cast&amp;amp;lt;QHashNode&amp;amp;lt;$T1,$T2&amp;amp;gt; *&amp;amp;gt;(next)</Item>
</Expand>
</Type>
<Type Name="QHash&amp;amp;lt;*,*&amp;amp;gt;">
    <DisplayString>{{ size={d->size} buckets={d->numBuckets} }}</DisplayString>
    <Expand>
	    <IndexListItems>
		    <Size>d->numBuckets</Size>
   <ValueNode Condition="reinterpret_cast&amp;amp;lt;QHashNode&amp;amp;lt;$T1,$T2&amp;amp;gt; *&amp;amp;gt;(d->buckets[$i]) != e">reinterpret_cast&amp;amp;lt;QHashNode&amp;amp;lt;$T1,$T2&amp;amp;gt; *&amp;amp;gt;(d->buckets[$i])</ValueNode>
	    </IndexListItems>
    </Expand>
</Type>
<Type Name="QSet&amp;amp;lt;*&amp;amp;gt;">
    <DisplayString>{{ size={q_hash.d->size} buckets={q_hash.d->numBuckets} }}</DisplayString>
    <Expand>
	    <IndexListItems>
		    <Size>q_hash.d->numBuckets</Size>
   <ValueNode Condition="reinterpret_cast&amp;amp;lt;QHashNode&amp;amp;lt;$T1,QHashDummyValue&amp;amp;gt; *&amp;amp;gt;(q_hash.d->buckets[$i]) != q_hash.e">reinterpret_cast&amp;amp;lt;QHashNode&amp;amp;lt;$T1,QHashDummyValue&amp;amp;gt; *&amp;amp;gt;(q_hash.d->buckets[$i])</ValueNode>

	    </IndexListItems>
    </Expand>
</Type>
<Type Name="QMapNode&amp;amp;lt;*,*&amp;amp;gt;">
<DisplayString>{{ key={key} value={value} }}</DisplayString>

</Type>
<Type Name="QMap&amp;amp;lt;*,*&amp;amp;gt;">
  <DisplayString>{{size = {d->size}}}</DisplayString>
  <Expand>
<LinkedListItems>
	  <Size>d->size</Size>
	  <HeadPointer>d->forward[0]</HeadPointer>
	  <NextPointer>forward[0]</NextPointer>
	  <ValueNode>reinterpret_cast&amp;amp;lt;QMapNode&amp;amp;lt;$T1,$T2&amp;amp;gt;* &amp;amp;gt;(reinterpret_cast&amp;amp;lt;char*&amp;amp;gt;(this) - (sizeof(QMapPayloadNode&amp;amp;lt;$T1,$T2&amp;amp;gt;) - sizeof(QMapData::Node*)))</ValueNode>
    </LinkedListItems>
</Expand>
</Type>

</AutoVisualizer>
It seems to me like all classes work as expected. But the QHash class pre-allocates some memory and only fills some if it. (The important part is the QHash and QHashNode part)

Now, my question is, whether anybody know if there is a way to just skip those values in the debugger display?

With the nativs file above, I get a lot of entries that are displayed as "<unable to display value>". With the old autoexp.dat files, values that didn't match a rule, were not displayed at all (see the linked posts). Does anybody happen to know a way to achieve the same in the new natvis format?

I am pretty pissed at the Microsoft support for saying it is a Qt problem, even though it is clearly reproducable without using Qt. So if you are running into a similar problem (or you are actually using Qt), I'd appreciate if you tell the MSDN guys that this IS a problem, and that you'd like this feature to be included (if itsn't already and I just don't know how to and the MSDN guys don't wan't to share - which I doubt).

Edited by brx, 17 December 2012 - 01:28 PM.


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS