This is the mail archive of the
mailing list for the GCC project.
Re: v2 of GDB hooks for debugging GCC
- From: Tom Tromey <tromey at redhat dot com>
- To: David Malcolm <dmalcolm at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 21 Aug 2013 15:01:01 -0600
- Subject: Re: v2 of GDB hooks for debugging GCC
- 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>
>>>>> "David" == David Malcolm <firstname.lastname@example.org> writes:
David> We chatted about this at Cauldron; I haven't yet had a chance to
David> implement the magic bullet approach we discussed there. In the
David> meantime, is there a API I can call to determine how safe this kludge
Not right now. You can just call the function and catch the exception
that occurs if it can't be done.
I think you can still run into trouble sometimes. For example if the
user puts a breakpoint in one of the functions used by the
pretty-printer, and then does "bt", hitting the breakpoint while
printing the backtrace... not sure what happens then, maybe a crash.
Tom> I think you could set up the safe-path in the gcc .gdbinit.
David> Interesting idea - but .gdbinit itself seems to get declined, so I don't
David> think this can help.
Haha, I didn't think of that :-)
David> So I implemented a similar scheme, with all the prettyprinters in a
David> top-level "gcc" holder, but doing precise string matching on the
David> "unqualified" type, like in the original patch.
David> This works as before, and presumably works with the pretty-printer
David> management facilities; running this gives sane-looking output:
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".
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.
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.