[llvm-dev] GDB pretty printers for LLVM ADTs

Piotr Padlewski via llvm-dev llvm-dev at lists.llvm.org
Mon Dec 19 02:47:28 PST 2016


Excellent. I think it would make sense to add small section somewhere in
documentation (e.g. LLVM Programmer’s Manual
<http://llvm.org/docs/ProgrammersManual.html>) about it, so it won't be
lost somewhere in the mailing list.

Piotr

2016-12-17 1:04 GMT+01:00 David Blaikie via llvm-dev <
llvm-dev at lists.llvm.org>:

> Added some basic DenseMap support in r290011
>
> On Fri, Dec 16, 2016 at 2:05 PM David Blaikie <dblaikie at gmail.com> wrote:
>
>> I've added a few LLVM GDB pretty printers a while back (& just added
>> llvm::Optional earlier today) & thought people might be interested in how
>> to use them, etc.
>>
>> I use them by adding the following to my .gdbinit:
>>
>>   source /path/to/llvm/src/utils/gdb-scripts/prettyprinters.py
>>
>> Also, I can suggest adding:
>>
>>   set print pretty on
>>
>> there too, it helps a lot when printing complex nested data structures.
>>
>> Once you have that, you can get pretty output like this:
>>
>> (gdb) p Abbrev->AbbrDeclSets
>> $1 = std::map with 1 elements = {
>>   [0] = {
>>     Offset = 0,
>>     FirstAbbrCode = 1,
>>     Decls = std::vector of length 1, capacity 1 = {{
>>         Code = 1,
>>         Tag = llvm::dwarf::Tag::DW_TAG_compile_unit,
>>         CodeByteSize = 1 '\001',
>>         HasChildren = false,
>>         AttributeSpecs = llvm::SmallVector of length 8, capacity 8 = {{
>>             Attr = llvm::dwarf::Attribute::DW_AT_low_pc,
>>             Form = llvm::dwarf::Form::DW_FORM_addr,
>>             ByteSize = llvm::Optional is not initialized
>>           }, {
>>             Attr = llvm::dwarf::Attribute::DW_AT_high_pc,
>>             Form = llvm::dwarf::Form::DW_FORM_data8,
>>             ByteSize = llvm::Optional is initialized = {
>>               value = 8 '\b'
>>             }
>>
>> Here you can see the pretty printers for SmallVector and Optional, but
>> there's also support for StringRef, SmallString, and ArrayRef.
>>
>> I've tried doing a DenseMap pretty printer, but haven't quite figured it
>> out yet (having trouble calling member functions to do some of teh more
>> complicated parts of DenseMap iteration - may end up printing it with the
>> tombstone/empty values present, but not sure how easy that'll be to read,
>> etc). Happy to take requests or talk people through adding more pretty
>> printers anyone wants to add :)
>>
>> Enjoy!
>> - Dave
>>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161219/6416a9aa/attachment.html>


More information about the llvm-dev mailing list