dwarf2read.c: Make dir_index and file_name_index strong typedefs
authorPedro Alves <palves@redhat.com>
Tue, 4 Apr 2017 19:03:25 +0000 (20:03 +0100)
committerPedro Alves <palves@redhat.com>
Tue, 4 Apr 2017 19:03:25 +0000 (20:03 +0100)
commitecfb656c37b982479d8eb07f240b434772d98fd6
treee87a230ac686748f42607b24dadb075fc0c6becd
parentd194f1fe51cb85b8a919b7ee9e3a7715b0ec9744
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.
gdb/ChangeLog
gdb/common/underlying.h [new file with mode: 0644]
gdb/dwarf2read.c
This page took 0.02496 seconds and 4 git commands to generate.