This is the mail archive of the
gdb-testers@sourceware.org
mailing list for the GDB project.
[binutils-gdb] dwarf2read.c: Make dir_index and file_name_index strong typedefs
- From: sergiodj+buildbot at sergiodj dot net
- To: gdb-testers at sourceware dot org
- Date: Mon, 24 Jul 2017 10:16:26 -0400
- Subject: [binutils-gdb] dwarf2read.c: Make dir_index and file_name_index strong typedefs
- Authentication-results: sourceware.org; auth=none
*** 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.