From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Cc: andrew.burgess@embecosm.com, jimw@sifive.com, palmer@sifive.com
Subject: [PATCH 2/4] Fall back to a default value of 0 for the MISA register.
Date: Wed, 19 Sep 2018 23:21:00 -0000 [thread overview]
Message-ID: <20180919231950.22634-3-jhb@FreeBSD.org> (raw)
In-Reply-To: <20180919231950.22634-1-jhb@FreeBSD.org>
The riscv architecture supports multiple architectures with differing
register sizes. If the MISA register is present, the specific
architecture is chosen based on its value, otherwise properties are
inferred from flags in the ELF header. However, the code to read MISA
throws an exception if the register is not present. This does not
trip when cross-debugging a core dump, but does trigger when
attempting to debug native processes if the native target does not
provide MISA.
MISA is a machine-mode register in RISC-V which may or may not be
available to supervisor operating systems. Rather than requiring
targets to always provide a fake MISA value, fallback to 0 for now.
(The Linux native target currently always provides a fake value of 0
for MISA.)
Longer term, the riscv architecture should perhaps add target
descriptions for the various sub-architectures and permit targets to
set a description. It would then only use MISA as a fallback if an
explicit description is not provided. This will permit the proper
register set to be used when debugging a RV32 process (where U-XLEN in
SSTATUS is set to 32 bits) on an RV64 host (where XLEN in MISA
indicates 64 bits) for example by using the U-XLEN field in SSTATUS to
set the target description (RV32 vs RV64) for individual processes.
gdb/ChangeLog:
* riscv-tdep.c (riscv_read_misa_reg): Fall back to a default value
of zero.
---
gdb/ChangeLog | 5 +++++
gdb/riscv-tdep.c | 13 +++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e1892f531a..9b8a5175b0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-09-19 John Baldwin <jhb@FreeBSD.org>
+
+ * riscv-tdep.c (riscv_read_misa_reg): Fall back to a default value
+ of zero.
+
2018-09-19 John Baldwin <jhb@FreeBSD.org>
* trad-frame.c (trad_frame_set_regmap, trad_frame_set_reg_regmap):
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 254914c9c7..4b385ed5da 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -317,9 +317,18 @@ riscv_read_misa_reg (bool *read_p)
}
CATCH (ex, RETURN_MASK_ERROR)
{
- /* Old cores might have MISA located at a different offset. */
- value = get_frame_register_unsigned (frame,
+ TRY
+ {
+ /* Old cores might have MISA located at a different offset. */
+ value
+ = get_frame_register_unsigned (frame,
RISCV_CSR_LEGACY_MISA_REGNUM);
+ }
+ CATCH (ex, RETURN_MASK_ERROR)
+ {
+ value = 0;
+ }
+ END_CATCH
}
END_CATCH
}
--
2.18.0
next prev parent reply other threads:[~2018-09-19 23:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-19 23:20 [PATCH 0/4] Initial support for FreeBSD/riscv John Baldwin
2018-09-19 23:21 ` John Baldwin [this message]
2018-09-20 0:09 ` [PATCH 2/4] Fall back to a default value of 0 for the MISA register Jim Wilson
2018-09-20 0:40 ` John Baldwin
2018-09-20 20:31 ` John Baldwin
2018-09-20 20:57 ` Jim Wilson
2018-09-20 22:55 ` John Baldwin
2018-09-20 21:51 ` Andrew Burgess
2018-09-20 23:01 ` John Baldwin
2018-09-21 9:27 ` Andrew Burgess
2018-09-21 17:26 ` Jim Wilson
2018-09-28 9:44 ` Andrew Burgess
2018-09-28 18:25 ` Palmer Dabbelt
2018-09-24 20:35 ` John Baldwin
2018-09-19 23:21 ` [PATCH 3/4] Add FreeBSD/riscv architecture John Baldwin
2018-09-19 23:21 ` [PATCH 1/4] Add helper functions to trad_frame to support register cache maps John Baldwin
2018-09-19 23:29 ` [PATCH 4/4] Add native target for FreeBSD/riscv John Baldwin
2018-09-20 4:19 ` Eli Zaretskii
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=20180919231950.22634-3-jhb@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=jimw@sifive.com \
--cc=palmer@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