libabigail
Loading...
Searching...
No Matches
environment Class Reference

This is an abstraction of the set of resources necessary to manage several aspects of the internal representations of the Abigail library. More...

#include <abg-ir.h>

Classes

struct  priv
 The private data of the environment type. More...
 

Public Types

typedef std::unordered_map< string, std::vector< type_base_sptr > > canonical_types_map_type
 A convenience typedef for a map of canonical types. The key is the pretty representation string of a particular type and the value is the vector of canonical types that have the same pretty representation string.
 

Public Member Functions

 environment ()
 Default constructor of the environment type.
 
virtual ~environment ()
 Destructor for the environment type.
 
bool analyze_exported_interfaces_only () const
 Getter for the property that controls if we are to restrict the analysis to the types that are only reachable from the exported interfaces only, or if the set of types should be more broad than that. Typically, we'd restrict the analysis to types reachable from exported interfaces only (stricto sensu, that would really be only the types that are part of the ABI of well designed libraries) for performance reasons.
 
void analyze_exported_interfaces_only (bool f)
 Setter for the property that controls if we are to restrict the analysis to the types that are only reachable from the exported interfaces only, or if the set of types should be more broad than that. Typically, we'd restrict the analysis to types reachable from exported interfaces only (stricto sensu, that would really be only the types that are part of the ABI of well designed libraries) for performance reasons.
 
bool canonicalization_is_done () const
 Test if the canonicalization of types created out of the current environment is done.
 
void canonicalization_is_done (bool)
 Set a flag saying if the canonicalization of types created out of the current environment is done or not.
 
bool canonicalization_started () const
 Getter of a flag saying if the canonicalization process has started or not.
 
void canonicalization_started (bool)
 Setter of a flag saying if the canonicalization process has started or not.
 
bool decl_only_class_equals_definition () const
 Getter of the "decl-only-class-equals-definition" flag.
 
void decl_only_class_equals_definition (bool f) const
 Setter of the "decl-only-class-equals-definition" flag.
 
type_baseget_canonical_type (const char *name, unsigned index)
 Get a given canonical type which has a given "string representation".
 
const vector< type_base_sptr > * get_canonical_types (const char *name) const
 Get the vector of canonical types which have a given "string representation".
 
canonical_types_map_typeget_canonical_types_map ()
 Getter the map of canonical types.
 
const canonical_types_map_typeget_canonical_types_map () const
 Getter the map of canonical types.
 
const configget_config () const
 Getter of the general configuration object.
 
const type_base_sptr & get_variadic_parameter_type () const
 Get a type_decl instance that represents a the type of a variadic function parameter. This node must be the only one representing a variadic parameter type in the system.
 
const type_base_sptr & get_void_pointer_type () const
 Getter of the "pointer-to-void" IR node that is shared across the ABI corpus. This node must be the only one representing a void pointer type in the system.
 
const type_base_sptr & get_void_type () const
 Get the unique type_decl that represents a "void" type for the current environment. This node must be the only one representing a void type in the system.
 
interned_string intern (const string &) const
 Do intern a string.
 
bool is_variadic_parameter_type (const type_base *) const
 Test if a type is a variadic parameter type as defined in the current environment.
 
bool is_variadic_parameter_type (const type_base_sptr &) const
 Test if a type is a variadic parameter type as defined in the current environment.
 
bool is_void_pointer_type (const type_base *) const
 Test if a given type is the same as the void pointer type of the environment.
 
bool is_void_pointer_type (const type_base_sptr &) const
 Test if a given type is the same as the void pointer type of the environment.
 
bool is_void_type (const type_base *) const
 Test if a given type is a void type as defined in the current environment.
 
bool is_void_type (const type_base_sptr &) const
 Test if a given type is a void type as defined in the current environment.
 
bool user_set_analyze_exported_interfaces_only () const
 Getter for a property that says if the user actually did set the analyze_exported_interfaces_only() property. If not, it means the default behaviour prevails.
 

Static Public Member Functions

static string & get_variadic_parameter_type_name ()
 Getter of the name of the variadic parameter type.
 

