[PATCH] Add some natvis visualizers for llvm::Value, llvm::Type, and llvm::Instruction

Zachary Turner zturner at google.com
Thu Jun 26 14:17:58 PDT 2014


Yea, I'm not sure.  I agree it's annoying, but if you only add SubclassID
and then let the rest still be visible through Raw View, it's kind of
awkward expanding the node and not seeing anything.  Someone not familliar
with the natvis stuff woudl think there's something wrong.  I was trying to
do something like adding a row called SubclassID with the cast value, and
then using an <ExpandedItem> to display "this" without the visualizer
applied, but I couldn't get that to work.  Do you know how?


On Thu, Jun 26, 2014 at 2:05 PM, Aaron Ballman <aaron.ballman at gmail.com>
wrote:

> On Thu, Jun 26, 2014 at 5:01 PM, Zachary Turner <zturner at google.com>
> wrote:
> > Added some more for llvm::Instruction to display the Opcode.
> >
> > http://reviews.llvm.org/D4316
> >
> > Files:
> >   utils/llvm.natvis
> >
> > Index: utils/llvm.natvis
> > ===================================================================
> > --- utils/llvm.natvis
> > +++ utils/llvm.natvis
> > @@ -166,4 +166,75 @@
> >        <Item Name="[underlying]" Condition="hasVal">*(($T1 *)(unsigned
> char *)storage.buffer)</Item>
> >      </Expand>
> >    </Type>
> > +
> > +  <Type Name="llvm::Value">
> > +    <DisplayString Condition="Name != 0">{Name}</DisplayString>
> > +    <DisplayString>{{anonymous value}}</DisplayString>
> > +    <Expand>
> > +      <Item Name="VTy">VTy</Item>
> > +      <Item Name="UseList">UseList</Item>
> > +      <Item Name="Name">Name</Item>
> > +      <Item Name="SubclassID">(llvm::Value::ValueTy)SubclassID</Item>
> > +      <Item Name="HasValueHandle">(bool)HasValueHandle</Item>
> > +      <Item Name="SubclassOptionalData">SubclassOptionalData</Item>
> > +      <Item Name="SubclassData">SubclassData</Item>
>
> It's unfortunate that all of this has to be duplicated just so
> SubclassID can be cast... Would it make more sense to just add that
> field, and allow access to the rest through Raw View (even though it's
> an extra click)? Any changes to Value may not be reflected in here,
> which is why I'm slightly concerned.
>
> > +    </Expand>
> > +  </Type>
> > +
> > +  <Type Name="llvm::Type">
> > +    <DisplayString>{(llvm::Type::TypeID)(IDAndSubclassData &
> 255)}</DisplayString>
> > +    <Expand>
> > +      <Item Name="[Integer Type]" Condition="(IDAndSubclassData &
> 255) == llvm::Type::IntegerTyID">*(llvm::IntegerType*)this</Item>
> > +      <Item Name="[Function Type]" Condition="(IDAndSubclassData &
> 255) == llvm::Type::FunctionTyID">*(llvm::FunctionType*)this</Item>
> > +      <Item Name="[Struct Type]" Condition="(IDAndSubclassData &
> 255) == llvm::Type::StructTyID">*(llvm::StructType*)this</Item>
> > +      <Item Name="[Array Type]" Condition="(IDAndSubclassData &
> 255) == llvm::Type::ArrayTyID">*(llvm::ArrayType*)this</Item>
> > +      <Item Name="[Pointer Type]" Condition="(IDAndSubclassData &
> 255) == llvm::Type::PointerTyID">*(llvm::PointerType*)this</Item>
> > +      <Item Name="[Vector Type]" Condition="(IDAndSubclassData &
> 255) == llvm::Type::VectorTyID">*(llvm::VectorType*)this</Item>
> > +    </Expand>
> > +  </Type>
> > +
> > +  <Type Name="llvm::SequentialType">
> > +    <Expand>
> > +      <Item Name="ContainedType">ContainedType</Item>
> > +      <ExpandedItem>*(llvm::Type*)this,nd</ExpandedItem>
> > +    </Expand>
> > +  </Type>
> > +
> > +  <Type Name="llvm::Instruction">
> > +    <Expand>
> > +      <Synthetic Name="[Opcode]">
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::Call">Call</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::Add">Add</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::Sub">Sub</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::Mul">Mul</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::SDiv">SDiv</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::UDiv">UDiv</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::SRem">SRem</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::URem">URem</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::Shl">Shl</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::LShr">LShr</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::AShr">AShr</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::And">And</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::Or">Or</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::Xor">Xor</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::Alloca">Alloca</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::BitCast">BitCast</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::ZExt">ZExt</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::SExt">SExt</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::Br">Br</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::GetElementPtr">GetElementPtr</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::ICmp">ICmp</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::IntToPtr">IntToPtr</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::PtrToInt">PtrToInt</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::Trunc">Trunc</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::Load">Load</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::Ret">Ret</DisplayString>
> > +        <DisplayString Condition="(SubclassID - InstructionVal) ==
> Instruction::Store">Store</DisplayString>
> > +        <DisplayString>{{Unknown}}</DisplayString>
> > +      </Synthetic>
> > +      <Item Name="Parent">Parent</Item>
> > +      <Item Name="DebugLoc">DbgLoc</Item>
> > +      <ExpandedItem>(llvm::User*)this,nd</ExpandedItem>
> > +    </Expand>
> > +  </Type>
> >  </AutoVisualizer>
>
> ~Aaron
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140626/bf47235a/attachment.html>


More information about the llvm-commits mailing list