From: Palmer Dabbelt <palmer@sifive.com>
To: andrew.burgess@embecosm.com
Cc: gdb-patches@sourceware.org, Jim Wilson <jimw@sifive.com>,
andrew.burgess@embecosm.com
Subject: Re: [PATCH 2/4] gdb/riscv: Extend instruction decode to cover more instructions
Date: Wed, 29 Aug 2018 23:10:00 -0000 [thread overview]
Message-ID: <mhng-3c9617ba-bf2a-4068-ad74-26ead2031c9e@palmer-si-x1c4> (raw)
In-Reply-To: <d74de1fc1f7150666bee412ba9d48e5357c3316e.1535560591.git.andrew.burgess@embecosm.com>
On Wed, 29 Aug 2018 09:40:52 PDT (-0700), andrew.burgess@embecosm.com wrote:
> Extends the instruction decoder used during prologue scan and software
> single step to cover more instructions. These instructions are
> encountered when running the current GDB testsuite with the DWARF
> stack unwinders turned off.
>
> gdb/ChangeLog:
>
> * riscv-tdep.c (riscv_insn::decode): Decode c.addi4spn, c.sd,
> c.sw, c.swsp, and c.sdsp.
> ---
> gdb/ChangeLog | 5 +++++
> gdb/riscv-tdep.c | 40 ++++++++++++++++++++++++++++++++++++++--
> 2 files changed, 43 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
> index 2f619c35e75..b4ac83a6dd9 100644
> --- a/gdb/riscv-tdep.c
> +++ b/gdb/riscv-tdep.c
> @@ -972,6 +972,31 @@ private:
> m_imm.s = EXTRACT_STYPE_IMM (ival);
> }
>
> + /* Helper for DECODE, decode 16-bit CS-type instruction. The immediate
> + encoding is different for each CSS format instruction, so extracting
I think you mean "each CS format" here -- it's true for CSS formats as well,
just not relevant until below.
> + the immediate is left up to the caller, who should pass the extracted
> + immediate value through in IMM. */
> + void decode_cs_type_insn (enum opcode opcode, ULONGEST ival, int imm)
> + {
> + m_opcode = opcode;
> + m_imm.s = imm;
> + m_rs1 = decode_register_index_short (ival, OP_SH_CRS1S);
> + m_rs2 = decode_register_index_short (ival, OP_SH_CRS2S);
> + }
> +
> + /* Helper for DECODE, decode 16-bit CSS-type instruction. The immediate
> + encoding is different for each CSS format instruction, so extracting
> + the immediate is left up to the caller, who should pass the extracted
> + immediate value through in IMM. */
> + void decode_css_type_insn (enum opcode opcode, ULONGEST ival, int imm)
> + {
> + m_opcode = opcode;
> + m_imm.s = imm;
> + m_rs1 = RISCV_SP_REGNUM;
> + /* Not a compressed register number in this case. */
> + m_rs2 = decode_register_index (ival, OP_SH_CRS2);
> + }
> +
> /* Helper for DECODE, decode 32-bit U-type instruction. */
> void decode_u_type_insn (enum opcode opcode, ULONGEST ival)
> {
> @@ -1165,14 +1190,25 @@ riscv_insn::decode (struct gdbarch *gdbarch, CORE_ADDR pc)
> m_rd = m_rs1 = decode_register_index (ival, OP_SH_RD);
> m_imm.s = EXTRACT_RVC_ADDI16SP_IMM (ival);
> }
> + else if (xlen < 16 && is_c_addi4spn_insn (ival))
> + {
> + m_opcode = ADDI;
> + m_rd = decode_register_index_short (ival, OP_SH_CRS2S);
> + m_rs1 = RISCV_SP_REGNUM;
> + m_imm.s = EXTRACT_RVC_ADDI4SPN_IMM (ival);
I think this is OK: the immediate is actually unsigned, but it's only 10 bits
long so it doesn't matter.
> + }
> else if (is_c_lui_insn (ival))
> m_opcode = OTHER;
> /* C_SD and C_FSW have the same opcode. C_SD is RV64 and RV128 only,
> and C_FSW is RV32 only. */
> else if (xlen != 4 && is_c_sd_insn (ival))
> - m_opcode = OTHER;
> + decode_cs_type_insn (SD, ival, EXTRACT_RVC_LD_IMM (ival));
> else if (is_c_sw_insn (ival))
> - m_opcode = OTHER;
> + decode_cs_type_insn (SW, ival, EXTRACT_RVC_LW_IMM (ival));
> + else if (is_c_swsp_insn (ival))
> + decode_css_type_insn (SW, ival, EXTRACT_RVC_SWSP_IMM (ival));
> + else if (is_c_sdsp_insn (ival))
> + decode_css_type_insn (SW, ival, EXTRACT_RVC_SDSP_IMM (ival));
> /* C_JR and C_MV have the same opcode. If RS2 is 0, then this is a C_JR.
> So must try to match C_JR first as it ahs more bits in mask. */
> else if (is_c_jr_insn (ival))
next prev parent reply other threads:[~2018-08-29 23:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-29 16:41 [PATCH 0/4] RISCV Non-DWARF stack unwinding Andrew Burgess
2018-08-29 16:41 ` [PATCH 2/4] gdb/riscv: Extend instruction decode to cover more instructions Andrew Burgess
2018-08-29 22:05 ` Jim Wilson
2018-08-29 23:10 ` Palmer Dabbelt [this message]
2018-08-29 16:41 ` [PATCH 4/4] gdb/riscv: Provide non-DWARF stack unwinder Andrew Burgess
2018-08-29 23:36 ` Palmer Dabbelt
2018-08-29 16:41 ` [PATCH 3/4] gdb: Extend the trad-frame API Andrew Burgess
2018-08-31 15:03 ` Tom Tromey
2018-08-29 16:41 ` [PATCH 1/4] gdb/riscv: remove extra caching of misa register Andrew Burgess
2018-08-29 23:10 ` Palmer Dabbelt
2018-08-29 23:36 ` [PATCH 0/4] RISCV Non-DWARF stack unwinding Palmer Dabbelt
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=mhng-3c9617ba-bf2a-4068-ad74-26ead2031c9e@palmer-si-x1c4 \
--to=palmer@sifive.com \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=jimw@sifive.com \
/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: link
Be 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