Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* can target code change architecture setting?
@ 2016-10-07 17:38 Tim Newsome
  2016-10-10  9:26 ` Yao Qi
  0 siblings, 1 reply; 8+ messages in thread
From: Tim Newsome @ 2016-10-07 17:38 UTC (permalink / raw)
  To: gdb

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.

Thank you,
Tim


^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: can target code change architecture setting?
@ 2016-10-10 16:48 duane
  2016-10-10 19:46 ` Tim Newsome
  2016-10-11 11:48 ` Yao Qi
  0 siblings, 2 replies; 8+ messages in thread
From: duane @ 2016-10-10 16:48 UTC (permalink / raw)
  To: Tim Newsome, Yao Qi; +Cc: gdb

Yao> > 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. 

Tim>> That sounds like a good solution. I'll see if I can make it
happen.

For an application level, I think this is 100% correct.

However in the bare metal case, I have a question about RISCV (and
arm-arch64)

In Arm-ARCH64 - you can have both 32bit application, and 64bit kernel.
I'm not sure about the x86_64 case - because I am not familiar with bare
metal debug there.

As a result, when a "jtag-halt" (aka: Bare metal halt) the CPU may halt
in either mode.

Described another way:

      You are stepping through 32bit user space code.
      Set a breakpoint.
      Click RUN

Option 1:
      The 64bit kernel crashes, and the jtag debugger reports HALT
      but the registers are 100% wrong.

Option 2:
      A hardware read/write breakpoint is configured
      And that hardware break point is triggered.
      maybe you are debugging memory corruption issues, these things
happen

Option 3:
      The program is taking a long time, the human hits "control-C"
      GDB sends a stop/halt packet
      And the CPU stops/halts in 64bit mode

Question #1 Is this dual mode possible in RISCV?

Question #2 - How should the remote debugger respond to GDB?
 
      I don't think there is an "architecture change" packet.

Thanks.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-11-03 19:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-07 17:38 can target code change architecture setting? Tim Newsome
2016-10-10  9:26 ` Yao Qi
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox