Commit Graph

25 Commits

Author SHA1 Message Date
Dodji Seketeli
23b7fa9ac2 Add a new DECL_NAME_CHANGE_CATEGORY change category
* include/abg-comparison.h (enum
	diff_category::DECL_NAME_CHANGE_CATEGORY): New enumerator.
	* src/abg-comparison.cc (report_name_size_and_alignment_changes)
	({enum, typedef}_diff::report): Adjust to avoid emitting name
	change report if the DECL_NAME_CHANGE_CATEGORY category of change
	is currently disallowed.
	* abg-comp-filter.cc (decl_name_changed): New static function.
	(harmless_filter::visit): Detect that the decl name changed and
	put the current diff node (and its parents) into the
	DECL_NAME_CHANGE_CATEGORY category.
	* tools/bidiff.cc (set_diff_context_from_opts): Set the new
	DECL_NAME_CHANGE_CATEGORY category into the harmless_changes group
	of categories.
	* tests/data/test-diff-filter/test6-report.txt: New test input file.
	* tests/data/test-diff-filter/test6-v0.cc: Likewise.
	* tests/data/test-diff-filter/test6-v0.o: Likewise.
	* tests/data/test-diff-filter/test6-v1.cc: Likewise.
	* tests/data/test-diff-filter/test6-v1.o: Likewise.
	* tests/data/test-diff-filter/test7-report.txt: Likewise.
	* tests/data/test-diff-filter/test7-v0.cc: Likewise.
	* tests/data/test-diff-filter/test7-v0.o: Likewise.
	* tests/data/test-diff-filter/test7-v1.cc: Likewise.
	* tests/data/test-diff-filter/test7-v1.o: Likewise.
	* tests/test-diff-filter.cc: Take the new inputs above to run new tests.
	* tests/Makefile.am: Add the new files above to the distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-06 15:59:38 +02:00
Dodji Seketeli
64bbb5ccef Add a COMPATIBLE_TYPE_CHANGE_CATEGORY to bidiff --no-harmless
* include/abg-comparison.h
	(diff_category::COMPATIBLE_TYPE_CHANGE_CATEGORY): New enumerator.
	(operator|=(diff_category&, diff_category)): New declaration.
	* include/abg-fwd.h (is_typedef, strip_typedef)
	(types_are_compatible): New declarations.
	* include/abg-ir.h (operator==(const decl_base_sptr, const
	decl_base_sptr)): Added the consts here.
	(operator==(const type_base_sptr, const type_base_sptr)): New
	declaration.
	* src/abg-comp-filter.cc (is_compatible_change): New static
	function.
	(harmless_filter::visit): Detect compatible changes and add the
	sub-tree into the new COMPATIBLE_TYPE_CHANGE_CATEGORY if
	applicable. Cleanup the logic.
	* src/abg-comparison.cc (operator|=(diff_category&,
	diff_category)): Define new function.
	(operator==(const decl_base_sptr l, const decl_base_sptr r)): Add
	consts.
	(operator==(const type_base_sptr l, const type_base_sptr r)):
	Define new operator.
	(is_typedef, strip_typedef, types_are_compatible): New function
	definitions.
	* tests/data/test-diff-filter/test3-report.txt: New test report
	reference.
	* tests/data/test-diff-filter/test3-v0.cc: Source code for new
	test input.
	* tests/data/test-diff-filter/test3-v0.o: New test input.
	* tests/data/test-diff-filter/test3-v1.cc: Source code for new
	test input.
	* tests/data/test-diff-filter/test3-v1.o: New test input.
	* tests/test-diff-filter.cc: Adjust to consume the new tests
	inputs above.
	* tools/bidiff.cc: Add the new COMPATIBLE_TYPE_CHANGE_CATEGORY
	into the --harmless group.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-02 17:23:56 +02:00
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
35d83f61eb Initialize a variable
* tools/bilint.cc (main): Initialize the 'r' variable.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-11 13:59:01 +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
7d19840822 Add debugging facilities for core diffing issues
* include/abg-ir.h (fns_to_str): Declare new fn.
	* src/abg-ir.cc (get_next_string, fn_to_str, fns_to_str): New
	static functions.
	(fns_to_str): Define new fn.
	* tools/abg-tools-utils.cc (dump_functions_as_string)
	(dump_function_names, compare_functions): New functions.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-10 15:51:09 +01:00
Dodji Seketeli
2a078ca1af Fix bilint outputting for translation units & corpus
* tools/bilint.cc (main): Fix logic.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-20 12:16:31 +01:00
Dodji Seketeli
677a69f8e1 Fix bilint --noout, add --diff option
* tools/bilint.cc (options::options): Initialize ...
	(options::{diff, bidiff}): ... new members.
	(display_usage): Update the display usage string for --diff &
	--bidiff options.
	(parse_command_line): Support the --diff and --bidiff options.
	(main): Require the --diff option to actually diff the emitted
	output with input.  Make --noout really work for when reading
	from dwarf.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-17 15:44:25 +01:00
Dodji Seketeli
d3e1c98f83 Fix reading/writing native xml corpus files
* src/abg-reader.cc (read_context::clear_type_map): New member
	function.
	(read_translation_unit_from_input): Read up to the next element
	node if we are not on an element node already.  Clear the type
	map.  Realize that we might be on the next 'abi-instr' node upon
	completion.
	(read_corpus_from_input): Read up to the next element node if we
	are not on an element node already.  It must be an "abi-corpus"
	node.  THen Advance to the next 'abi-instr' element node before
	handing it to read_translation_unit_from_input.
	* src/abg-writer.cc (write_context::clear_type_id_map): New member
	function.
	(write_translation_unit): Call it.
	* tools/abg-tools-utils.cc (guess_file_type): Read enough bytes to
	detect abi-corpus files magic bytes.
	* tools/bilint.cc (main): Do not write the corpus file to the
	output stream if --noout has been provided.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 17:36:20 +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
7350cfd893 Make bilint read input from stdin
* include/abg-libxml-utils.h (new_reader_from_istream): Declare
	new public entry point.
	* src/abg-libxml-utils.cc (xml_istream_input_read)
	(xml_istream_input_close): New static functions.
	(new_reader_from_istream): Define new public input function.
	* include/abg-reader.h (read_translation_unit_from_istream):
	Declare new entry points.
	* src/abg-reader.cc (read_translation_unit_from_istream): Define
	new entry points.
	* tools/bilint.cc (options::{read_from_stdin, noout}): New
	members.
	(display_usage): Document --stdin and --noout.
	(parse_command_line): Adjust to consider that no option on the
	command line means reading from stdin, just like --stdin.  Support
	the --noout option as well.
	(main): Support Read the abi instr from stdin; in that case, what
	was read is just serialized back to stdout, unless --noout was
	supplied.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-11 15:20:42 +01:00
Dodji Seketeli
bd1af4cd52 Initial support of reading an ABI Corpus from DWARF
* configure.ac: Check the presence of libdw.so and
	elfutils/libdwfl.h headers from elfutils and define the necessary
	linking flags.
	* include/abg-dwarf-reader.h: New header file
	* include/Makefile.am: Add the new header file to the source
	distribution.
	* src/abg-dwarf-reader.cc:: New file.
	* src/Makefile.am: Add the new file to the source distribution.
	* include/abg-fwd.h (dump): Add declarations for several overloads
	to allow dumping to a given output stream.
	* include/abg-ir.h (class translation_unit): Use a pimpl idiom for
	this now.
	(translation_unit::canonicalize_type): Declare new method.
	* src/abg-ir.cc (struct translation_unit::priv): New private type
	for the pimpl idiom for translation_unit.
	(translation_unit::{translation_unit, get_global_scope, get_path,
	set_path, get_loc_mgr}): Adjust for pimpl idiom.
	(translation_unit::canonicalize_type): Define this new method and
	one overload.
	* src/abg-writer.cc (dump): Define several overloads to dump IR
	nodes to given output streams.
	* tools/bidw.cc: New file for the new bidw tool.
	* tools/Makefile.am: Define rules to build the new bidw tools.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-07 08:07:54 +01:00
Dodji Seketeli
96fba7d95f Pass a string by reference rather than by value
* tools/bilint.cc (display_usage): Pass program name by reference.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-07 07:26:06 +01:00
Dodji Seketeli
98681a9327 Misc style fixes
* src/abg-ir.cc (location_manager::location_manager)
	(translation_unit::{is_empty, traverse, ~translation_unit): Remove
	useless vertical white spaces.
	* tools/bilint.cc (parse_command_line): Fix indentation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-07 07:22:57 +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
80b753e85d Add bilint tool to validate bi files somewhat.
* tools/bilint.cc: New file.
	* tools/Makefile.am: Build and install the new file above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:28:04 +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
Dodji Seketeli
0d738e2b95 Initial version of an archive manipulation program: biar
* tests/test-utils.h (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): Move these directories manipulation
	utilities from here to ...
	* tools/abg-tools-utils.h (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): ... here in this new file.
	(dir_name, base_name): Declare these new functions.
	* tests/test-utils.cc (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): Likewise, move these to ...
	* tools/abg-tools-utils.cc (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): ... here in this new file.
	(dir_name, base_name): Define these.
	* tools/Makefile.am: New file.  Create a new libtoolsutils.la
	static library with stuff from tools/abg-tools-utils.cc in it.
	Also create a new 'biar' program with the stuff from the new
	tools/biar.cc in it.
	* tools/biar.cc: New file.  Contains the code for the new "biar"
	archive manipulation command line utility.
	* tests/test-read-write.cc (main): Adjust for the change about
	ensure_parent_dir_created above.
	* tests/test-write-read-archive.cc (main): Likewise.
	* Makefile.am (SUBDIRS): Add the new tools/ sub-directory to the
	build system.
	* configure.ac (AC_CONFIG_FILES): Generate tools/Makefile.
	* tests/Makefile.am: Make libtestutils.la link with the new
	libtoolsutils.la.  Make sure to express the dependencies between
	libtestutils.la and the binaries that depend on it.  Otherwise
	parallel builds can go awry.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-29 17:08:47 +02:00