Commit Graph

12 Commits

Author SHA1 Message Date
Dodji Seketeli
67e6971005 Take filtering in account in diff stats & better categorizing
* include/abg-comparison.h
	(diff_category::ACCESS_CHANGE_CATEGORY): Renamed
	ACCESS_CHANGED_CATEGORY into this.
	(diff_category::SIZE_OR_OFFSET_CHANGE_CATEGORY): Renamed
	SIZE_CHANGED_CATEGORY into this.  Changed its semantics to
	incorporate offset changes as well.
	* src/abg-comparison.cc (struct noop_deleter): Move this up.
	(represent): Do not report filtered out data members.
	(report_mem_header): Add a new num_filtered parameter to take
	filtered-out members in account in members report headers.
	Adjust.
	(class_diff::priv::{count_filtered_bases,
	count_filtered_data_members, count_filtered_member_functions}):
	New member functions.  When a member is filtered, do not report
	it all.
	({enum_diff, class_diff}::report): Adjust.  Take filtered members
	into account in headers.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats): New
	member function.
	(corpus_diff::priv::emit_diff_stats): Renamed
	emit_corpus_diff_stats into this.  Change it to take the stats in
	parameter.
	(corpus_diff::report): Adjust to re-use the above.  Filter
	varibles as well.  Take the filtered functions & variables in
	account in the stats.  Do not report filtered-out functions &
	variables at all.
	* src/abg-comp-filter.cc (type_size_changed, access_changed)
	(data_member_offset_changed): New predicates.
	({harmless, harmful}_filter::visit): Adjust to use the new
	predicates above.  Update the harmful variant for the new
	SIZE_OR_OFFSET_CHANGE_CATEGORY category.
	* tools/bidiff.cc (set_diff_context_from_opts): Adjust for the
	categories name changes.
	* tests/data/test-diff-filter/test0-report.txt: New test input.
	* tests/data/test-diff-filter/test0-v0.cc: Likewise.
	* tests/data/test-diff-filter/test0-v0.o: Likewise.
	* tests/data/test-diff-filter/test0-v1.cc: Likewise.
	* tests/data/test-diff-filter/test0-v1.o: Likewise.
	* tests/test-diff-filter.cc: New test harness.
	* tests/Makefile.am: Add the new test files above to the
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-29 10:26:45 +01:00
Dodji Seketeli
802f7cbc92 Initial implementation of diff tree node filtering
* include/abg-comp-filter.h: New file.
	* include/Makefile.am: Add the new include/abg-comp-filter.h to
	the source distribution.
	* include/abg-comparison.h (enum visiting_kind, diff_category): New enums.
	(operator|): Declare new operator declaration for the new
	visiting_kind enum.
	(operator{|,^,&,~}): Declare new operator decl for the new
	diff_category enum.
	(diff_context::{get_allowed_category, set_allowed_category,
	switch_categories_on, switch_categories_off, diff_filters,
	add_diff_filter, maybe_apply_filters}): Declare new member functions.
	(diff::{parent_, category_}): New members.
	(diff::diff): Adjust.
	(diff::{get_parent, set_parent, get_category, add_to_category,
	is_filtered_out, to_be_reported}):  New members.
	(diff_node_visitor::{get_visiting_kind, set_visiting_kind}): New
	members.
	(diff_node_visitor::visit): Add a new flag to saying if the
	visitor is being called in post or pre children traversing mode.
	* src/abg-comparison.cc (operator|): Declare new operator
	declaration for the new visiting_kind enum.
	(operator{|,^,&,~}): Declare new operator decl for the new
	diff_category enum.
	(diff_context::priv::{allowed_category_, filters_}): New members.
	(diff_context::diff_context): Add all known filters.
	(diff_context::{get_allowed_category, set_allowed_category,
	switch_categories_on, switch_categories_off, diff_filters,
	add_diff_filter, maybe_apply_filters}): Define new member
	functions.
	(diff::{is_filtered_out, to_be_reported}): Define new members.
	(*::report): Use the new diff::to_be_reported function.
	(*::traverse): Adjust for pre/post visiting.
	(var_diff::var_diff): Chain the type diff node to its parent.
	({pointer_diff, reference_diff, qualified_type_diff,
	typedef_diff}::underlying_type_diff): Chain the underlying type
	diff node to its parent.
	(enum_diff::enum_diff): Likewise.
	(base_diff::underlying_class_diff): Likewise.
	({class_diff, corpus_diff}::report): Do not report changed
	(member) functions that have been filtered out.  Rather report
	that they have been filtered out.
	({function_decl_diff, class_diff}::traverse): Chain underlying
	type diff nodes to their parent.
	(diff_node_visitor::visit): Add a new flag to saying if the
	visitor is being called in post or pre children traversing mode.
	Make sure to call the default diff::visit overload.
	* src/abg-comp-filter.cc: New file.
	* src/Makefile.am: Add the new abg-comp-filter.cc to the source
	distribution.
	* tools/bidiff.cc (options::show_harm{ful,less}_changes): New
	members.
	(display_usage): Add usage strings for --no-harmless and
	--no-harmful options.
	(parse_command_line): Parse --no-harmless and --no-harmful command
	line options.
	(set_diff_context_from_opts): Populate the diff context
	accordingly.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-27 13:01:18 +01:00