Public Attributes

std::unique_ptr< privpriv_
 

Friends

class class_decl
 
class class_or_union
 
class function_type
 
void keep_type_alive (type_base_sptr t)
 Make sure that the life time of a given (smart pointer to a) type is the same as the life time of the libabigail library.
 

Detailed Description

This is an abstraction of the set of resources necessary to manage several aspects of the internal representations of the Abigail library.

An environment can be seen as the boundaries in which all related Abigail artifacts live. So before doing anything using this library, the first thing to create is, well, you know it now, an environment.

Note that the lifetime of environment objects must be longer than the lifetime of any other type in the Abigail system. So a given instance of environment must stay around as long as you are using libabigail. It's only when you are done using the library that you can de-allocate the environment instance.

Definition at line 147 of file abg-ir.h.

Member Typedef Documentation

◆ canonical_types_map_type

std::unordered_map<string, std::vector<type_base_sptr> > canonical_types_map_type

A convenience typedef for a map of canonical types. The key is the pretty representation string of a particular type and the value is the vector of canonical types that have the same pretty representation string.

Definition at line 158 of file abg-ir.h.

Constructor & Destructor Documentation

◆ environment()

Default constructor of the environment type.

Definition at line 3224 of file abg-ir.cc.

◆ ~environment()

~environment ( )
virtual

Destructor for the environment type.

Definition at line 3229 of file abg-ir.cc.

Member Function Documentation

◆ analyze_exported_interfaces_only() [1/2]

bool analyze_exported_interfaces_only ( ) const

Getter for the property that controls if we are to restrict the analysis to the types that are only reachable from the exported interfaces only, or if the set of types should be more broad than that. Typically, we'd restrict the analysis to types reachable from exported interfaces only (stricto sensu, that would really be only the types that are part of the ABI of well designed libraries) for performance reasons.

Parameters
fthe value of the flag.

Definition at line 3619 of file abg-ir.cc.

◆ analyze_exported_interfaces_only() [2/2]

void analyze_exported_interfaces_only ( bool f)

Setter for the property that controls if we are to restrict the analysis to the types that are only reachable from the exported interfaces only, or if the set of types should be more broad than that. Typically, we'd restrict the analysis to types reachable from exported interfaces only (stricto sensu, that would really be only the types that are part of the ABI of well designed libraries) for performance reasons.

Parameters
fthe value of the flag.

Definition at line 3606 of file abg-ir.cc.

◆ canonicalization_is_done() [1/2]

bool canonicalization_is_done ( ) const

Test if the canonicalization of types created out of the current environment is done.

Returns
true iff the canonicalization of types created out of the current environment is done.

Definition at line 3386 of file abg-ir.cc.

◆ canonicalization_is_done() [2/2]

void canonicalization_is_done ( bool f)

Set a flag saying if the canonicalization of types created out of the current environment is done or not.

Note that this function must only be called by internal code of the library that creates ABI artifacts (e.g, read an abi corpus from elf or from our own xml format and creates representations of types out of it) and thus needs to canonicalize types to speed-up further type comparison.

Parameters
fthe new value of the flag.

Definition at line 3400 of file abg-ir.cc.

◆ canonicalization_started() [1/2]

bool canonicalization_started ( ) const

Getter of a flag saying if the canonicalization process has started or not.

Returns
the flag saying if the canonicalization process has started or not.

Definition at line 3413 of file abg-ir.cc.

◆ canonicalization_started() [2/2]

void canonicalization_started ( bool f)

Setter of a flag saying if the canonicalization process has started or not.

Parameters
fthe new value of the flag saying if the canonicalization process has started or not.

Definition at line 3422 of file abg-ir.cc.

◆ decl_only_class_equals_definition() [1/2]

bool decl_only_class_equals_definition ( ) const

Getter of the "decl-only-class-equals-definition" flag.

Usually, a declaration-only class named 'struct foo' compares equal to any class definition named "struct foo'. This is at least true for C++. In C, though, because there can be multiple definitions of 'struct foo' in the binary, a declaration-only "struct foo" might be considered to *NOT* resolve to any of the struct foo defined. In that case, the declaration-only "struct foo" is considered different from the definitions. This flag controls the behaviour of the comparison of an unresolved decl-only class against a definition of the same name. If set to false, the the declaration equals the definition. If set to false, then the decalration is considered different from the declaration. @return the value of the "decl-only-class-equals-definition" flag.

Definition at line 3446 of file abg-ir.cc.

◆ decl_only_class_equals_definition() [2/2]

void decl_only_class_equals_definition ( bool f) const

Setter of the "decl-only-class-equals-definition" flag.

Usually, a declaration-only class named 'struct foo' compares equal to any class definition named "struct foo'. This is at least true for C++. In C, though, because there can be multiple definitions of 'struct foo' in the binary, a declaration-only "struct foo" might be considered to *NOT* resolve to any of the struct foo defined. In that case, the declaration-only "struct foo" is considered different from the definitions. This flag controls the behaviour of the comparison of an unresolved decl-only class against a definition of the same name. If set to false, the the declaration equals the definition. If set to false, then the decalration is considered different from the declaration. @param the new value of the "decl-only-class-equals-definition" flag.

Definition at line 3471 of file abg-ir.cc.

◆ get_canonical_type()

type_base * get_canonical_type ( const char * name,
unsigned index )

Get a given canonical type which has a given "string representation".

Parameters
'name',thetextual representation of the type as returned by type_or_decl_base::get_pretty_representation(/*internal=*‍/true, /*qualified=*‍/true).
index,theindex of the type in the vector of types that all have the same textual representation 'name'. That vector is returned by the function environment::get_canonical_types().
Returns
the canonical type which has the representation name, and which is at index index in the vector of canonical types having that same textual representation.

Definition at line 3753 of file abg-ir.cc.

◆ get_canonical_types()

const vector< type_base_sptr > * get_canonical_types ( const char * name) const

Get the vector of canonical types which have a given "string representation".

Parameters
'name',thetextual representation of the type as returned by type_or_decl_base::get_pretty_representation(/*internal=*‍/true, /*qualified=*‍/true)

This is useful to for debugging purposes as it's handy to use from inside a debugger like GDB.

Returns
a pointer to the vector of canonical types having the representation name, or nullptr if no type with that representation exists.

Definition at line 3730 of file abg-ir.cc.

◆ get_canonical_types_map() [1/2]

environment::canonical_types_map_type & get_canonical_types_map ( )

Getter the map of canonical types.

Returns
the map of canonical types. The key of the map is the hash of the canonical type and its value if the canonical type.

Definition at line 3237 of file abg-ir.cc.

◆ get_canonical_types_map() [2/2]

const environment::canonical_types_map_type & get_canonical_types_map ( ) const

Getter the map of canonical types.

Returns
the map of canonical types. The key of the map is the hash of the canonical type and its value if the canonical type.

Definition at line 3245 of file abg-ir.cc.

◆ get_config()

const config & get_config ( ) const

Getter of the general configuration object.

Returns
the configuration object.

Definition at line 3583 of file abg-ir.cc.

◆ get_variadic_parameter_type()

const type_base_sptr & get_variadic_parameter_type ( ) const

Get a type_decl instance that represents a the type of a variadic function parameter. This node must be the only one representing a variadic parameter type in the system.

Note that upon first use of this IR node (by the relevant front-end, for instance) it must be added to a scope using e.g, the add_decl_to_scope() function.

Returns
the Get a type_decl instance that represents a the type of a variadic function parameter.

Definition at line 3361 of file abg-ir.cc.

◆ get_variadic_parameter_type_name()

string & get_variadic_parameter_type_name ( )
static

Getter of the name of the variadic parameter type.

Returns
the name of the variadic parameter type.

Definition at line 3374 of file abg-ir.cc.

◆ get_void_pointer_type()

const type_base_sptr & get_void_pointer_type ( ) const

Getter of the "pointer-to-void" IR node that is shared across the ABI corpus. This node must be the only one representing a void pointer type in the system.

Note that upon first use of this IR node (by the relevant front-end, for instance) it must be added to a scope using e.g, the add_decl_to_scope() function.

Returns
the "pointer-to-void" IR node.

Definition at line 3342 of file abg-ir.cc.

◆ get_void_type()

const type_base_sptr & get_void_type ( ) const

Get the unique type_decl that represents a "void" type for the current environment. This node must be the only one representing a void type in the system.

Note that upon first use of this IR node (by the relevant front-end, for instance) it must be added to a scope using e.g, the add_decl_to_scope() function.

Returns
the type_decl that represents a "void" type.

Definition at line 3323 of file abg-ir.cc.

◆ intern()

interned_string intern ( const string & s) const

Do intern a string.

If a value of this string already exists in the interned string pool of the current environment, then this function returns a new interned_string pointing to that already existing string. Otherwise, a new string is created, stored in the interned string pool and a new interned_string instance is created to point to that new intrerned string, and it's return.

Parameters
sthe value of the string to intern.
Returns
the interned string.

Definition at line 3576 of file abg-ir.cc.

◆ is_variadic_parameter_type() [1/2]

bool is_variadic_parameter_type ( const type_base * t) const

Test if a type is a variadic parameter type as defined in the current environment.

Parameters
tthe type to consider.
Returns
true iff t is a variadic parameter type as defined in the current environment.

Definition at line 3545 of file abg-ir.cc.

◆ is_variadic_parameter_type() [2/2]

bool is_variadic_parameter_type ( const type_base_sptr & t) const

Test if a type is a variadic parameter type as defined in the current environment.

Parameters
tthe type to consider.
Returns
true iff t is a variadic parameter type as defined in the current environment.

Definition at line 3560 of file abg-ir.cc.

◆ is_void_pointer_type() [1/2]

bool is_void_pointer_type ( const type_base * t) const

Test if a given type is the same as the void pointer type of the environment.

Parameters
tthe IR type to test.
Returns
true iff t is the void pointer returned by environment::get_void_pointer_type().

Definition at line 3529 of file abg-ir.cc.

◆ is_void_pointer_type() [2/2]

bool is_void_pointer_type ( const type_base_sptr & t) const

Test if a given type is the same as the void pointer type of the environment.

Parameters
tthe IR type to test.
Returns
true iff t is the void pointer returned by environment::get_void_pointer_type().

Definition at line 3513 of file abg-ir.cc.

◆ is_void_type() [1/2]

bool is_void_type ( const type_base * t) const

Test if a given type is a void type as defined in the current environment.

Parameters
tthe type to consider.
Returns
true iff t is a void type as defined in the current environment.

Definition at line 3497 of file abg-ir.cc.

◆ is_void_type() [2/2]

bool is_void_type ( const type_base_sptr & t) const

Test if a given type is a void type as defined in the current environment.

Parameters
tthe type to consider.
Returns
true iff t is a void type as defined in the current environment.

Definition at line 3482 of file abg-ir.cc.

◆ user_set_analyze_exported_interfaces_only()

bool user_set_analyze_exported_interfaces_only ( ) const

Getter for a property that says if the user actually did set the analyze_exported_interfaces_only() property. If not, it means the default behaviour prevails.

Returns
tru iff the user did set the analyze_exported_interfaces_only() property.

Definition at line 3593 of file abg-ir.cc.

Friends And Related Symbol Documentation

◆ class_decl

friend class class_decl
friend

Definition at line 290 of file abg-ir.h.

◆ class_or_union

friend class class_or_union
friend

Definition at line 289 of file abg-ir.h.

◆ function_type

friend class function_type
friend

Definition at line 291 of file abg-ir.h.

◆ keep_type_alive

void keep_type_alive ( type_base_sptr t)
friend

Make sure that the life time of a given (smart pointer to a) type is the same as the life time of the libabigail library.

Parameters
tthe type to consider.

Definition at line 27915 of file abg-ir.cc.

Member Data Documentation

◆ priv_

std::unique_ptr<priv> priv_

Definition at line 151 of file abg-ir.h.


The documentation for this class was generated from the following files: