Commit Graph

13 Commits

Author SHA1 Message Date
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
3153f4c83a Do not choke on AR archives
* tools/abg-tools-utils.h (file_type::FILE_TYPE_AR): New enumerator.
	* tools/abg-tools-utils.cc (guess_file_type): Recognize AR archive
	files.
	* tools/bidiff.cc (main): Support AR archives.
	* tools/bidw.cc (main): Likewise.
	* tools/bilint.cc (main): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-06-02 17:05:05 +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
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
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
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
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