Dodji Seketeli
bac732ff5a Add --drop/--keep options to bidiff
* include/abg-sptr-utils.h: New file.
	* include/Makefile.am: Add abg-sptr-utils. to the build system.
	* include/abg-libxml-utils.h (reader_sptr, xml_char_sptr): Remove
	these typedefs as there are now in abg-sptr-utils.
	(build_sptr): Likewise for this template and its specializations
	declarations.
	* src/abg-libxml-utils.cc (sptr_utils::build_sptr): Mode the
	definition of the specializations for xmlTextReader and xmlChar
	into the sptr_utils namespace.
	* include/abg-corpus.h
	(corpus::{get_regex_patterns_of_fns_to_suppress,
	get_regex_patterns_of_vars_to_suppress,
	get_regex_patterns_of_fns_to_keep,
	get_regex_patterns_of_vars_to_keep}): Declare new member
	functions.
	* src/abg-comparison.cc (sptr_utils::regex_t_deleter): Define new
	functor.
	(build_sptr) Define new specialization for regex_t.
	(struct array_deleter): Remove unused functor.
	(corpus::priv::regex_patterns_{fns,vars}_to_{suppress,keep}): New data
	members.
	(symtab_build_visitor_type::regex_patterns_{fns,vars}_to_{suppress,keep}):
	Likewise.
	(symtab_build_visitor_type::r_{fns,vars}_{suppress,keep})):
	Likewise.
	(symtab_build_visitor_type::symtab_build_visitor_type): Update the
	signature of this constructor to take regex patterns for functions
	and variables to suppress and to keep.  Also, initialize the data
	members from these new parameters.
	(symtab_build_visitor_type::regex_{fns,vars}_{suppress,keep}): New
	member functions.
	(symtab_build_visitor_type::{add_fn_to_wip_fns,
	add_var_to_wip_vars}): Likewise.
	(symtab_build_visitor_type::visit) Use either add_fn_to_wip_fns or
	add_var_to_wip_vars depending on the overload of the visit()
	member.
	(corpus::priv::build_symbol_table): Update for the change of the
	symtab_build_visitor_type constructor signature.
	(corpus::get_regex_patterns_of_{fns,vars}_to_{suppress,keep}):
	Define new member functions.
	* tools/bidiff.cc (options::{drop,keep}_{fn,var}_regex_patterns}):
	New data member.
	(display_usage): Add help strings for --drop, --drop-fn,
	--drop-var, --keep, --keep-fn, --keep-var
	(parse_command_line): Parse the command lines above.
	(set_corpus_keep_drop_regex_patterns): Define new static function.
	(main): Use the new set_corpus_keep_drop_regex_patterns.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 17:59:39 +01:00
Dodji Seketeli
fde5a31a2a Add a --stat option to bidiff
* include/abg-comparison.h (diff_context::show_stats_only):
	Declare new accessors.
	* src/abg-comparison.cc
	(diff_context::priv::show_stats_only_): New member.
	(diff_context::show_stats_only): Define new accessors.
	(corpus_diff::report): If showing stats only, quit right after
	showing the summary.
	* tools/bidiff.cc (options::show_stats_only): New data member.
	(options::options): Initialize the new data member.
	(display_usage): Add help string for --stat.
	(parse_command_line): Parse the --stat option.
	(set_diff_context_from_opts): Update to set the show_stats_only
	onto the context.  Cleanup the logic to make it more compact.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 13:03:53 +01:00
