ir: Add new environment::get_type_id_from_type
authorDodji Seketeli <dodji@redhat.com>
Thu, 13 Apr 2023 14:03:04 +0000 (16:03 +0200)
committerDodji Seketeli <dodji@redhat.com>
Thu, 13 Apr 2023 14:03:04 +0000 (16:03 +0200)
While debugging some issues, I felt the need to easily get the type-id
from a given ir::type_base* from within the debugger.

I have thus added this new environment::get_type_id_from_type member
function.

* include/abg-ir.h (environment::get_pointer_type_id_map): Declare
...
* src/abg-ir.cc (environment::get_pointer_type_id_map): ... this
new member function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
include/abg-ir.h
src/abg-ir.cc

index d25e3a8c964566a724dfd8b4e6bb3911bc1a3f79..263bff5eb3b679d0dde2a59258ee114274d80922 100644 (file)
@@ -253,6 +253,9 @@ public:
   string
   get_type_id_from_pointer(uintptr_t ptr);
 
+  string
+  get_type_id_from_type(const type_base *ptr);
+
   uintptr_t
   get_canonical_type_from_type_id(const char*);
 #endif
index 64dfee791743860983b8f3c6b6348571521d4da4..4da8c461f729f89e0c26cf411057c502204659e3 100644 (file)
@@ -3944,6 +3944,25 @@ environment::get_type_id_from_pointer(uintptr_t ptr)
   return "";
 }
 
+/// Getter of the type-id that corresponds to the value of an
+/// abigail::ir::type_base that was created from the abixml reader.
+///
+/// That value is retrieved from the map returned from
+/// environment::get_pointer_type_id_map().
+///
+/// That map is populated at abixml reading time, (by build_type())
+/// when a given XML element representing a type is read into a
+/// corresponding abigail::ir::type_base.
+///
+/// This is used only for the purpose of debugging the
+/// self-comparison process.  That is, when invoking "abidw
+/// --debug-abidiff".
+///
+/// @return the type-id strings that corresponds
+string
+environment::get_type_id_from_type(const type_base *t)
+{return get_type_id_from_pointer(reinterpret_cast<uintptr_t>(t));}
+
 /// Getter of the canonical type of the artifact designated by a
 /// type-id.
 ///