libabigail
Typedefs | Enumerations | Functions
abigail::xml_writer Namespace Reference

The namespace for the native XML file format writer. More...

Typedefs

typedef unordered_map< shared_ptr< class_tdecl >, string, class_tdecl::shared_ptr_hashclass_tmpl_shared_ptr_map
 
typedef unordered_map< shared_ptr< function_tdecl >, string, function_tdecl::shared_ptr_hashfn_tmpl_shared_ptr_map
 
typedef std::unordered_set< function_type * > fn_type_ptr_set_type
 A convenience typedef for a set of function type*. More...
 
typedef std::unordered_map< const type_base *, interned_string, non_canonicalized_type_hash, non_canonicalized_type_equal > nc_type_ptr_istr_map_type
 A map meant to carry non canonicalized types as key. More...
 
typedef std::unordered_set< const type_base *, non_canonicalized_type_hash, non_canonicalized_type_equal > nc_type_ptr_set_type
 A set meant to carry non canonicalized types. More...
 
typedef unordered_map< type_base *, interned_stringtype_ptr_map
 A convenience typedef for a map that associates a pointer to type to a string. More...
 
typedef std::unordered_set< const type_base * > type_ptr_set_type
 
typedef shared_ptr< write_context > write_context_sptr
 A convenience typedef for a shared pointer to write_context. More...
 

Enumerations

enum  type_id_style_kind { SEQUENCE_TYPE_ID_STYLE , HASH_TYPE_ID_STYLE }
 The style of type id the XML writer will output. More...
 

Functions

template<>
bool annotate (const elf_symbol_sptr &sym, write_context &ctxt, unsigned indent)
 Annotate an elf symbol in form of an ABIXML comment, effectively writing out its demangled form. More...
 
template<>
bool annotate (const function_decl::parameter_sptr &parm, write_context &ctxt, unsigned indent)
 Annotate a function parameter in form of an ABIXML comment. More...
 
bool annotate (const function_type_sptr &function_type, write_context &ctxt, unsigned indent)
 Annotate a function type in form of an ABIXML comment. More...
 
template<>
bool annotate (const typedef_decl_sptr &typedef_decl, write_context &ctxt, unsigned indent)
 Annotate a typedef declaration in form of an ABIXML comment. More...
 
write_context_sptr create_write_context (const environment &env, ostream &default_output_stream)
 Create a write_context object that can be used to emit abixml files. More...
 
void set_annotate (write_context &ctxt, bool flag)
 Set the 'annotate' flag. More...
 
template<typename OPTS >
void set_common_options (write_context &ctxt, const OPTS &opts)
 A convenience generic function to set common options (usually used by Libabigail tools) from a generic options carrying-object, into a given write_context. More...
 
void set_ostream (write_context &ctxt, ostream &os)
 Set the new ostream. More...
 
void set_short_locs (write_context &ctxt, bool flag)
 Set the 'short-locs' flag. More...
 
void set_show_locs (write_context &ctxt, bool flag)
 Set the "show-locs" flag. More...
 
void set_type_id_style (write_context &ctxt, type_id_style_kind style)
 Set the 'type-id-style' property. More...
 
void set_write_architecture (write_context &ctxt, bool flag)
 Set the 'write-architecture' flag. More...
 
void set_write_comp_dir (write_context &ctxt, bool flag)
 Set the 'write-comp-dir' flag. More...
 
void set_write_corpus_path (write_context &ctxt, bool flag)
 Set the 'write-corpus-path' flag. More...
 
void set_write_default_sizes (write_context &ctxt, bool flag)
 Set the 'default-sizes' flag. More...
 
void set_write_elf_needed (write_context &ctxt, bool flag)
 Set the 'elf-needed' flag. More...
 
void set_write_parameter_names (write_context &ctxt, bool flag)
 Set the 'parameter-names' flag. More...
 
