ruediger / Boost-Pretty-Printer

GDB Pretty Printers for Boost
197 stars 61 forks source link

Subprinters #8

Closed mateidavid closed 10 years ago

mateidavid commented 10 years ago

Hi,

I'm working on a project with boost multi_index_containers, and I've been looking for a gdb printer for those. I couldn't find one, so I wrote an experimental one for myself. In the process, I changed your printers to the (newer) subprinter framework, which allows them to be listed, enabled, and disabled individually from within gdb. I'm sending this pull request in case you might find these useful. They are also "inspired" by libstdcxx.

The ordered multi_index support is in a separate branch not included in this request, but you can see it under my fork. Let me know if you think that could also be useful to the main project.

BTW, I'm not sure how these pull requests work, let me know if I didn't get it right.

Matei

mateidavid commented 10 years ago

Oh, and I moved my contributions to a 'v1.41' folder, which is not referenced in the README.

ruediger commented 10 years ago

Why did you copy them to a new folder? I think it would be better to change the code in 'v1.40'. What are the requirements for the newer subprinter framework (GDB version)?

mateidavid commented 10 years ago

I thought I should change the version number, that's why I changed the folder name. In fact, the name/version which gets displayed in gdb by 'info pretty-printer' is the 'name' attribute of the class which gets registered by gdb.printing.register_pretty_printer(). So the folder name is inconsequential in that sense. If you want the pull but prefer to keep only one version, you can decide on the folder name yourself.

Regarding the versions, I pushed some updates today that now work with: GNU gdb (GDB) 7.0.1-debian GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04 GNU gdb (GDB) 7.6.1 The second one is Kubuntu 12.04.3 up-to-date, the last one is compiled from source.

There were some issues with the version from last night:

  1. gdb.printing doesn't exist in 7.0, but one can still register the top-level printer generator using the old method.
  2. gdb.parse_and_eval() doesn't exist in 7.0. The experimental ordered_multi_index printer relies heavily on this, so I only register it internally if I find that method.

Also, I added the option for individual printers to define a 'supports(basic_type)' method when wrapped in a subprinter object (which is passed the type, not just the type tag). I wanted to do a proper check for boost::ordered_unique using 'type.template_argument()', but that doesn't work as advertised. I left the code in there for when they fix it.

I wonder how to update the pull request...

mateidavid commented 10 years ago

Oh, the commit is showing here among the comments.

mateidavid commented 10 years ago

To clarify, 7.0.1 doesn't have subprinters and it cannot enable or disable individual printers or subprinters (as far as I can tell). However, the subprinters work just fine under the hood.

ruediger commented 10 years ago

Your patch looks good. But I think we should only have one version. Especially if the subprinter framework is backwards compatible with GDB 7.0.1. Could please you move your changes to the v1_40 folder?

(the v1_40 is actually a bit pointless by now. I used it back when I first created them because I designed the printers for boost 1.40. Boost is now at 1.55. I guess I should get rid of the v1_40 part eventually.

ruediger commented 10 years ago

Why did you close it?