Dodji Seketeli
fd21fea696 Add --{changed,deleted,added}-{fns,vars} options to bidiff
* include/abg-comparison.h
	(diff_context::{show_{deleted,changed_added}_{fns,vars}}): Declare
	new accessors.
	(corpus_diff::context): Declare new getter.
	* src/abg-comparison.cc
	(diff_context::{show_{deleted,changed_added}_{fns,vars}}): Define
	these new accessors.
	(corpus_diff::priv::emit_corpus_diff_stats): Define new function.
	(corpus_diff::context()): Define new getter.
	(corpus_diff::report): Use the new
	corpus_diff::priv::emit_corpus_diff_stats to emit diff stats at
	the beginning of the report.  Conditionalise emitting the
	different parts of the reports (changed,deleted,added stuff) on
	the values of the new properties that were just added.
	* tools/bidiff.cc
	(options::{show_{deleted,changed,added}_{fns,vars}): New
	properties.
	(display_usage, parse_command_line): Update for the newly added
	--{changed,deleted,added}-{fns,vars} command line options.
	(set_diff_context_from_opts): Define new static function.
	(main): Create a diff context, initialize it from the options
	(using set_diff_context_from_opts) and pass it to compute_diff.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-12 16:42:14 +01:00
Dodji Seketeli
7209295af9 Add --show-symtabs to bidiff
* tools/bidiff.cc (display_usage): Update usage string.
	(parse_command_line): Recognize the --show-symtab cmdline option.
	(display_symtabs): New static function.
	(main): Call the new display_symtabs.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-11 16:22:52 +01:00
Dodji Seketeli
2c9fb3e70d Support new 'abi-corpus' native XML format (.abi)
* include/abg-reader.h (read_corpus_from_native_xml)
	(read_corpus_from_native_xml_file): Declare new entry points.
	* include/abg-writer.h (write_corpus_to_native_xml)
	(write_corpus_to_native_xml_file): Likewise.
	* src/abg-reader.cc (read_translation_unit_from_input): Renamed
	read_input into this.  Support new 'path' attribute for
	'abi-instr' XML element.
	(read_corpus_from_input): New static function.
	(read_translation_unit_from_file)
	(read_translation_unit_from_buffer)
	(read_translation_unit_from_istream): Update wrt read_input ->
	read_translation_unit_from_input.
	(read_corpus_from_native_xml, read_corpus_from_native_xml)
	(read_corpus_from_native_xml_file): Define new entry points.
	* src/abg-writer.cc (write_translation_unit): Write 'path'
	attribute into the 'abi-instr' xml element.
	(write_corpus_to_native_xml, write_corpus_to_native_xml_file):
	Define new entry points.
	* tools/abg-tools-utils.h (file_type::{FILE_TYPE_XML_CORPUS,
	FILE_TYPE_ZIP_CORPUS}): New enumerators.
	* tools/abg-tools-utils.cc (guess_file_type): Support detection of
	the new xml file format containing a document root 'abi-corpus'
	root element.
	* tools/bidiff.cc (main): Support diffing xml corpus-es and zip
	corpus-es.
	* tools/bidw.cc (main): Recognize elf files before reading them.
	* tools/bilint.cc (main): Support reading xml/zip corpus-es too.
	* tests/data/test-read-write/test[0-23].xml: Update 'path'
	attribute.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-07 14:12:26 +01:00
Dodji Seketeli
fbb6b1bc73 Initial support for diffing ABI corpus files
* include/abg-comparison.h (string_function_ptr_map)
	(changed_function_ptr, string_changed_function_ptr_map)
	(corpus_diff_sptr): New convenience typedefs.
	(translation_unit_diff): Add comments.
	(class corpus_diff): New type.
	(compute_diff): New overload for corpus_diff.
	* include/abg-corpus.h (corpus::{functions, variables}): New
	typedefs.
	(corpus::{operator==, get_functions, get_variables}): New members.
	* include/abg-diff-utils.h (struct deep_ptr_eq_functor): New
	functor.
	* include/abg-ir.h (translation_unit::operator==): New member
	equality operator.
	* src/abg-comparison.cc (struct corpus_diff::priv): New private
	struct holding the private members of corpus_diff.
	(corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables,
	ensure_lookup_tables_populated}): Define new private member functions.
	(corpus_diff::{corpus_diff, first_corpus, second_corpus,
	function_changes, variable_changes, length, report}): New public members.
	(struct noop_deleter): New struct.
	(compute_diff): New implementation for corpus_diff.
	* src/abg-corpus.cc (struct corpus::priv): Renamed corpus::impl
	into this.  Add new fns, vars and is_symbol_table_built data
	members.
	(corpus::priv::build_symbol_table): New member function.
	(class symtab_build_visitor_type): New visitor type to build the
	symbol table.
	(struct func_comp, struct var_comp): New comparison functors.
	(corpus::priv::build_symbol_table): Define new member function.
	(corpus::{corpus, add, get_translation_units, operator==,
	get_functions, get_variables}): Define new members.
	* src/abg-ir.cc (translation_unit::operator==): Define new member
	equality operator.
	(operator==(translation_unit_sptr l, translation_unit_sptr r)):
	Define new equality operator.
	* tools/abg-tools-utils.h (enum file_type): New enum.
	(guess_file_type): Declare new function.
	* tools/abg-tools-utils.cc (guess_file_type): define new function.
	* tools/bidiff.cc (main): Guess the type of the files given in
	input and support elf files reading and diffing.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-23 14:05:19 +01:00
