From patchwork Wed Aug 2 15:41:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 21874 Received: (qmail 9483 invoked by alias); 2 Aug 2017 15:41:35 -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 8587 invoked by uid 89); 2 Aug 2017 15:41:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Aug 2017 15:41:33 +0000 Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Forcepoint Email with ESMTPS id C81B08526BE0 for ; Wed, 2 Aug 2017 16:41:26 +0100 (IST) Received: from [10.20.78.24] (10.20.78.24) by HHMAIL01.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server id 14.3.294.0; Wed, 2 Aug 2017 16:41:29 +0100 Date: Wed, 2 Aug 2017 16:41:20 +0100 From: "Maciej W. Rozycki" To: Subject: [committed] MIPS: Factor out FPU type naming in `gdbarch' debug Message-ID: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Replace chains of conditional expressions used in target-dependent MIPS `gdbarch' debug output to get a textual name of the FPU type with calls to a helper decoder function, improving code readability. No functional change. gdb/ * mips-tdep.c (mips_fpu_type_str): New function. (mips_dump_tdep): Call it. --- gdb/mips-tdep.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) gdb-mips-dump-tdep-fpu-type.diff Index: binutils/gdb/mips-tdep.c =================================================================== --- binutils.orig/gdb/mips-tdep.c 2017-08-02 15:53:01.525265847 +0100 +++ binutils/gdb/mips-tdep.c 2017-08-02 16:32:59.908428854 +0100 @@ -8907,6 +8907,24 @@ show_mips_compression (struct ui_file *f value); } +/* Return a textual name for MIPS FPU type FPU_TYPE. */ + +static const char * +mips_fpu_type_str (enum mips_fpu_type fpu_type) +{ + switch (fpu_type) + { + case MIPS_FPU_NONE: + return "none"; + case MIPS_FPU_SINGLE: + return "single"; + case MIPS_FPU_DOUBLE: + return "double"; + default: + return "???"; + } +} + static void mips_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) { @@ -8957,19 +8975,13 @@ mips_dump_tdep (struct gdbarch *gdbarch, fprintf_unfiltered (file, "mips_dump_tdep: MIPS_DEFAULT_FPU_TYPE = %d (%s)\n", MIPS_DEFAULT_FPU_TYPE, - (MIPS_DEFAULT_FPU_TYPE == MIPS_FPU_NONE ? "none" - : MIPS_DEFAULT_FPU_TYPE == MIPS_FPU_SINGLE ? "single" - : MIPS_DEFAULT_FPU_TYPE == MIPS_FPU_DOUBLE ? "double" - : "???")); + mips_fpu_type_str (MIPS_DEFAULT_FPU_TYPE)); fprintf_unfiltered (file, "mips_dump_tdep: MIPS_EABI = %d\n", MIPS_EABI (gdbarch)); fprintf_unfiltered (file, "mips_dump_tdep: MIPS_FPU_TYPE = %d (%s)\n", MIPS_FPU_TYPE (gdbarch), - (MIPS_FPU_TYPE (gdbarch) == MIPS_FPU_NONE ? "none" - : MIPS_FPU_TYPE (gdbarch) == MIPS_FPU_SINGLE ? "single" - : MIPS_FPU_TYPE (gdbarch) == MIPS_FPU_DOUBLE ? "double" - : "???")); + mips_fpu_type_str (MIPS_FPU_TYPE (gdbarch))); } extern initialize_file_ftype _initialize_mips_tdep; /* -Wmissing-prototypes */