<div dir="ltr"><div>What if I would generate the pretty printers at build time from the <a href="https://github.com/llvm/llvm-project/blob/2946cd701067404b99c39fb29dc9c74bd7193eb3/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def">SVals.def</a>, <a href="https://github.com/llvm/llvm-project/blob/2946cd701067404b99c39fb29dc9c74bd7193eb3/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Symbols.def">Symbols.def</a> and <a href="https://github.com/llvm/llvm-project/blob/2946cd701067404b99c39fb29dc9c74bd7193eb3/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def">Regions.def</a>.</div><div>Just like we generate c++ code using X macros for these classes.<br></div><div><br></div><div>It would be aware of changing those definition files and the build system would regenerate the pretty printers.</div><div><br></div><div>Should I code this pretty printer generation in python as well?</div><div>And hook it into the build system via the <span style="font-family:monospace">add_custom_target</span>?<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Sterling Augustine <<a href="mailto:saugustine@google.com">saugustine@google.com</a>> ezt írta (időpont: 2020. aug. 5., Sze, 18:00):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hardcoding types inside a python pretty printer is more or less the standard way of doing it. A pretty printer has to be very closely tied to the type and structure of the type it is printing. The knowledge must be quite intimate, or it couldn't do a better job than your standard debug info printer.</div><div><br></div><div>libcxx has some nicely implemented pretty printers for various standard types (if I do say so myself). You could take those as examples.</div><div><br></div><div>I'll second the "avoid calling process code in a pretty printer". It might be better than nothing (particularly if there isn't a standard way to call the dump function), but it is invasive, and there is no reason to believe it wouldn't allocate memory (say, when concatenating a string), which can perturb the state of the program you are debugging.</div><div> </div><div dir="ltr">On Wed, Aug 5, 2020 at 10:53 AM David Blaikie via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">We don't have many pretty printers because people haven't<br>
implemented/desired them, I guess. I implemented a handful to start &<br>
some folks added/improved on them a bit.<br>
<br>
In general you don't want to call into the process's code in a pretty<br>
printer if you can help it - because that risks heisenbugs (risks that<br>
pretty printing a value could change the state of the process being<br>
debugged) and doesn't work on core files (which have no running<br>
process to interact with).<br>
<br>
But sometimes it's hard to avoid & I think I've done it in one or two<br>
places in the existing LLVM Pretty printers - so it's by no means an<br>
impossibility.<br>
<br>
On Wed, Aug 5, 2020 at 10:41 AM Balázs Benics via cfe-dev<br>
<<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
> I was thinking about some pretty printers.<br>
> And I'm thinking about SVals and SymExprs specifically.<br>
><br>
> Why do we have no pretty printers for such types?<br>
><br>
> I guess we could reuse their dump() method to acquire string representation.<br>
> The only problem is that that dumps the output to the standard error stream.<br>
><br>
> What options do I have to get a python pretty-printer using this dump method?<br>
><br>
> Another possible way to implement such a pretty printer is to hardcode the SVal<br>
> kinds in python to do the right thing for each case.<br>
> I'm not really a big fan of this way though.<br>
><br>
> If you have experience with gdb pretty printers then your comments more then welcomed.<br>
><br>
> Balazs.<br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>
</blockquote></div>