Dodji Seketeli
6258b5f824 Prepare serialization API for multiple backends
* include/abg-reader.h: New file with abigail::xml_reader APIs.
	* include/abg-writer.h: New file with abigail::xml_writer APIs.
	* include/Makefile.am: Add the new files above to the source
	distribution.
	* src/abg-reader.cc: Update top-file comments.
	(namespace xml_reader): Rename namespace
	reader into this.
	(read_to_translation_unit, read_corpus_from_archive): New static
	functions.
	(read_translation_unit_from_file)
	(read_translation_unit_from_file, read_corpus_from_file): New
	entry points.
	(struct array_deleter): New functor.
	(translation_unit::read): Remove this.
	* src/abg-writer.cc: Update top file comments.
	(namespace xml_writer): Rename namespace
	writer into this.
	(struct archive_write_ctxt): New internal type.
	(create_archive_write_context, write_translation_unit_to_archive)
	(write_translation_unit, write_corpus_to_archive): New low level
	static functions overloads.
	(write_corpus_to_archive, write_translation_unit): Public higher
	level overloads.
	(translation_unit::write): Remove.
	(dump): Update for new xml_writer namespace.
	* include/abg-ir.h (translation_unit::{read, write}): Remove these
	serialization methods.
	* include/abg-corpus.h (corpus_sptr): New convenience typedef.
	(corpus::{read, write}): Remove these methods.
	* src/abg-corpus.cc (corpus::{read, write})
	(corpus::impl::{serialized_tus, archive}): Remove these members.
	(corpus::impl::{get_archive, close_archive, write_tu_to_archive,
	read_to_translation_unit}): Remove these methods.
	* tests/test-bidiff.cc (main): Update for usage of the new
	xml_reader API.
	* tests/test-read-write.cc (main): Likewise. Update for the usage
	of the new xml_writer API, too.
	* tests/test-walker.cc (main): Update for the usage of the new
	xml_reader API.
	* tests/test-write-read-archive.cc (main): Likewise.  And for the
	xml_writer API, too.
	* tools/biar.cc (add_tus_to_archive, extract_tus_from_archive): Likewise.
	* tools/bidiff.cc (main): Likewise, for xml_reader APIs.
	* tools/bilint.cc (main): Likewise, for xml_writer APIs, too.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-04 20:26:38 +01:00
Dodji Seketeli
1cdc283b1d Add diff support for typedef_decl and type_decl
* include/abg-ir.h (operator<<(std::ostream&,
	decl_base::visibility)): Declare new streaming operator.
	* src/abg-ir.cc (operator<<(std::ostream&,
	decl_base::visibility)): Define it.
	(type_decl::{operator==, get_pretty_representation}): Likewise,
	define these new overloads.
	(decl_base::{operator==, get_pretty_representation}): New overloads.
	* include/abg-comparison.h (type_decl_diff type_decl_diff_sptr,
	typedef_diff, typedef_diff_sptr): Declare new classes and
	typedefs.
	* src/abg-comparison.cc (type_decl_diff::{type_decl_diff,
	first_type_decl, second_type_decl, length, report}): New methods
	definitions.
	(compute_diff): New function definition that takes pointers of
	type_decl.
	(typedef_diff::{typedef_diff, first_typedef_decl,
	second_typedef_decl, underlying_type_diff, length, report}): New
	methods.
	(compute_diff): New function definition that takes pointers of
	typedef_decl.
	(try_to_diff_types): New template function, factorized out of ...
	(compute_diff_for_types): ... this.  Add support diffing type_decl
	and typedef_decl.
	(pointer_diff::report): Fix indentation of emitted report.
	* tools/bidiff.cc (parse_command_line): Fix style.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:28:00 +01:00
