Any way to view a value tree?

Hi, is there a way to easily print out a value tree to see all of its contents?
It is practically impossible to click through the variabes section of visual studio.

There is a great tool for this in the juce-toys, GitHub - jcredland/juce-toys: Debugging utilities in a JUCE Module, plus NatVis and LLDB customizations. Follow the instructions to install the juce.natvis file, and you will have a much better view of ValueTrees, and a number of other JUCE containters.

2 Likes

Thanks, this is really useful!

The juce-toys thing is great, though I think I remember having to modify the files a bit before I could get it to work.

If you’re looking for something simpler, then you can use valueTree.toXmlString() to print ValueTrees as XML.

Personally, I have set up a global function like this:

void printVT(ValueTree toPrint)
{
    static const Identifier printTest("xxxxxxxxxxxxxxxxxxxxxxxxxxxxx");

    toPrint.setProperty(printTest, "x", nullptr);

    DBG(toPrint.getRoot().toXmlString());

    toPrint.removeProperty(printTest, nullptr);
}

This prints the whole tree and puts a marker on the node that you’re looking at. It’s pretty crude, but very useful for debugging.

@LiamG I actually updated the juce-toys a while back and submitted a PR which fixed them (along with other changes to juce containers). But, you are also right, in that there are instances where dumping the whole thing makes sense.

Do you know if this kind of tool exist for Xcode? juce-toys seems to be made for Visual Studio only.

I think the juce-toys has one for xcode as well, juce_lldb_xcode.py., but I did not update it as I did the VS one. Hopefully Jim will update it, but if not, I suspect I eventually do it to, as I do cross platform work, and I always bemoan this missing in xcode.

Thanks! I’m sorry I didn’t see this file :sweat_smile:

I was never able to get this working in XCode, or didn’t understand what it was supposed to add and how to access it properly.

I need to take a swing at it. if I do I will post an update here, with any extra info on getting it setup.

2 Likes