public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Yvan Roux <yroux@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/arm: Use if-else if instead of switch Date: Mon, 25 Jul 2022 13:31:25 +0000 (GMT) [thread overview] Message-ID: <20220725133125.A34A33858C55@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=42e11f363c5e2c5e750e9b9b67fbae511d83974d commit 42e11f363c5e2c5e750e9b9b67fbae511d83974d Author: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> Date: Mon Jul 25 14:51:58 2022 +0200 gdb/arm: Use if-else if instead of switch As the register numbers for the alternative Arm SP registers are not constant, it's not possible to use switch statement to define the rules. In order to not have a mix, replace the few existing switch statements with regular if-else if statements Diff: --- gdb/arm-tdep.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index d3b4fce98a3..7d0944f9e3f 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -3785,9 +3785,8 @@ arm_dwarf2_prev_register (struct frame_info *this_frame, void **this_cache, CORE_ADDR lr; ULONGEST cpsr; - switch (regnum) + if (regnum == ARM_PC_REGNUM) { - case ARM_PC_REGNUM: /* The PC is normally copied from the return column, which describes saves of LR. However, that version may have an extra bit set to indicate Thumb state. The bit is not @@ -3807,18 +3806,18 @@ arm_dwarf2_prev_register (struct frame_info *this_frame, void **this_cache, lr = frame_unwind_register_unsigned (this_frame, ARM_LR_REGNUM); return frame_unwind_got_constant (this_frame, regnum, arm_addr_bits_remove (gdbarch, lr)); - - case ARM_PS_REGNUM: + } + else if (regnum == ARM_PS_REGNUM) + { /* Reconstruct the T bit; see arm_prologue_prev_register for details. */ cpsr = get_frame_register_unsigned (this_frame, regnum); lr = frame_unwind_register_unsigned (this_frame, ARM_LR_REGNUM); cpsr = reconstruct_t_bit (gdbarch, lr, cpsr); return frame_unwind_got_constant (this_frame, regnum, cpsr); - - default: - internal_error (__FILE__, __LINE__, - _("Unexpected register %d"), regnum); } + + internal_error (__FILE__, __LINE__, + _("Unexpected register %d"), regnum); } /* Implement the stack_frame_destroyed_p gdbarch method. */ @@ -4944,17 +4943,13 @@ arm_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum, return; } - switch (regnum) + if (regnum == ARM_PC_REGNUM || regnum == ARM_PS_REGNUM) { - case ARM_PC_REGNUM: - case ARM_PS_REGNUM: reg->how = DWARF2_FRAME_REG_FN; reg->loc.fn = arm_dwarf2_prev_register; - break; - case ARM_SP_REGNUM: - reg->how = DWARF2_FRAME_REG_CFA; - break; } + else if (regnum == ARM_SP_REGNUM) + reg->how = DWARF2_FRAME_REG_CFA; } /* Given BUF, which is OLD_LEN bytes ending at ENDADDR, expand
reply other threads:[~2022-07-25 13:31 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220725133125.A34A33858C55@sourceware.org \ --to=yroux@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).