void set_write_undefined_symbols (write_context &ctxt, bool flag)
 Set the 'undefined-symbols' flag. More...
 
bool write_corpus (write_context &ctxt, const corpus_sptr &corpus, unsigned indent, bool member_of_group)
 Serialize an ABI corpus to a single native xml document. The root note of the resulting XML document is 'abi-corpus'. More...
 
bool write_corpus_group (write_context &ctxt, const corpus_group_sptr &group, unsigned indent)
 Serialize an ABI corpus group to a single native xml document. The root note of the resulting XML document is 'abi-corpus-group'. More...
 
bool write_corpus_to_archive (const corpus &corp, const bool annotate=false)
 
bool write_corpus_to_archive (const corpus &corp, const string &path, const bool annotate=false)
 
bool write_corpus_to_archive (const corpus_sptr corp, const bool annotate=false)
 
bool write_translation_unit (write_context &ctxt, const translation_unit &tu, const unsigned indent, bool is_last)
 Serialize a translation unit to an output stream. More...
 

Detailed Description

The namespace for the native XML file format writer.

It contains utilities to serialize ABI artifacts from the ir namespace into the native XML format.

Typedef Documentation

◆ fn_type_ptr_set_type

typedef std::unordered_set<function_type*> fn_type_ptr_set_type

A convenience typedef for a set of function type*.

Definition at line 196 of file abg-writer.cc.

◆ nc_type_ptr_istr_map_type

typedef std::unordered_map<const type_base*, interned_string, non_canonicalized_type_hash, non_canonicalized_type_equal> nc_type_ptr_istr_map_type

A map meant to carry non canonicalized types as key.

Those types make the function is_non_canonicalized_type return true.

Definition at line 193 of file abg-writer.cc.

◆ nc_type_ptr_set_type

typedef std::unordered_set<const type_base*, non_canonicalized_type_hash, non_canonicalized_type_equal> nc_type_ptr_set_type

A set meant to carry non canonicalized types.

Those types make the function is_non_canonicalized_type return true.

Definition at line 184 of file abg-writer.cc.

◆ type_ptr_map

typedef unordered_map<type_base*, interned_string> type_ptr_map

A convenience typedef for a map that associates a pointer to type to a string.

Definition at line 110 of file abg-writer.cc.

◆ write_context_sptr

typedef shared_ptr<write_context> write_context_sptr

A convenience typedef for a shared pointer to write_context.

Definition at line 36 of file abg-writer.h.

Enumeration Type Documentation

◆ type_id_style_kind

The style of type id the XML writer will output.

Definition at line 27 of file abg-writer.h.

Function Documentation

◆ annotate() [1/4]

bool abigail::xml_writer::annotate ( const elf_symbol_sptr sym,
write_context &  ctxt,
unsigned  indent 
)

Annotate an elf symbol in form of an ABIXML comment, effectively writing out its demangled form.

Parameters
symthe symbol, whose name should be demangled.
ctxtthe context of the parsing.
indentthe amount of white space to indent to.
Returns
true iff decl is valid

Definition at line 1106 of file abg-writer.cc.

◆ annotate() [2/4]

bool abigail::xml_writer::annotate ( const function_decl::parameter_sptr parm,
write_context &  ctxt,
unsigned  indent 
)

Annotate a function parameter in form of an ABIXML comment.

Parameters
parmthe function parameter to annotate.
ctxtthe context of the parsing.
indentthe amount of white space to indent to.
Returns
true iff decl is valid

Definition at line 1268 of file abg-writer.cc.

◆ annotate() [3/4]

bool abigail::xml_writer::annotate ( const function_type_sptr function_type,
write_context &  ctxt,
unsigned  indent 
)

Annotate a function type in form of an ABIXML comment.

Parameters
function_typethe function type to annotate.
ctxtthe context of the parsing.
indentthe amount of white space to indent to.
skip_first_parmif true, do not serialize the first parameter of the function decl.
Returns
true iff decl is valid

