aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2015-08-06 17:21:41 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2015-08-06 17:22:49 -0400
commitaead7601eb0ddc3fa51d43747bdad0e02abda342 (patch)
treee5c4d43a1986795822cf6a6be84a1923eb0cf10d /gdb/dwarf2read.c
parent84da3f0cf938f8f74d9fa89f89f228bc950282c6 (diff)
downloadgdb-aead7601eb0ddc3fa51d43747bdad0e02abda342.zip
gdb-aead7601eb0ddc3fa51d43747bdad0e02abda342.tar.gz
gdb-aead7601eb0ddc3fa51d43747bdad0e02abda342.tar.bz2
Add casts for legitimate integer to enum conversions
This patch is mostly extracted from Pedro's C++ branch. It adds explicit casts from integer to enum types, where it is really the intention to do so. This could be because we are ... * iterating on enum values (we need to iterate on an equivalent integer) * converting from a value read from bytes (dwarf attribute, agent expression opcode) to the equivalent enum * reading the equivalent integer value from another language (Python/Guile) An exception to that is the casts in regcache.c. It seems to me like struct regcache's register_status field could be a pointer to an array of enum register_status. Doing so would waste a bit of memory (4 bytes used by the enum vs 1 byte used by the current signed char, for each register). If we switch to C++11 one day, we can define the underlying type of an enum type, so we could have the best of both worlds. gdb/ChangeLog: * arm-tdep.c (set_fp_model_sfunc): Add cast from integer to enum. (arm_set_abi): Likewise. * ax-general.c (ax_print): Likewise. * c-exp.y (exp : string_exp): Likewise. * compile/compile-loc2c.c (compute_stack_depth_worker): Likewise. (do_compile_dwarf_expr_to_c): Likewise. * cp-name-parser.y (demangler_special : DEMANGLER_SPECIAL start): Likewise. * dwarf2expr.c (execute_stack_op): Likewise. * dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise. (disassemble_dwarf_expression): Likewise. * dwarf2read.c (dwarf2_add_member_fn): Likewise. (read_array_order): Likewise. (abbrev_table_read_table): Likewise. (read_attribute_value): Likewise. (skip_unknown_opcode): Likewise. (dwarf_decode_macro_bytes): Likewise. (dwarf_decode_macros): Likewise. * eval.c (value_f90_subarray): Likewise. * guile/scm-param.c (gdbscm_make_parameter): Likewise. * i386-linux-tdep.c (i386_canonicalize_syscall): Likewise. * infrun.c (handle_command): Likewise. * memory-map.c (memory_map_start_memory): Likewise. * osabi.c (set_osabi): Likewise. * parse.c (operator_length_standard): Likewise. * ppc-linux-tdep.c (ppc_canonicalize_syscall): Likewise, and use single return point. * python/py-frame.c (gdbpy_frame_stop_reason_string): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol): Likewise. (gdbpy_lookup_global_symbol): Likewise. * record-full.c (record_full_restore): Likewise. * regcache.c (regcache_register_status): Likewise. (regcache_raw_read): Likewise. (regcache_cooked_read): Likewise. * rs6000-tdep.c (powerpc_set_vector_abi): Likewise. * symtab.c (initialize_ordinary_address_classes): Likewise. * target-debug.h (target_debug_print_signals): Likewise. * utils.c (do_restore_current_language): Likewise.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r--gdb/dwarf2read.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b5ffd04..7e79342 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -12897,7 +12897,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
/* Get accessibility. */
attr = dwarf2_attr (die, DW_AT_accessibility, cu);
if (attr)
- accessibility = DW_UNSND (attr);
+ accessibility = (enum dwarf_access_attribute) DW_UNSND (attr);
else
accessibility = dwarf2_default_access_attribute (die, cu);
switch (accessibility)
@@ -13812,7 +13812,8 @@ read_array_order (struct die_info *die, struct dwarf2_cu *cu)
attr = dwarf2_attr (die, DW_AT_ordering, cu);
- if (attr) return DW_SND (attr);
+ if (attr)
+ return (enum dwarf_array_dim_ordering) DW_SND (attr);
/* GNU F77 is a special case, as at 08/2004 array type info is the
opposite order to the dwarf2 specification, but data is still
@@ -15345,7 +15346,8 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
/* read in abbrev header */
cur_abbrev->number = abbrev_number;
- cur_abbrev->tag = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+ cur_abbrev->tag
+ = (enum dwarf_tag) read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
abbrev_ptr += bytes_read;
cur_abbrev->has_children = read_1_byte (abfd, abbrev_ptr);
abbrev_ptr += 1;
@@ -15365,8 +15367,10 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
* sizeof (struct attr_abbrev)));
}
- cur_attrs[cur_abbrev->num_attrs].name = abbrev_name;
- cur_attrs[cur_abbrev->num_attrs++].form = abbrev_form;
+ cur_attrs[cur_abbrev->num_attrs].name
+ = (enum dwarf_attribute) abbrev_name;
+ cur_attrs[cur_abbrev->num_attrs++].form
+ = (enum dwarf_form) abbrev_form;
abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
abbrev_ptr += bytes_read;
abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
@@ -16210,7 +16214,7 @@ read_attribute_value (const struct die_reader_specs *reader,
unsigned int bytes_read;
struct dwarf_block *blk;
- attr->form = form;
+ attr->form = (enum dwarf_form) form;
switch (form)
{
case DW_FORM_ref_addr:
@@ -21170,7 +21174,8 @@ skip_unknown_opcode (unsigned int opcode,
for (i = 0; i < arg; ++i)
{
- mac_ptr = skip_form_bytes (abfd, mac_ptr, mac_end, defn[i], offset_size,
+ mac_ptr = skip_form_bytes (abfd, mac_ptr, mac_end,
+ (enum dwarf_form) defn[i], offset_size,
section);
if (mac_ptr == NULL)
{
@@ -21287,7 +21292,7 @@ dwarf_decode_macro_bytes (bfd *abfd,
break;
}
- macinfo_type = read_1_byte (abfd, mac_ptr);
+ macinfo_type = (enum dwarf_macro_record_type) read_1_byte (abfd, mac_ptr);
mac_ptr++;
/* Note that we rely on the fact that the corresponding GNU and
@@ -21427,7 +21432,9 @@ dwarf_decode_macro_bytes (bfd *abfd,
/* We don't increment mac_ptr here, so this is just
a look-ahead. */
- next_type = read_1_byte (abfd, mac_ptr);
+ next_type
+ = (enum dwarf_macro_record_type) read_1_byte (abfd,
+ mac_ptr);
if (next_type != 0)
complaint (&symfile_complaints,
_("no terminating 0-type entry for "
@@ -21603,7 +21610,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
break;
}
- macinfo_type = read_1_byte (abfd, mac_ptr);
+ macinfo_type = (enum dwarf_macro_record_type) read_1_byte (abfd, mac_ptr);
mac_ptr++;
/* Note that we rely on the fact that the corresponding GNU and