Add primitives callable from the command line of the debugger
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:
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 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.