Definition at line 1173 of file abg-writer.cc.

◆ annotate() [4/4]

bool abigail::xml_writer::annotate ( const typedef_decl_sptr typedef_decl,
write_context &  ctxt,
unsigned  indent 
)

Annotate a typedef declaration in form of an ABIXML comment.

Parameters
typedef_declthe typedef to annotate.
ctxtthe context of the parsing.
indentthe amount of white space to indent to.
Returns
true iff decl is valid

Definition at line 1137 of file abg-writer.cc.

◆ create_write_context()

write_context_sptr create_write_context ( const environment env,
ostream &  default_output_stream 
)

Create a write_context object that can be used to emit abixml files.

Parameters
envthe environment for the write_context object to use.
default_output_streamthe default output stream to use.
Returns
the new write_context object.

Definition at line 2210 of file abg-writer.cc.

◆ set_annotate()

void set_annotate ( write_context &  ctxt,
bool  flag 
)

Set the 'annotate' flag.

When this flag is set then the XML writer annotates ABI artifacts with a human readable description.

Parameters
ctxtthe context to set this flag on to.
flagthe new value of the 'annotate' flag.

Definition at line 2239 of file abg-writer.cc.

◆ set_common_options()

void abigail::xml_writer::set_common_options ( write_context &  ctxt,
const OPTS &  opts 
)

A convenience generic function to set common options (usually used by Libabigail tools) from a generic options carrying-object, into a given write_context.

Parameters
ctxtthe the write_context to consider.
optsthe option-carrying object to set the options from. It must contain data members named: annotate, and show_locs, at very least.

Definition at line 86 of file abg-writer.h.

◆ set_ostream()

void set_ostream ( write_context &  ctxt,
ostream &  os 
)

Set the new ostream.

The ostream refers to the object, writers should stream new output to.

Parameters
ctxtthe context to set this to.
osthe new ostream

Definition at line 2250 of file abg-writer.cc.

◆ set_short_locs()

void set_short_locs ( write_context &  ctxt,
bool  flag 
)

Set the 'short-locs' flag.

When this flag is set then the XML writer will emit only file names rather than full paths.

Parameters
ctxtthe context to set this flag on to.
flagthe new value of the 'short-locs' flag.

Definition at line 2298 of file abg-writer.cc.

◆ set_show_locs()

void set_show_locs ( write_context &  ctxt,
bool  flag 
)

Set the "show-locs" flag.

