From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9509 invoked by alias); 7 Aug 2015 02:37:10 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 9489 invoked by uid 89); 7 Aug 2015 02:37:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 07 Aug 2015 02:37:08 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 5C2808E3FE; Fri, 7 Aug 2015 02:37:07 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t76JkvuL023684; Thu, 6 Aug 2015 15:46:57 -0400 Message-ID: <55C3B9B0.5080202@redhat.com> Date: Fri, 07 Aug 2015 02:37:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH] Add casts for legitimate integer to enum conversions References: <1438889665-25655-1-git-send-email-simon.marchi@ericsson.com> In-Reply-To: <1438889665-25655-1-git-send-email-simon.marchi@ericsson.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-08/txt/msg00190.txt.bz2 On 08/06/2015 08:34 PM, Simon Marchi wrote: > This patch is mostly extracted from Pedro's C++ branch. Thanks a lot again for doing this. While patches are in the branch, you're doing a lot of work to clean them up, split/merge them, writing rationales, etc. Much appreciated. And when you reach the same conclusions I did, makes me much more confident to march ahead with the patches quickly. > 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. Yeah, I had similar thoughts, and had decided to leave it be until we have C++11. > > 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. LGTM. Thanks, Pedro Alves