This is the mail archive of the
mailing list for the GCC project.
Re: v2 of GDB hooks for debugging GCC
- From: David Malcolm <dmalcolm at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 26 Aug 2013 14:28:59 -0400
- Subject: Re: v2 of GDB hooks for debugging GCC
- Authentication-results: sourceware.org; auth=none
- References: <1375494523 dot 4994 dot 108 dot camel at surprise> <87mwow9ptg dot fsf at fleche dot redhat dot com> <1377115676 dot 9927 dot 25 dot camel at surprise> <877gfedaia dot fsf at fleche dot redhat dot com>
On Wed, 2013-08-21 at 15:01 -0600, Tom Tromey wrote:
> >>>>> "David" == David Malcolm <firstname.lastname@example.org> writes:
> David> How would one go about toggling the enabledness of a prettyprinter? Is
> David> this something that can only be done from python?
> You can use "enable pretty-printer" and "disable pretty-printer".
Yes, using .* to match the current executable:
(gdb) disable pretty-printer .* gcc
7 printers disabled
128 of 135 printers enabled
and this does indeed disable/enable the prettyprinters.
> David> I did see references to gdb.parameter("verbose") in gdb.printing
> David> - how would one go about setting this?
> "set verbose on"
> I think few people use this setting though; probably best to do what
> you're doing now.
> David> +# Convert "enum tree_code" (tree.def and tree.h) to a dict:
> David> +tree_code_dict = gdb.types.make_enum_dict(gdb.lookup_type('enum tree_code'))
> One other subtlety is that this doesn't interact well with all kinds of
> uses of gdb. For example if you have a running gdb, then modify enum
> tree_code and rebuild, then the pretty-printers won't notice this
> I guess it would be nice if we had pre-built caches for this kind of
> this available upstream. But meanwhile, if you care, you can roll your
> own using events to notice when to invalidate data.
As they say, the two fundamental problems in Computer Science are cache
invalidation, naming things, and off-by-one errors.
I'm inclined not to care for now: if you've rebuilt gcc with a new enum
tree code, then you should restart gdb.
Is there a precanned event provided by gdb that I can connect to for
when the underlying code has changed and my caches need to be
> David> + def __call__(self, gdbval):
> David> + type_ = gdbval.type.unqualified()
> David> + str_type_ = str(type_)
> FWIW I think for RegexpCollectionPrettyPrinter you could write a
> subclass whose __call__ first dereferenced a pointer, then called
> super's __call__. But your approach is just fine.