Commit Graph

601 Commits

Author SHA1 Message Date
Dodji Seketeli
b34f513889 Adjust copyright years
* src/abg-corpus.cc: Adjust copyright years.
	* src/abg-libzip-utils.cc: Likewise.
	* src/abg-writer.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-01 15:15:47 +02:00
Dodji Seketeli
f1e79c86fe Factorize basic redundancy detection in diff report
* src/abg-comparison.cc
	(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER)
	(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER{2,3}): New
	macros.
	({pointer_diff, array_diff, reference_diff, qualified_type_diff,
	class_diff, typedef_diff}::report): Use the new macros above.
	* tests/data/test-bidiff/test-qual-type0-report.txt: Adjust
	because type pretty representation are now always quoted.
	* tests/data/test-bidiff/test-struct1-report.txt: Adjust likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-01 15:04:37 +02:00
Dodji Seketeli
e6e7680113 Display package configuration at the end of configure
* configure.ac: Display the configure of the package at the end of
	the configure script.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-31 11:28:42 +02:00
Dodji Seketeli
36ed6e0583 Make zip archive support optional
* configure.ac: Support a new --enable-zip-archive option.  By
	default its value is set to the 'auto', meaning that if libzip is
	installed, that turns the option on -- just like if
	--enable-zip-archive was called with the value 'yes'; if libzip is
	not installed, that turns the option off -- just like if
	--enable-zip-archive was called with the value 'no'.  If libzip is
	detected, the pre-processor macro HAVE_LIBZIP is set to 1.  If
	--enable-zip-archive is turned on, the pre-processor macro
	WITH_ZIP_ARCHIVE is set to 1.
	* config.h.in (HAVE_LIBZIP, WITH_ZIP): New define.
	* src/abg-corpus.cc: Include config.h.  Guard the inclusion of
	abg-libzip-utils.h with the WITH_ZIP_ARCHIVE macro.  Likewise for
	the use of declarations coming from abg-libzip-utils.h.
	* src/abg-libzip-utils.cc: Include config.h.  Guard the file's
	content with the WITH_ZIP_ARCHIVE macro.
	* src/abg-reader.cc: Include config.h.  Guard the inclusion of
	abg-libzip-utils.h with the WITH_ZIP_ARCHIVE.  Likewise for the
	use of declarations coming from abg-libzip-utils.h.
	* src/abg-writer.cc: Likewise.
	* tests/Makefile.am: Build runtestwritereadarchive and runtestdot
	only if zip archives are supported.
	* tools/Makefile.am: The biar program is built only if
	zip archives are supported.
	* tools/bidiff.cc: Handle zip archives only if the
	WITH_ZIP_ARCHIVE macros is defined.
	* tools/bilint.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-31 11:28:42 +02:00
Dodji Seketeli
89564d516a Tell bidiff --help, wrong options and missing argument apart
* tools/bidiff.cc (options::{display_usage,missing_operand}): New
	data members.
	(options::options): Initialize them.
	(parse_command_line):  Flag missing operands.  Return false only
	when an option could not be parsed.  Flag when the user wants us
	to display help.
	(main): Tell --help, wrong options and missing argument apart and
	give an appropriate message on stderr.  The help string goes to
	stdout though.  Just like what GNU diff does.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-29 10:27:43 +02:00
Dodji Seketeli
fbbc89bad8 In bidiff, don't emit a report when the binaries have the same ABI
* tools/bidiff.cc (main): For differences of zero length, do not
	emit any report.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-29 10:27:43 +02:00
Dodji Seketeli
926ea2811e Take variables in account in corpus changes detection
* src/abg-comparison.cc (corpus_diff::length): Take changes about
	variables into account.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-29 10:27:43 +02:00
Dodji Seketeli
bc7694e14c During redundancy marking start with the current node as non redundant
* src/abg-comparison.cc (ENSURE_DIFF_NODE_TRAVERSED_ONCE):  If the
	diff node is being traversed for the first time, mark it as being
	in the NOT_REDUNDANT_CATEGORY.  I don't know why I was doing this
	only for classes and basic types.  Update comments.
	* tests/data/test-diff-filter/test16-report.txt: New test input.
	* tests/data/test-diff-filter/test16-v0.cc: Source code of new
	test input.
	* tests/data/test-diff-filter/test16-v0.o: New test input.
	* tests/data/test-diff-filter/test16-v1.cc: Source code of new
	test input.
	* tests/data/test-diff-filter/test16-v1.o: New test input.
	* tests/data/test-diff-filter/test17-0-report.txt: Likewise.
	* tests/data/test-diff-filter/test17-1-report.txt: Likewise.
	* tests/data/test-diff-filter/test17-v0.cc: Source code of new
	test input.
	* tests/data/test-diff-filter/test17-v0.o: Likewise.
	* tests/data/test-diff-filter/test17-v1.cc: Source code of new
	test input.
	* tests/data/test-diff-filter/test17-v1.o: Likewise.
	* tests/Makefile.am: Add the new files to the source distribution.
	* tests/test-diff-filter.cc (in_out_spec): Run this test harness
	over the new test inputs.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-28 16:27:38 +02:00
Dodji Seketeli
408d0f17bf Give anonymous struct the name "__anonymous_struct__"
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Set
	the name of anonymous structs to '__anonymous_struct_'.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-28 10:09:28 +02:00
Dodji Seketeli
378f47e283 Style fix in the comparison engine
* src/abg-comparison.cc (represent): Remove useless white space.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-28 10:01:57 +02:00
Dodji Seketeli
83ed508010 In bidiff, change --no-linkage-names to --no-linkage-name
* tools/bidiff.cc (display_usage): Change--no-linkage-names -o
	--no-linkage-name in the help string.
	(parse_command_line): Adjust the command line parsing accordingly.
	* tests/test-diff-filter.cc (in_out_specs): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-27 15:16:53 +02:00
Dodji Seketeli
b0ced3261e In diff reports, show symbol version info in linkage names
* src/abg-comparison.cc (represent, corpus_diff::report): show
	symbol version info in linkage name info.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-27 15:12:44 +02:00
Dodji Seketeli
97cabc1248 In diff reports, fns & members add/remove at the top, changes later.
* src/abg-comparison.cc (class_diff::report): Put virtual member
	function adding/removal/change first, then data members
	add/removal, then the rest (including data members changes).
	(corpus_diff::report): Put function adding/removal first, then
	function changes.  Likewise for variables.
	* tests/data/test-bidiff/test-struct0-report.txt: Adjust.
	* tests/data/test-bidiff/test-struct1-report.txt: Adjust.
	* tests/data/test-diff-dwarf/test0-report.txt: Adjust.
	* tests/data/test-diff-dwarf/test1-report.txt: Adjust.
	* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
	* tests/data/test-diff-dwarf/test8-report.txt: Adjust.
	* tests/data/test-diff-dwarf/test9-report.txt: Adjust.
	* tests/data/test-diff-filter/test0-report.txt: Adjust.
	* tests/data/test-diff-filter/test01-report.txt: Adjust.
	* tests/data/test-diff-filter/test1-report.txt: Adjust.
	* tests/data/test-diff-filter/test13-report.txt: Adjust.
	* tests/data/test-diff-filter/test2-report.txt: Adjust.
	* tests/data/test-diff-filter/test3-report.txt: Adjust.
	* tests/data/test-diff-filter/test9-report.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-27 14:53:34 +02:00
Dodji Seketeli
06f9ed88f5 Consider symbol versions' public-ness during comparison
* src/abg-ir.cc (elf_symbol::operator==): Rather than comparing
	bindings, compare public-ness here.  That is, if two symbol
	versions' differ because one is GLOBAL and the other one is WEAK,
	they should still be considered equal, from an ABI standpoint.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-27 11:53:16 +02:00
Dodji Seketeli
495a1dba55 Lookup proper names of symbol during determination of deleted/added decls
* src/abg-comparison.cc
	({class,corpus}_diff::ensure_lookup_tables_populated):  Now that in the
	intermediate maps we store symbol *ids* rather than symbol names,
	make sure to really refer to symbol names for symbol lookups,
	rather than (wrongly) referring to symbol ids.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-27 11:37:50 +02:00
Dodji Seketeli
e5490e206b Cleanup bidiff help string some more
* tools/bidiff.cc (display_usage): Add help strings for --harmless
	and --no-harmful.
	(main): Emit the help string to stdout, not stderr.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-26 16:29:53 +02:00
Dodji Seketeli
a5350a23d6 bidiff --no-harmless is no more
* tools/bidiff.cc (display_usage): Remove the help string for the
	--no-harmless option that doesn't exist anymore, as it's on by
	default.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-26 15:51:44 +02:00
Dodji Seketeli
30b7fb8e5a During comparison use symbol name + version as decl ID
* include/abg-ir.h ({var,function}_decl::get_id): New member
	function declarations.
	* src/abg-ir.cc ({var,function}_decl::get_id): New member function
	definitions.
	* src/abg-comparison.cc
	(corpus_diff::priv::ensure_lookup_tables_populated): Use the
	::get_id() function to get an identifier for the function or
	variable.
	* src/abg-corpus.cc (symtab_build_visitor_type::build_id): Use the
	get_id of the function/variable.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-26 14:37:14 +02:00
Dodji Seketeli
73ffa4f562 Fix access to alternate die -> decl map
* src/abg-dwarf-reader.cc (read_context::alternate_die_decl_map):
	Return the real alternate die decl map, rather than what we was
	doing previously b/c of a stupid copy/paste.  Oh well.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-26 14:28:42 +02:00
Dodji Seketeli
b13345fd86 Take symbol versions in account when computing added/removed decls
* include/abg-corpus.h
	(corpus::lookup_{function,variable}_symbol): Add an overload
	declaration that takes the version of the symbol to lookup.
	* src/abg-comparison.cc
	(corpus_diff::priv::ensure_lookup_tables_populated): So when looking
	up the corpora for symbols, take their versions in account.
	* src/abg-corpus.cc (corpus::lookup_{function,variable}_symbol):
	Add an overload definition that takes the version of the symbol to
	lookup.
	(symtab_build_visitor_type::build_id): New
	member functions.
	(corpus::priv::build_public_decl_table): Use the new member
	functions above.
	* src/abg-ir.cc (elf_symbol::version::operator==): Do not take the
	is_default flag in account when comparing two symbol versions.
	* libtest12-v{0,1}.so: New test input files.
	* libtest12-v{0,1}.c: Source code for the test input files.
	* test12-version-script: Version script to build the files above.
	* test12-report.txt: Test input file.
	* tests/Makefile.am: Add the new test input files above to the
	source distribution.
	* tests/test-diff-dwarf.cc (in_out_specs[]): Add an entry to this
	table for the new test input files.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-25 23:16:50 +02:00
Dodji Seketeli
5c493339c6 Misc style cleanups
* include/abg-corpus.h (corpus::lookup_function_symbol)
	(corpus::lookup_variable_symbol): Add the name of the function
	parameter in the declaration.
	* include/abg-ir.h (elf_symbol::version::version): Properly indent
	this constructor declaration.
	* src/abg-corpus.cc
	(symtab_build_visitor_type::symtab_build_visitor_type): Properly
	indent constructor parameters.
	* src/abg-ir.cc (function_decl::operator==): Fix typo in
	comments.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-25 23:04:53 +02:00
Dodji Seketeli
e6b39a7813 bidiff --harmful is not supported anymore
* tools/bidiff.cc (display_usage): remove the '--harmful' line
	from the help string as this option is now activated by default.
	It's --harmless that exists now.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-25 10:45:40 +02:00
Dodji Seketeli
b6d7fcc515 A builtin type name change is not harmless - fix that
* include/abg-comp-filter.h (has_harmless_name_change): New
	function declaration.
	* include/abg-comparison.h
	(diff_category::DECL_NAME_CHANGE_CATEGORY): Renamed this into
	HARMLESS_DECL_NAME_CHANGE_CATEGORY.
	(diff_category::EVERYTHING_CATEGORY): Update.
	* include/abg-fwd.h (is_enum): New function declaration.
	(is_var_decl): Return the shared_ptr<var_decl> rather than a bool.
	(is_data_member): New overload that takes a shared_ptr<decl_base>.
	* src/abg-comp-filter.cc (decl_name_changed): Consider the
	qualified name here.
	(has_harmless_name_change): Define new function declaration.
	(harmless_filter::visit): Use the new has_harmless_name_change
	function.
	* src/abg-comparison.cc (represent)
	(report_name_size_and_alignment_changes, enum_diff::report)
	(typedef_diff::report, is_data_member): Use the new
	filtering::has_harmless_name_change function to simplify logic of
	emitting the name change related diff
	* tools/bidiff.cc (set_diff_context_from_opts): Adjust
	DECL_NAME_CHANGE_CATEGORY -> HARMLESS_DECL_NAME_CHANGE_CATEGORY.
	* src/abg-ir.cc (is_data_member, is_enum): New function definitions.
	(is_var_decl): Return the var_decl_sptr rather than just a bool.
	* tests/data/test-diff-filter/test13-report.txt: Adjust.
	* tests/data/test-diff-filter/test6-report.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-22 17:19:27 +02:00
Ondrej Oprala
055a789abe Support C and C++ array type.
* include/abg-comparison.h (array_diff): Declare new class.
	(array_diff_sptr): Shared pointer to type array_diff.
	(compute_diff): Overload the function to take type
	array_diff_sptr as the first two arguments.
	* include/abg-fwd.h (array_type_def): Declare new class.
	(subrange_type): Likewise.
	(is_array_def): Declare new function.
	* include/abg-ir.h (array_type_def_sptr): Shared pointer
	to type array_type_def.
	(array_type_def): Declare new class.
	(ir_node_visitor::visit): Declare a new virtual function
	taking a pointer to type array_type_def as an argument.
	* src/abg-comparison.cc (compute_diff_for_types): Add
	try_to_diff for two instances of type array_type_def.
	(array_diff::priv): declare struct for holding private members
	of type array_diff.
	(array_diff::array_diff): Define constructor.
	(array_diff::{first,second}_array):Define new
	member functions.
	(array_diff::element_type_diff): Likewise.
	(array_diff::{length,report,traverse}): Likewise.
	(compute_diff): Define function overloaded in
	include/abg-comparison.h.
	* src/abg-dwarf-reader.cc (build_array_type): Define new
	function. Handle DW_TAG_array_type and DW_TAG_subrange type.
	(build_ir_node_from_die): Amend case DW_TAG_array_type with
	a call to build_array_type.
	* src/abg-hash.cc (array_type_def::hash): Declare new struct.
	(type_base::dynamic_hash::operator()): Attempt to dynamic_cast
	the argument to type array_type_def as well.
	(array_type_def::hash): Declare new struct.
	* src/abg-ir.cc (array_type_def::array_type_def): Define
	constructors.
	(array_type_def::priv): declare struct for holding private members
	of type array_type_def.
	(array_type_def::operator==(const decl_base&):
	Define new operator.
	(array_type_def::operator==(const type_base&):
	Likewise.
	(array_type_def::append_subrange{,s}): Define
	new functions.
	(array_type_def::{set,get}_size_in_bits): Likewise.
	(array_type_def::get_dimension_count): Likewise.
	(array_type_def::get_qualified_name): Likewise.
	(array_type_def::get_pretty_representation): Likewise.
	(array_type_def::get_subrange_representation): Likewise.
	(array_type_def::traverse): Likewise.
	(array_type_def::get_{element_type,location,subranges}): Likewise.
	(array_type_def::is_infinite): Likewise.
	(array_type_def::~array_type_def): Define destructor.
	(ir_node_visitor::visit): Define function, taking
	pointer to array_type_def as an argument.
	* src/abg-reader.cc (map_id_and_node): Check if node
	is an array.
	(is_array_def): Check if object is an array.
	(handle_element_node): Handle array_type_def as well.
	(build_subrange_type): Define new function.
	(build_array_type_def): Likewise.
	(build_type): Build type array_type_def as well.
	(build_type_composition): Likewise.
	(handle_array_type_def): Define new function.
	* src/abg-writer.cc: (write_decl): Output arrays
	as well.
	(write_member_type): Likewise.
	(write_type_composition): Likewise.
	(write_array_type_def): Define new function.
	* tests/data/test-diff-dwarf/test{10,11}-v{0,1}.{cc,o}: New test source
	files
	* tests/data/test-diff-dwarf/test{10,11}-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test10-report.txt: New test input.
	* tests/data/test-read-dwarf/test7.cc: New test source
	file.
	* tests/data/test-read-dwarf/test7.so: New input binary
	to read.
	* tests/data/test-read-dwarf/test7.so.abi: New reference
	test to compare against.
	* tests/data/test-read-write/test25.xml: New test source
	file.
	* tests/test-diff-dwarf.cc: Adjust to launch the new test.
	* tests/test-read-dwarf.cc: Likewise.
	* tests/test-read-write.cc: Likewise.
	* test/Makefile.am: Add the new test inputs to the source
	distribution.

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-22 13:07:41 +02:00
Dodji Seketeli
edb50beeed Ignore variables which type couldn't be read from DWARF
* src/abg-dwarf-reader.cc (build_var_decl): Drop the var on the
	floor if its type couldn't be built.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-19 15:13:14 +02:00
Dodji Seketeli
d08e5181f2 Support TLS variables
* src/abg-ir.cc (elf_symbol::is_variable): Accept TLS objects as
	variables too.
	* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr)
	(die_location_address): Add an output parameter to say if the
	resulting constant value is a tls address or not.
	(lookup_public_variable_symbol_from_elf): Use the proper
	elf_symbol::is_variable() method, rather than trying to figure out
	the low levels of what a variable is here.  Also, cleanup the
	condition.
	(read_context::load_symbol_maps): Consider symbols of type
	STT_TLS, when loading symbols for variables.  Also, to avoir
	symbols that are for versions, filter out symbols of type
	STT_OBJECT and with a SHN_ABS section index.
	(read_context::get_variable_address): If the address is for a tls
	variable, do no try to adjust the address to arrange for things
	like prelink.  As that doesn't seem to affect TLS variables.
	(dwarf_expr_eval_context::set_tls_addr): New data member.
	(dwarf_expr_eval_context::dwarf_expr_eval_context): Initialize it.
	(dwarf_expr_eval_context::set_tls_address): New accessors.
	(dwarf_expr_eval_context::op_manipulates_stack): Handle
	DW_OP_GNU_push_tls_address, a bit like DW_OP_form_tls_address, but
	then, its result is a constant.  Set the
	dwarf_expr_eval_context::set_tls_addr flag when these two OPs are
	run.
	(die_member_offset): Adjust to the new signature of
	eval_last_constant_dwarf_sub_expr.
	* tests/data/test-diff-dwarf/libtest9-v0.so: New test input.
	* tests/data/test-diff-dwarf/libtest9-v1.so: Likewise.
	* tests/data/test-diff-dwarf/test9-report.txt: Likewise
	* tests/data/test-diff-dwarf/test9-v0.cc: Source code for the
	first input.
	* tests/data/test-diff-dwarf/test9-v1.cc: Source code for the
	second input.
	* tests/test-diff-dwarf.cc: Run this harness on the two new inputs
	above.
	* tests/Makefile.am: Add the new inputs to the source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-19 13:50:23 +02:00
Dodji Seketeli
d8ff78240a Update copyright for abg-dwarf-reader.cc
* src/abg-dwarf-reader.cc: Update copyright year.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-19 13:50:23 +02:00
Dodji Seketeli
1bd8dcf173 Make the link to the alt debug info file relative
* tests/data/test-alt-dwarf-file/test0-debug-dir/.build-id/16/7088580c513b439c9ed95fe6a8b29496495f26.debug:
	Make this link be relative.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-18 23:45:42 +02:00
Dodji Seketeli
da4f096bb9 White space fix
* tests/test-lookup-syms.cc: Remove useless white space.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-15 18:28:22 +02:00
Dodji Seketeli
7fa9c3ca04 Update copyright notice
* tests/test-lookup-syms.cc: Update year in copyright notice.
	* tools/bidw.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-15 18:27:34 +02:00
Dodji Seketeli
7b126c03a0 Support alternate debug info sections
ABGBZ#17193
	* include/abg-dwarf-reader.h (class read_context)
	(typedef read_context_sptr, create_read_context)
	(has_alt_debug_info): Declare these.
	(read_corpus_from_elf): Declare new overload.
	* src/abg-dwarf-reader.cc (find_alt_debug_info)
	(is_die_attribute_resolved_through_gnu_ref_alt)
	(build_primary_die_parent_relations_under)
	(build_alternate_die_parent_relations_under):
	Define new static functions.
	(read_context::{alt_dwarf_,
	alt_debug_info_path_, alternate_die_decl_map_,
	alternate_die_parent_map_}): New data members.
	(read_context::{alt_dwarf, alt_debug_info_path,
	alternate_die_decl_map, associate_die_to_decl_primary,
	associate_die_to_decl_alternate, associate_die_to_decl,
	lookup_decl_from_die_offset_primary,
	lookup_decl_from_die_offset_alternate,
	lookup_decl_from_die_offset, alternate_die_parent_map}): New
	member functions.
	(read_context::load_debug_info): Painfully Get a handle on the
	alternate debug info section too.  We shouldn't have to do all
	this work; we could use the new dwarf_getalt() function from
	libdw, but we cannot as we want to support supports that predate
	that api.  When a version of elfutils gets released with that api
	though, we should conditionally use that instead.
	(build_ir_node_from_die, get_parent_die, get_scope_for_die)
	(build_namespace_decl_and_add_to_ir)
	(build_class_type_and_add_to_ir, build_qualified_type)
	(build_pointer_type_def, build_reference_type, build_typedef_type)
	(build_var_decl, build_function_decl): Take a new parameter that
	tells if the input DIE is from alternate debug info.  Adjust their
	code accordingly.
	(die_die_attribute): Take a new output parameter that tells if the
	resolved DIE is from alternate debug info.  Also take a new
	parameter that tells if the input DIE is from alternate debug info
	sections.
	(build_die_parent_relations_under): Take the DIE -> parent map to
	act upon.  Also, add a new overload that takes a flag saying if
	the DIE is from alternate debug info or not, and act upon that.
	(build_die_parent_maps): Renamed build_die_parent_map into this
	and make it build DIE -> parent DIE relationship for the alternate
	debug info file as well.
	(find_last_import_unit_point_before_die, ): Adjust to use the
	information about if the relevant DIEs are in alternate debug info
	or not.
	(build_translation_unit_and_add_to_ir): Clear the alternate DIE ->
	decl map, that is per TU just as the primary DIE -> decl map.
	Adjust to use the information about if the relevant DIEs are in
	alternate debug info or not.
	(read_debug_info_into_corpus): Build the two DIE -> DIE parent
	maps (one for the primary debug info and one for the alternate
	debug info).
	(create_read_context, has_alt_debug_info): Define new public entry
	points.
	(read_corpus_from_elf): New entry point overload that takes a
	read_context.
	* tools/bidw.cc (options::{check_alt_debug_info_path,
	show_base_name_alt_debug_info_path}): New data members.
	(display_usage): Update for the two new options
	--check-alternate-debug-info and
	check-alternate-debug-info-base-name.
	(parse_command_line): Parse the two options above.
	(main) Handle the two new options above.
	* tests/Makefile.am: Build the new runtestaltdwarf test.  Add the
	new data/test-alt-dwarf-file/* files to the build system.
	* tests/test-alt-dwarf-file.cc: New test driver.
	* tests/data/test-alt-dwarf-file/test0-common.cc: New test input
	files.
	* tests/data/test-alt-dwarf-file/libtest0-common.so: Likewise.
	* tests/data/test-alt-dwarf-file/test0.cc: Likewise.
	* tests/data/test-alt-dwarf-file/libtest0.so: Likewise.
	* tests/data/test-alt-dwarf-file/test0.h: Likewise.
	* tests/data/test-alt-dwarf-file/test0-common-dwz.debug: Likewise.
	* tests/data/test-alt-dwarf-file/test0-debug-dir/.build-id/16/7088580c513b439c9ed95fe6a8b29496495f26.debug:
	Likewise.
	* tests/data/test-alt-dwarf-file/test0-debug-dir/test0-common-dwz.debug:
	Likewise.
	* tests/data/test-read-dwarf/test1.abi: Adjust. bidw doesn't emit
	an abstract constructor/destructor anymore. It emits just the
	functions matching the cdtor symbols found in the binary.
	* tests/data/test-read-dwarf/test2.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-15 18:27:04 +02:00
Dodji Seketeli
9742eb07ba Better handle corner cases of void* DWARF parsing
* src/abg-dwarf-reader.cc (build_pointer_type_def):  Better
	support cases where the underlying type of the pointer is not
	know.  In that case, the pointer should not be created.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-07-26 10:07:36 +02:00
Dodji Seketeli
2b9bd93b42 Support finding symbols with bias wrt DWARF references
* src/abg-dwarf-reader.cc (get_binary_load_address): New function
	definition.
	(read_context::elf_handle): Add comment.
	(read_context::{dwarf_elf_handle, dwarf_is_splitted,
	maybe_adjust_address_for_exec_or_dyn}): New method definitions.
	(maybe_adjust_fn_sym_address)
	(maybe_adjust_var_sym_address): Move these so they become members
	of read_context.  Also, For shared libraries and executable (that
	could have been e.g prelinked), consider their loading address
	when trying to find which symbol resides at a given place in
	memory.
	(read_context::{get_function_address, get_variable_address):
	Adjust.
	(build_translation_unit_and_add_to_ir): Fix comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-07-25 13:02:37 +02:00
Dodji Seketeli
153568c903 Reset the scope of void_type_decl for each new translation unit
* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir):
	Clear the void_type_decl on new translation units.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-07-20 10:29:55 +02:00
Dodji Seketeli
bb521c98c9 Update INSTALL file
* INSTALL: Adjust the copyright year information because autotools
	2.69 did.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-07-18 19:01:43 +02:00
Dodji Seketeli
3b6d0ec0a9 Correctly write the name of a const reference type
* src/abg-dwarf-reader.cc (maybe_strip_qualification): Define new
	function.
	(build_ir_node_from_die): Use the maybe_strip_qualification when
	building a qualified type.
	* src/abg-ir.cc (qualified_type_def::build_name): Fix the
	representation of the name of a reference that is const.
	* tests/data/test-read-dwarf/test1.abi: Adjust.
	* tests/data/test-diff-dwarf/test0-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test1-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test6-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test7-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test8-report.txt: Likewise.
	* tests/data/test-diff-filter/test0-report.txt: Likewise.
	* tests/data/test-diff-filter/test01-report.txt: Likewise.
	* tests/data/test-diff-filter/test2-report.txt: Likewise.
	* tests/data/test-diff-filter/test3-report.txt: Likewise.
	* tests/data/test-diff-filter/test9-report.txt: Likewise.
	* tests/data/test-diff-filter/test10-report.txt: Likewise.
	* tests/data/test-diff-filter/test13-report.txt: Likewise.
	* tests/data/test-diff-filter/test14-0-report.txt: Likewise.
	* tests/data/test-diff-filter/test14-1-report.txt: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-07-18 18:55:23 +02:00
Sinny Kumari
fe6b9fb61b Consider symbols with STB_GNU_UNIQUE binding as public
* src/abg-ir.cc (is_public): Change in function to consider
	symbols with STB_GNU_UNIQUE binding as public
	* tests/data/test-read-dwarf/test6.cc: Test file to generate
	STB_GNU_UNIQUE binding symbols
	* tests/data/test-read-dwarf/test6.so: Test shared library having
	STB_GNU_UNIQUE binding symbols
	* tests/data/test-read-dwarf/test6.so.abi: XML file containing
	dwarf information from test6.so
	* tests/test-read-dwarf.cc (in_out_specs): Add the new test above
	* tests/Makefile.am: Add tests/data/test-read-dwarf/test6.cc,
	tests/data/test-read-dwarf/test6.so and
	tests/data/test-read-dwarf/test6.so.abi to the distribution

Signed-off-by: Sinny Kumari <skumari@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-07-08 14:18:36 +02:00
Dodji Seketeli
a11912d964 Add comment to test-read-write.cc
* tests/test-read-write.cc: Update copyright notice and add a
	meaningful comment for the file.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-07-01 09:42:25 +02:00
Dodji Seketeli
01cd814bbc Support reading void* type from DWARF
* include/abg-ir.h (type_decl::get_void_type_decl): Declare new
	static method.
	* src/abg-ir.cc (type_decl::get_void_type_decl): Define it.
	* src/abg-dwarf-reader.cc (build_ir_node_for_void_type): Define
	new static function.
	(build_pointer_type_def): Support void* type nodes here.
	* tests/data/test-read-dwarf/test5.cc: Source code for new test
	input.
	* tests/data/test-read-dwarf/test5.o: New test input.
	* tests/data/test-read-dwarf/test5.o.abi: Likewise.
	* tests/Makefile.am: Add the above to the source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-06-23 17:31:26 +02:00
Dodji Seketeli
3e215cc737 Update a comment in abg-dwarf-reader.cc
* src/abg-dwarf-reader.cc (build_ir_node_from_die): Update a
	comment here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-06-23 17:22:05 +02:00
Mark Wielaard
453ed93d01 Handle C99 restrict qualifier and DWARFv3 DW_TAG_restrict_type.
* src/abg-dwarf-reader.cc (build_qualified_type): Handle
	DW_TAG_restrict_type by adding CV_RESTRICT.
	(build_ir_node_from_die): Call build_qualified_type for
	DW_TAG_restrict_type.
	* src/abg-reader.cc (build_qualified_type_decl): Handle
	"restrict" attribute by adding CV_RESTRICT.
	* src/abg-writer.cc (write_qualified_type_def): Output
	"restrict" attribute for CV_RESTRICT.
	* tests/data/test-read-dwarf/test4.c: New test file.
	* tests/data/test-read-dwarf/test4.so: Likewise.
	* tests/data/test-read-dwarf/test4.so.abi: Likewise.
	* tests/data/test-read-write/test24.xml: Likewise.
	* tests/test-read-dwarf.cc (in_out_specs): Add test4.
	* tests/test-read-write.cc (in_out_specs): Add test24.xml.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-06-23 15:55:37 +02:00
Dodji Seketeli
a8285b1f9c Add subdir-objects automake option where it is needed
* src/Makefile.am: Add the subdir-object automake option here.
	Do not specify absolute paths for the input files as Automake now
	takes care of that just fine.
	* tests/Makefile.am: Likewise.
	* tools/Makefile.am: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@seketeli.org>
2014-06-23 15:01:00 +02:00
Dodji Seketeli
e4ad1ea740 Remove autotools artifacts from the repository
* config.guess: Remove from revision control system.
	* config.sub: Likewise.
	* depcomp: Likewise.
	* m4/libtool.m4: Likewise.
	* missing: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-06-23 14:20:46 +02:00
Dodji Seketeli
591014bf40 Avoid reporting diff nodes that have already been reported
* include/abg-comp-filter.h (class harmful_filter): Update
	comment.
	(class redundant_filter): Declare new filter.
	* include/abg-comparison.h (enum
	diff_category::NOT_REDUNDANT_CATEGORY): New category.  Update the
	values of the other enumerators.
	(diff_context::{add_diff, diff_has_been_traversed}): New overloads.
	(diff_context::{categorizing_redundancy, show_redundant_changes}):
	Declare new methods.
	(diff_context::remove_from_category): Define new inline method.
	* src/abg-comparison.cc (noop_deleter::operator()): Constify the
	parameter.
	(CATEGORIZE_REDUNDANCY_FROM_CHILD_NODE)
	(UPDATE_REDUNDANCY_CATEGORIZATION_FROM_NODE_SUBTREE): New macros.
	(TRAVERSE_DIFF_NODE_AND_PROPAGATE_CATEGORY)
	(TRAVERSE_MEM_DIFF_NODE_AND_PROPAGATE_CATEGORY)
	(TRAVERSE_MEM_FN_DIFF_NODE_AND_PROPAGATE_CATEGORY): Use the new
	CATEGORIZE_REDUNDANCY_FROM_CHILD_NODE and
	UPDATE_REDUNDANCY_CATEGORIZATION_FROM_NODE_SUBTREE macros above.
	(ENSURE_DIFF_NODE_TRAVERSED_ONCE)
	(ENSURE_MEM_DIFF_NODE_TRAVERSED_ONCE): If the (type_decl or class)
	node hasn't been yet traversed, mark it as non-redundant.
	(diff_context::priv::categorizing_redundancy): New member.
	(diff_context::priv::priv): Initialize it.
	(diff_context::{add_diff, diff_has_been_traversed): Define new
	overloads.
	(diff_context::mark_diff_as_traversed): Intern a diff node that is
	marked as being traversed.
	(diff_context::{categorizing_redundancy, show_redundant_changes}):
	Define new methods.
	(diff::is_filtered_out): A redundant function or top-level
	variable is considered filtered-out.  Otherwise, the new
	NOT_REDUNDANT_CATEGORY doesn't play any role when comparing
	allowed categories with the set of categories a diff node belongs
	to.
	(corpus::priv::categorize_redundant_changed_sub_nodes): Define
	new member function.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats): Change
	this to first walk the changed functions and variables to apply
	filters, then categorize redundant changed functions, and then
	walk the changed functions and variables again to count
	filtered-out diff nodes.
	(filtering::redundant_filter::visit): Define new member function.
	* tools/bidiff.cc (options::show_redundant_changes): New data
	member.
	(options::options): Initialize it.
	(display_usage): Add help string for the --redundant command line
	option.
	(parse_command_line): Add support for the --redundant command line
	option.
	(set_diff_context_from_opts): Take the --redundant command line
	option in account.
	* tests/test-diff-filter.cc: Update this to add new test inputs.
	* tests/data/test-diff-filter/test14-0-report.txt: New test input.
	* tests/data/test-diff-filter/test14-1-report.txt: Likewise.
	* tests/data/test-diff-filter/test14-v0.cc: Likewise.
	* tests/data/test-diff-filter/test14-v0.o: Likewise.
	* tests/data/test-diff-filter/test14-v1.cc: Likewise.
	* tests/data/test-diff-filter/test14-v1.o: Likewise.
	* tests/data/test-diff-filter/test15-0-report.txt: Likewise.
	* tests/data/test-diff-filter/test15-1-report.txt: Likewise.
	* tests/data/test-diff-filter/test15-v0.cc: Likewise.
	* tests/data/test-diff-filter/test15-v0.o: Likewise.
	* tests/data/test-diff-filter/test15-v1.cc: Likewise.
	* tests/data/test-diff-filter/test15-v1.o: Likewise.
	* tests/Makefile.am: Add the above to the build system.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-06-23 13:43:42 +02:00
Dodji Seketeli
effab01a0e A name that couldn't be demangled remains the same
* src/abg-ir.cc (demangle_cplus_mangled_name): When the demangler
	fails to demangle a name, just return the input name as-is.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-06-23 13:43:33 +02:00
Dodji Seketeli
f3f2382396 Update copyright notice for a bunch of files
* include/abg-comp-filter.h: Update copyright notice.
	* include/abg-comparison.h: Likewise.
	* src/abg-comparison.cc: Likewise.
	* src/abg-ir.cc: Likewise.
	* tools/bidiff.cc: Likewise.
	* tests/test-diff-filter.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-06-23 13:43:07 +02:00
Sinny Kumari
64bd3adce5 Keep symbol's multiple aliases within single attribute separated by comma
* src/abg-writer.cc (write_elf_symbol_aliases): Changing function
	to keep multiple symbol aliases within one alias attribute
	* src/abg-reader.cc (build_elf_symbol_db): Changing function to read
	symbol's alias attribute and split if multiple alias exist with comma(,)
	asi a delimiter and add all aliases to main symbol
	* tests/data/test-read-dwarf/test3.c: Test file to generate multiple aliases
	* tests/data/test-read-dwarf/test3.so: Test shared library having multiple
	aliases of a symbol
	* tests/data/test-read-dwarf/test3.so.abi: XML file containing dwarf
	information from test3.so
	* tests/test-read-dwarf.cc (in_out_specs): Add the new test above
	* tests/Makefile.am: Add tests/data/test-read-dwarf/test3.c,
	tests/data/test-read-dwarf/test3.so and tests/data/test-read-dwarf/test3.so.abi
	to the distribution

Signed-off-by: Sinny Kumari <skumari@redhat.com>
2014-06-20 11:56:49 +02:00
Mark Wielaard
0608454a73 DW_TAG_mutable_type doesn't exist.
DW_TAG_mutable_type was a mistake in an early DWARFv3 draft and was removed
in the final version. http://dwarfstd.org/ShowIssue.php?issue=050223.1

	* src/abg-dwarf-reader.cc (is_type_tag): Remove DW_TAG_mutable_type.
	(build_ir_node_from_die): Likewise.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-06-18 21:34:37 +02:00
Dodji Seketeli
d1843bb3b3 Look at first parm type and artificial-ness to detect static-ness
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): To
	tell if a member function is static, look if the first parm is a
	pointer to the type of the enclosing class, and if it's
	artificial.  Don't bother trying to be smart by looking at the
	non-presence of DW_AT_object_pointer b/c that attribute wasn't
	emitted by GCC 4_4.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-06-05 15:13:32 +02:00
Dodji Seketeli
c4e7f9792d Harden debug info path management & better error reporting
* include/abg-dwarf-reader.h (enum status): New enum.
	(read_corpus_from_elf): Return an instance of status above, and
	return the corpus by parameter.
	* src/abg-dwarf-reader.cc (create_default_dwfl): Add a comment
	about elfutils wanting the Dwfl_Callbacks::debuginfo_path to be an
	absolute path.
	(read_corpus_from_elf): Return an instance of status above, and
	return the corpus by parameter.
	* tools/abg-tools-utils.h (make_path_absolute): Declare new function.
	* tools/abg-tools-utils.cc (make_path_absolute): New
	implementation.
	* tools/bidiff.cc (options::di_root_path[12]): Make these be
	shared pointers.
	(parse_command_line): ensure the debug info root paths are
	absolute.
	(main): Adjust.  Give meaningful errors when the debug info or
	symbol files couldn't be read.
	* tools/bidw.cc (options::di_root_path): Make this be a shared
	pointer.
	(parse_command_line): Ensure the debug info root path is absolute.
	(main): Adjust.  Give meaningful errors when the debug info or
	symbol files couldn't be read.
	* tools/bilint.cc (options::di_root_path): Make this be a shared
	pointer.
	(parse_command_line): Ensure the debug info root path is absolute.
	(main): Adjust.  Give meaningful errors when the debug info or
	symbol file couldn't be read.
	* tests/test-diff-dwarf.cc (main): Adjust.
	* tests/test-read-dwarf.cc (main): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-06-04 16:30:18 +02:00