aboutsummaryrefslogtreecommitdiff
path: root/gdb/ppc-linux-tdep.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/ppc-linux-tdep.c
parent84da3f0cf938f8f74d9fa89f89f228bc950282c6 (diff)
downloadfsf-binutils-gdb-aead7601eb0ddc3fa51d43747bdad0e02abda342.zip
fsf-binutils-gdb-aead7601eb0ddc3fa51d43747bdad0e02abda342.tar.gz
fsf-binutils-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/ppc-linux-tdep.c')
-rw-r--r--gdb/ppc-linux-tdep.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index cf46c2d..69c791e 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -765,29 +765,32 @@ static struct linux_record_tdep ppc64_linux_record_tdep;
static enum gdb_syscall
ppc_canonicalize_syscall (int syscall)
{
+ int result = -1;
+
if (syscall <= 165)
- return syscall;
+ result = syscall;
else if (syscall >= 167 && syscall <= 190) /* Skip query_module 166 */
- return syscall + 1;
+ result = syscall + 1;
else if (syscall >= 192 && syscall <= 197) /* mmap2 */
- return syscall;
+ result = syscall;
else if (syscall == 208) /* tkill */
- return gdb_sys_tkill;
+ result = gdb_sys_tkill;
else if (syscall >= 207 && syscall <= 220) /* gettid */
- return syscall + 224 - 207;
+ result = syscall + 224 - 207;
else if (syscall >= 234 && syscall <= 239) /* exit_group */
- return syscall + 252 - 234;
- else if (syscall >= 240 && syscall <=248) /* timer_create */
- return syscall += 259 - 240;
- else if (syscall >= 250 && syscall <=251) /* tgkill */
- return syscall + 270 - 250;
+ result = syscall + 252 - 234;
+ else if (syscall >= 240 && syscall <= 248) /* timer_create */
+ result = syscall += 259 - 240;
+ else if (syscall >= 250 && syscall <= 251) /* tgkill */
+ result = syscall + 270 - 250;
else if (syscall == 336)
- return gdb_sys_recv;
+ result = gdb_sys_recv;
else if (syscall == 337)
- return gdb_sys_recvfrom;
+ result = gdb_sys_recvfrom;
else if (syscall == 342)
- return gdb_sys_recvmsg;
- return -1;
+ result = gdb_sys_recvmsg;
+
+ return (enum gdb_syscall) result;
}
/* Record registers which might be clobbered during system call.