Commit Graph

9 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Dodji Seketeli
cf80e9d378 Support debug info files being outside the expected system directories
* include/abg-dwarf-reader.h (read_corpus_from_elf): Take a
	debug_info_root_path parameter.
	src/abg-dwarf-reader.cc (create_default_dwfl): Take a
	debug_info_root_path.  Use that to initialize the Dwfl_Callbacks
	structure used by dwfl_begin.
	(create_default_dwfl_sptr, read_corpus_from_elf): Likewise, Take a
	debug_info_root_path parameter.
	* tests/test-diff-dwarf.cc (main): Adjust.
	* tests/test-read-dwarf.cc (main): Likewise.
	* tools/bidiff.cc (options::dir_root_path[12]): New member.
	(options::options): Initialize it.
	(display_usage): Add help string for the --debug-info-dir[12]
	options.
	(parse_command_line): Handle the new --debug-info-dir[12] options.
	(main): Pass the debug info directories to read_corpus_from_elf.
	* bidw.cc (options::::di_root_path): New member.
	(options::options): Initialize it.
	(display_usage): Add help string for the new --debug-info-dir
	option.
	(parse_command_line): Handle the new --debug-info-dir.
	(main): Pass the debug info root path to read_corpus_from_elf.
	* tools/bilint.cc (options::di_root_path): New member.
	(options::options): Initialize it.
	(display_usage): Add help string for the new --debug-info-dir.
	(parse_command_line): Handle --debug-info-dir command line option.
	(main): Pass the debug info root path to read_corpus_from_elf.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-22 13:14:44 +02:00
Dodji Seketeli
c469546e45 Initial support for DW_TAG_partial_unit
* src/abg-dwarf-reader.cc (read_context::cur_tu_die_): New member.
	(read_context::read_context): Initialize the new member.
	(read_context::cur_tu_die): New accessors.
	(find_last_import_unit_point_before_die): New static function.
	(get_parent_die): Take a logical current die offset parameter.  If
	the die we want the parent for is a partial unit, then find the
	last DW_TAG_imported_unit that imports that partial unit before
	the logical current die and return the parent of that
	DW_TAG_imported_unit die.
	(get_scope_for_die): Take a logical current die offset parameter.
	Adjust.
	(build_translation_unit_and_add_to_ir): Set/unset the current
	translation unit DIE in the context.  Adjust.
	(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, build_ir_node_from_die):
	Take a logical current die offset parameter.  Adjust.
	(build_corpus): Accept that we can have DIE that are not
	DW_TAG_compile_unit at the top level, because, well, we can now
	have DW_TAG_partial_unit too.
	* tests/data/test-read-dwarf/test2-{0,1}.cc: New test source
	files.
	* tests/data/test-read-dwarf/test2.h: Likewise.
	* tests/data/test-read-dwarf/test2.so: New input binary to read.
	* tests/data/test-read-dwarf/test2.so.abi: New reference test to
	compare against.
	* tests/test-read-dwarf.cc: Adjust to launch the new test.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-19 17:26:40 +02:00
Dodji Seketeli
8f9b8e76a0 Add regression tests for dwarf reading
* tests/test-read-dwarf.cc: New dwarf reading regression test.
	* tests/data/test-read-dwarf/test0: New test input.
	* data/test-read-dwarf/test0: Likewise.
	* data/test-read-dwarf/test0.abi: Likewise.
	* data/test-read-dwarf/test0.cc: Likewise.
	* data/test-read-dwarf/test1: Likewise.
	* data/test-read-dwarf/test1.abi: Likewise.
	* data/test-read-dwarf/test1.cc: Likewise.
	* tests/Makefile.am: Build the new tests/test-read-dwarf.cc file.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-07 15:51:52 +01:00