This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] dwarf2read.c: Make dir_index and file_name_index strong typedefs


*** TEST RESULTS FOR COMMIT ecfb656c37b982479d8eb07f240b434772d98fd6 ***

Author: Pedro Alves <palves@redhat.com>
Branch: master
Commit: ecfb656c37b982479d8eb07f240b434772d98fd6

dwarf2read.c: Make dir_index and file_name_index strong typedefs

This should help catch mistakes related to mixing the 1-based DWARF
indexes with 0-based std::vector indexes, since the new types do not
implicitly convert to anything.

The change in read_formatted_entries relates to the fact that doing
the seemingly simpler:

 -	      uintp = &fe.dir_index;
 +	      uintp = (unsigned int *) &fe.dir_index;

would be undefined C/C++.  So to address that, I made the function
extract the form before assigning to the file_entry.  It felt natural
to use gdb::optional for "do I have this value", and this is what
motivated the previous patch that added the missing observer methods
to gdb::optional.

gdb/ChangeLog:
2017-04-04  Pedro Alves  <palves@redhat.com>

	* common/underlying.h: New file.
	* dwarf2read.c: Include "common/gdb_optional.h" and
	"common/underlying.h".
	(dir_index, file_name_index): New types.
	(file_entry): Use them.
	(file_entry::include): Use to_underlying.
	(line_header::add_file_name): Use dir_index.
	(read_formatted_entries): Use gdb::optional.  Read form before
	writting to file_entry.
	(dwarf_decode_line_header): Use dir_index.
	(lnp_state_machine::current_file): Use to_underlying.
	(lnp_state_machine::file): Change type to file_name_index.
	(dwarf_record_line): Use to_underlying.
	(init_lnp_state_machine): Use file_name_index.
	(dwarf_decode_lines_1): Use dir_index and file_name_index.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]