mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-16 23:14:36 +00:00
6eee409137
During debugging it can be extremely useful to be able to visualize the data members of a class type, instance of abigail::ir::class_decl*. It's actually useful to visualize the pretty representation (type name and kind) of all types and decls that inherit abigail::ir::type_or_decl_base, basically. Today, in the debugger, if we have a variable defined as "abigail::ir::type_or_decl_base* t", we can type: $ p t->get_pretty_representation(true, true); This would display something like: $ typedef foo_t However, if 't' is declared as: "abigail::ir::class_decl* t", then if we type: (gdb) p t->get_pretty_representation(true, true); We'll get something like: class foo_klass (gdb) So we get the kind and the name of the ABI artifact; but in case of a class, we don't get the details of its data members. This patch introduces a function named "debug" which, would be invoked on the 't' above like this: (gdb) p debug(t) I would yield: struct tm { // size in bits: 448 // translation unit: test24-drop-fns.cc // @: 0x5387a0, @canonical: 0x5387a0 int tm_sec; // uses canonical type '@0x538270' int tm_min; // uses canonical type '@0x538270' int tm_hour; // uses canonical type '@0x538270' int tm_mday; // uses canonical type '@0x538270' int tm_mon; // uses canonical type '@0x538270' int tm_year; // uses canonical type '@0x538270' int tm_wday; // uses canonical type '@0x538270' int tm_yday; // uses canonical type '@0x538270' int tm_isdst; // uses canonical type '@0x538270' long int tm_gmtoff; // uses canonical type '@0x461200' const char* tm_zone; // uses canonical type '@0x544528' }; (gdb) This gives much more information to understand what 't' designates. The patch also provides functions to retrieve one data member from a given type that happens to designate a class type. For instance: (gdb) p get_data_member(t, "tm_sec") This would yield: $19 = std::shared_ptr<abigail::ir::var_decl> (use count 4, weak count 0) = {get() = 0x9d9a80} We could visualize that data member by doing: (gdb) p debug(get_data_member(t, "tm_sec")._M_ptr) int tm::tm_sec (gdb) The patch also provides a new 'debug_equals' function that allow us to easily perform an artifact comparison from the command line of the debugger, as well as methods to the environment type to poke at the canonical types available in the environment. These new debugging primitives already proved priceless while debugging issues that are fixed by subsequent patches to come. * include/abg-fwd.h (get_debug_representation, get_data_member) (debug, debug_equals): Declare new functions. * include/abg-ir.h (environment{get_canonical_types, get_canonical_type}): Declare new member functions. * src/abg-ir.cc (environment::{get_canonical_types, get_canonical_type}): Define new member functions. (get_debug_representation, get_data_member) (debug, debug_equals): Define new functions. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
---|---|---|
.. | ||
abg-comp-filter.h | ||
abg-comparison.h | ||
abg-config.h | ||
abg-corpus.h | ||
abg-cxx-compat.h | ||
abg-diff-utils.h | ||
abg-dwarf-reader.h | ||
abg-fwd.h | ||
abg-hash.h | ||
abg-ini.h | ||
abg-interned-str.h | ||
abg-ir.h | ||
abg-libxml-utils.h | ||
abg-reader.h | ||
abg-regex.h | ||
abg-reporter.h | ||
abg-sptr-utils.h | ||
abg-suppression.h | ||
abg-tools-utils.h | ||
abg-traverse.h | ||
abg-version.h.in | ||
abg-viz-common.h | ||
abg-viz-dot.h | ||
abg-viz-svg.h | ||
abg-workers.h | ||
abg-writer.h | ||
Makefile.am |