Chandler suggested that I socialize the improvements that I have been making to Clang data structure visualizations in Visual Studio. For example, these changes replace the traditional incomprehensible Locals/Watch display of a TemplateArgumentLoc
Now it clearly displays that it is a Type Template Parameter where T has been replaced by struct A.
I only have a small portion of the Clang data types done so far, but it is already really helping me keep track of what is going on while debugging Clang (It’s also been an excellent way for me to learn Clang data structures J ). I will be continuing to add further visualizations over the next few weeks and ongoing.
I hope these prove helpful to the community,
Thank you for helping to improve these! As someone who works on Clang using
Visual Studio, these improvements to the visualizers are greatly
Looks cool! I’m not a VS guy - how did you achieve this? Was there some source changes in clang or is this a plugin that leverages clang for VS?
I am not using plugins (yet!). Visual Studio supports XML-based visualizers that let you specify how your types are displayed in at least a limited way. I added this functionality by editing clang/utils/clang.natvis.
FWIW, GDB has a visualizer system in python - I wrote up some visualizers for SmallVector, etc, but I couldn’t find a way to plug them in for free into GDB (everything required some reconfiguration of GDB to point to a script directory or the like). I might check them in anyway with a README telling people how to set them up if they want to.
Cool results, but XML - ewwie…
That's the way GCC does it for libstdc++; the Python pretty-printer
macros are shipped with GCC and installed as part of installing the
compiler (IIRC), and it's up to the person putting together their
environment to DTRT, which usually involves adding a source line to
their .gdbinit file or whatever.
Not unlike gdb visualizers, Visual Studio visualizers require some setup: You have to put clang.natvis and llvm.natvis in Documents\Visual Studio 20xx\Visualizers. However, VS2015 added support for visualizers in a project. Once we stop supporting VS2013, we will be able to automagically eliminate the manual setup. Is there a timeline for dropping VS2013 support?
We support the last two major releases of msvc unless there is a really compelling case to drop support early. So whenever the successor to msvc 2015 comes out is when we plan to drop support for msvc 2013.
I’ve been away for a week (and will be for ~one more), but I’ve long wanted to write a patch for CMake so that it’d link to the natvis that’s part of LLVM’s repo. I think you can find the discussion in the January cfe-dev archives, and if you’re up to it, go right ahead!
My local install of git is all screwed up, and since CMake uses git, I haven’t gotten around to it.
Can you be more specific? I’m afraid I can’t find the discussion.
Whoops, sorry, it was in llvm-dev.
Here’s the last message in the thread: http://lists.llvm.org/pipermail/llvm-dev/2016-January/094608.html
I also thought about doing having CMake put the .natvis files in llvm.sln, but I held back because that doesn’t work with MSVC2013. Should we wait until VS2013 support is dropped, or do you know how to make CMake only add them to the projects for VS2015 and up?
Yeah, if I know what you’re talking about, it should be like what I did in this patch: http://reviews.llvm.org/D15784
This is now done. Native visualizers should now automagically work with VS2015 with no installation or configuration steps required.