When this flag is set then the XML writer emits location (/// information (file name, line and column) for the ABI artifacts that it emits.

Parameters
ctxtthe write_context to set the option for.
flagthe new value of the option.

Definition at line 2227 of file abg-writer.cc.

◆ set_type_id_style()

void set_type_id_style ( write_context &  ctxt,
type_id_style_kind  style 
)

Set the 'type-id-style' property.

This property controls the kind of type ids used in XML output.

Parameters
ctxtthe context to set this property on.
stylethe new value of the 'type-id-style' property.

Definition at line 2360 of file abg-writer.cc.

◆ set_write_architecture()

void set_write_architecture ( write_context &  ctxt,
bool  flag 
)

Set the 'write-architecture' flag.

When this flag is set then the XML writer will emit architecture information

Parameters
ctxtthe context to set this flag on to.
flagthe new value of the 'write-architecture' flag.

Definition at line 2262 of file abg-writer.cc.

◆ set_write_comp_dir()

void set_write_comp_dir ( write_context &  ctxt,
bool  flag 
)

Set the 'write-comp-dir' flag.

When this flag is set then the XML writer will emit compilation dir information

Parameters
ctxtthe context to set this flag on to.
flagthe new value of the 'write-comp-dir' flag.

Definition at line 2286 of file abg-writer.cc.

◆ set_write_corpus_path()

void set_write_corpus_path ( write_context &  ctxt,
bool  flag 
)

Set the 'write-corpus-path' flag.

When this flag is set then the XML writer will emit corpus-path information

Parameters
ctxtthe context to set this flag on to.
flagthe new value of the 'write-corpus-path' flag.

Definition at line 2274 of file abg-writer.cc.

◆ set_write_default_sizes()

void set_write_default_sizes ( write_context &  ctxt,
bool  flag 
)

Set the 'default-sizes' flag.

When this flag is set then the XML writer will emit default size-in-bits attributes for pointer type definitions, reference type definitions, function declarations and function types even when they are equal to the default address size of the translation unit.

Parameters
ctxtthe context to set this flag on to.
flagthe new value of the 'default-sizes' flag.

Definition at line 2349 of file abg-writer.cc.

◆ set_write_elf_needed()

void set_write_elf_needed ( write_context &  ctxt,
bool  flag 
)

Set the 'elf-needed' flag.

When this flag is set then the XML writer will emit corpus get_needed() (DT_NEEDED) information.

Parameters
ctxtthe context to set this flag on to.
flagthe new value of the 'elf-needed' flag.

Definition at line 2322 of file abg-writer.cc.

◆ set_write_parameter_names()

void set_write_parameter_names ( write_context &  ctxt,
bool  flag 
)

Set the 'parameter-names' flag.

When this flag is set then the XML writer will emit the names of function parameters.

Parameters
ctxtthe context to set this flag on to.
flagthe new value of the 'parameter-names' flag.

Definition at line 2310 of file abg-writer.cc.

◆ set_write_undefined_symbols()

void set_write_undefined_symbols ( write_context &  ctxt,
bool  flag 
)

Set the 'undefined-symbols' flag.

When this flag is set then the XML writer will emit corpus information about the undefined function and variable symbols.

Parameters
ctxtthe context to set this flag on to.
flagthe new value of the 'undefined-symbols' flag.

Definition at line 2334 of file abg-writer.cc.

◆ write_corpus()

bool write_corpus ( write_context &  ctxt,
const corpus_sptr &  corpus,
unsigned  indent,
bool  member_of_group 
)

Serialize an ABI corpus to a single native xml document. The root note of the resulting XML document is 'abi-corpus'.

Note: If either corpus is null or corpus does not contain serializable content (i.e. corpus.is_empty()), nothing is emitted to the ctxt's output stream.

Parameters
ctxtthe write context to use.
corpusthe corpus to serialize.
indentthe number of white space indentation to use.
Returns
true upon successful completion, false otherwise.

Definition at line 4756 of file abg-writer.cc.

◆ write_corpus_group()

bool write_corpus_group ( write_context &  ctxt,
const corpus_group_sptr &  group,
unsigned  indent 
)

Serialize an ABI corpus group to a single native xml document. The root note of the resulting XML document is 'abi-corpus-group'.

Parameters
ctxtthe write context to use.
groupthe corpus group to serialize.
indentthe number of white space indentation to use.
Returns
true upon successful completion, false otherwise.

Definition at line 4904 of file abg-writer.cc.

◆ write_translation_unit()

bool write_translation_unit ( write_context &  ctxt,
const translation_unit tu,
const unsigned  indent,
bool  is_last 
)

Serialize a translation unit to an output stream.

Parameters
ctxtthe context of the serialization. It contains e.g, the output stream to serialize to.
tuthe translation unit to serialize.
indenthow many indentation spaces to use during the serialization.
is_lastIf true, it means the TU to emit is the last one of the corpus. If this is the case, all the remaining referenced types that were not emitted are going to be emitted here, irrespective of if they belong to this TU or not. This is quite a hack. Ideally, we should have a pass that walks all the TUs, detect their non-emitted referenced types, before hand. Then, when we start emitting the TUs, we know for each TU which non-emitted referenced type should be emitted. As we don't yet have such a pass, we do our best for now.
Returns
true upon successful completion, false otherwise.

Definition at line 2555 of file abg-writer.cc.