From: Yao Qi <qiyaoltc@gmail.com>
To: Tim Newsome <tim@sifive.com>
Cc: gdb <gdb@sourceware.org>
Subject: Re: can target code change architecture setting?
Date: Mon, 10 Oct 2016 09:26:00 -0000 [thread overview]
Message-ID: <CAH=s-PNEgS0G3-qus29bGiuLzK-Yzj6_oVA8MS76uGMJNjpiKw@mail.gmail.com> (raw)
In-Reply-To: <CAGDihe=wvpAC6y8-d8ZNdM6NStMb9gUGDqT0s13YEQfiqnG0gw@mail.gmail.com>
On Fri, Oct 7, 2016 at 6:38 PM, Tim Newsome <tim@sifive.com> wrote:
> I’m working with riscv gdb support. One problem people occasionally
> run into is that riscv has both 32- and 64-bit variants. The current
> gdb code just assumes 64-bit by default (unless a file is specified,
> and then it gets the info from the ELF info). If such a gdb connects
> to a 32-bit target, bulk register reads end up wonky, and writes send
> too much data which confuses OpenOCD. Currently the user needs to do
> something like set arch riscv:rv32 to work around this.
>
> Is it possible for riscv-tdep.c to have some kind of callback function
> that is called when gdb connects to a server, and for that function to
> change the register width? If so, gdb could read the riscv misa
> (instruction set architecture information) register and transparently
> reconfigure.
>
> I looked, but I didn’t see any obvious callbacks that get called when
> connecting to a target.
>
I don't know much about riscv, so I assume 32-bit variant and 64-bit
variant can _not_ co-exist in one program. If so, each variant can
be abstracted as a gdbarch.
You need to add two target descriptions for 32-bit and 64-bit variants
respectively, and OpenOCD need to send back the right target
description to GDB. I assume riscv 32-bit and 64-bit variants have
different registers.
In GDB side, you need two gdbarch instances, 32-bit riscv and 64-bit
riscv. In riscv_gdbarch_init, look for the feature from the target
description (sent by OpenOCD for example), if 32-bit is found, create
and return gdbarch for 32-bit; if 64-bit is found, create and return
gdbarch for 64-bit.
If 32-bit variant and 64-bit one is quite different, you even can create
two tdep.c files, like riscv32-tdep.c and risc64-tdep.c.
--
Yao (齐尧)
next prev parent reply other threads:[~2016-10-10 9:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-07 17:38 Tim Newsome
2016-10-10 9:26 ` Yao Qi [this message]
2016-10-10 15:39 ` Tim Newsome
2016-10-10 16:48 duane
2016-10-10 19:46 ` Tim Newsome
2016-10-11 11:48 ` Yao Qi
2016-10-11 14:30 ` Duane Ellis
2016-11-03 19:47 ` Doug Evans
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='CAH=s-PNEgS0G3-qus29bGiuLzK-Yzj6_oVA8MS76uGMJNjpiKw@mail.gmail.com' \
--to=qiyaoltc@gmail.com \
--cc=gdb@sourceware.org \
--cc=tim@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