From patchwork Fri Oct 9 21:41:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 9029 Received: (qmail 20570 invoked by alias); 9 Oct 2015 21:42:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 20441 invoked by uid 89); 9 Oct 2015 21:42:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 09 Oct 2015 21:42:14 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 59F2428F8A for ; Fri, 9 Oct 2015 17:42:12 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id cYIhUKyrYuPq for ; Fri, 9 Oct 2015 17:42:12 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 26CFC2912D for ; Fri, 9 Oct 2015 17:42:12 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id B709E42BBB; Fri, 9 Oct 2015 14:42:10 -0700 (PDT) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [PATCH 6/8] make is_scalar_type non-static and use it in ada-lang.c Date: Fri, 9 Oct 2015 14:41:59 -0700 Message-Id: <1444426921-19985-7-git-send-email-brobecker@adacore.com> In-Reply-To: <1444426921-19985-1-git-send-email-brobecker@adacore.com> References: <1444426921-19985-1-git-send-email-brobecker@adacore.com> Just a small cleanup, to avoid code duplication... gdb/ChangeLog: * gdbtypes.h (is_scalar_type): Add extern declaration. * gdbtypes.c (is_scalar_type): Make non-static. * ada-lang.c (ada_value_primitive_packed_val): Use is_scalar_type to compute IS_SCALAR instead of doing it ourselves. --- gdb/ChangeLog | 7 +++++++ gdb/ada-lang.c | 14 +------------- gdb/gdbtypes.c | 2 +- gdb/gdbtypes.h | 2 ++ 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 06a0637..9787afe 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2015-10-09 Joel Brobecker + * gdbtypes.h (is_scalar_type): Add extern declaration. + * gdbtypes.c (is_scalar_type): Make non-static. + * ada-lang.c (ada_value_primitive_packed_val): Use is_scalar_type + to compute IS_SCALAR instead of doing it ourselves. + +2015-10-09 Joel Brobecker + * ada-lang.c (ada_value_primitive_packed_val): Rework handling of case where TYPE is dynamic. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 2b2c47c..d9bbed9 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2519,7 +2519,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, gdb_byte *src; /* First byte containing data to unpack */ int src_len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8; gdb_byte *unpacked; - int is_scalar; + const int is_scalar = is_scalar_type (type); const int is_big_endian = gdbarch_bits_big_endian (get_type_arch (type)); gdb_byte *staging = NULL; int staging_len = 0; @@ -2527,18 +2527,6 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, type = ada_check_typedef (type); - switch (TYPE_CODE (type)) - { - case TYPE_CODE_ARRAY: - case TYPE_CODE_UNION: - case TYPE_CODE_STRUCT: - is_scalar = 0; - break; - default: - is_scalar = 1; - break; - } - if (obj == NULL) src = (gdb_byte *) valaddr + offset; else diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index b406550..919cac9 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -2717,7 +2717,7 @@ is_integral_type (struct type *t) /* Return true if TYPE is scalar. */ -static int +int is_scalar_type (struct type *type) { type = check_typedef (type); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 9c64569..0828723 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1912,6 +1912,8 @@ extern int can_dereference (struct type *); extern int is_integral_type (struct type *); +extern int is_scalar_type (struct type *type); + extern int is_scalar_type_recursive (struct type *); extern int class_or_union_p (const struct type *);