libabigail/include
Dodji Seketeli 6eee409137 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:

   (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>
2021-05-25 12:08:10 +02:00
..
abg-comp-filter.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-comparison.h Bug 27569 - abidiff misses a function parameter addition 2021-03-29 12:34:48 +02:00
abg-config.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-corpus.h abg-corpus: remove symbol maps and their setters 2021-04-02 15:48:01 +02:00
abg-cxx-compat.h abg-cxx-compat: add simplified version of std::optional 2021-03-09 10:41:10 +01:00
abg-diff-utils.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-dwarf-reader.h dwarf reader: drop (now) unused code related to symbol table reading 2021-04-02 15:48:23 +02:00
abg-fwd.h Add primitives callable from the command line of the debugger 2021-05-25 12:08:10 +02:00
abg-hash.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-ini.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-interned-str.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-ir.h Add primitives callable from the command line of the debugger 2021-05-25 12:08:10 +02:00
abg-libxml-utils.h reader: Use xmlFirstElementChild and xmlNextElementSibling rather than xml::advance_to_next_sibling_element 2021-05-03 17:15:22 +02:00
abg-reader.h Bug 27512 - Remove broken zip-archive support 2021-03-19 10:52:57 +01:00
abg-regex.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-reporter.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-sptr-utils.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-suppression.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-tools-utils.h Bug 27512 - Remove broken zip-archive support 2021-03-19 10:52:57 +01:00
abg-traverse.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-version.h.in Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-viz-common.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-viz-dot.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-viz-svg.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-workers.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-writer.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
Makefile.am Bug 27512 - Remove broken zip-archive support 2021-03-19 10:52:57 +01:00