Dodji Seketeli
894df5bf01 Progress on diffing pointers, references and classes
* include/abg-comparison.h (diff::{first_subject,second_subject): Changed
	first_scope/second_scope into these; so that this diff class now works on
	stuff that are not scope.  Changed the type of these to
	decl_base_sptr
	(diff::diff): Update for the change above.
	(diff::{length, report}): New virtual pure methods.
	(class pointer_diff, reference_diff): New classes declarations.
	(compute_diff): New overloads for the new classes above.  Make the
	existing overloads take shared_pointers instead of references.
	Also make them return shared pointers of the computed diff, rather
	than just populating diff references passed in parameter.
	(class class_diff): Renamed class class_decl_diff into this.
	(report_changes): Change these functions into member functions.
	* src/abg-comparison.cc (compute_diff_for_types): New static
	function.
	(pointer_diff::pointer_diff, pointer_diff::first_pointer)
	(pointer_diff::second_pointer, pointer_diff::length)
	(pointer_diff::underlying_type_diff)
	(pointer_diff::underlying_type_diff, pointer_diff::report)
	(pointer_diff::report, compute_diff)
	(reference_diff::reference_diff, reference_diff::first_reference)
	(reference_diff::second_reference)
	(reference_diff::underlying_type_diff)
	(reference_diff::underlying_type_diff, reference_diff::length)
	(reference_diff::report, compute_diff): New functions.
	(class_diff::class_diff, class_diff::length)
	(class_diff::first_class_decl, class_diff::second_class_decl)
	(class_diff::base_changes, class_diff::base_changes)
	(class_diff::member_types_changes)
	(class_diff::member_types_changes)
	(class_diff::data_members_changes)
	(class_diff::data_members_changes, class_diff::member_fns_changes)
	(class_diff::member_fns_changes)
	(class_diff::member_fn_tmpls_changes)
	(class_diff::member_class_tmpls_changes)
	Update wrt class_decl_diff -> class_diff renaming.
	(class_diff::report): Make the report function be a member
	function.  Add an indentation parameter. Add support for member
	types and data members.
	(compute_diff): New overload for class_decl_sptr.
	(scope_diff::first_scope, scope_diff::second_scope)
	(scope_diff::length, scope_diff::report): New member functions.
	(scope_diff::{deleted_member_at, inserted_member_at}): Update wrt
	first_scope -> first_subject change.
	(compute_diff): New overload for scope_decl_sptr.
	(translation_unit_diff::report): Change the report function into
	this member function.
	(compute_diff): Change the overload for translation_unit to take a
	translation_unit_sptr rather than a reference.
	* tools/bidiff.cc (main): Update this wrt the change of the
	signature of compute_diff.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:24:44 +01:00
Dodji Seketeli
749611d2e8 Initial implementation of tu diffing & bidiff cmd line program
* include/abg-comparison.h (class translation_unit_diff): New type.
	(compute_diff): Make this take class_decl&, rather than
	class_decl_sptr.  Add new overloads for scope_decl& and
	translation_unit&.
	(report_changes): New overload for scope_diff& and
	translation_unit&.
	* src/abg-comparison.cc (struct class_decl_diff::priv): New type.
	(class class_decl_diff): Add comments to methods.
	(class translation_unit_diff): Implement methods.
	(compute_diff, report_changes): Implement the new overloads.
	(scope_diff::ensure_lookup_tables_populated): Fix a thinko here.
	* src/abg-ir.cc (is_var_decl): Add new predicate.
	* tools/abg-tools-utils.h (file_exists, is_regular_file)
	(check_file): Declare new functions.
	* tools/abg-tools-utils.cc (get_stat, file_exists, check_file)
	(is_regular_file): Define new functions.
	(is_dir): Use the new get_stat.
	* tools/bidiff.cc: New file.
	* tools/Makefile.am: Add tools/bidiff.cc to the build system; make it
	produce the bidiff tool.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:24:01 +01:00