Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Tim Newsome <tim@sifive.com>
To: gdb <gdb@sourceware.org>
Subject: gdbarch_init, ABI, and registers
Date: Wed, 06 Dec 2017 20:21:00 -0000	[thread overview]
Message-ID: <CAGDihekNnrW=JnVGuXHaPE6G3KPqxYBqwfCYhqSje_tFvCZztg@mail.gmail.com> (raw)

Still working on RISC-V support…

I’ve taught OpenOCD to provide a target description, so now when connecting
to a target that doesn’t have an FPU, the FPU registers don’t show up.
Obviously I want this reflected in gdb, and I’ve managed to make that work
in some cases. However, it doesn’t always work. Sometimes my target appears
to revert to the case where it just uses the built-in list of registers,
despite being connected to an OpenOCD that I know provides the target
description.

My confusion comes from when riscv_gdbarch_init() is called, and how. With
a bit of instrumenting, I get this output:

+ /opt/riscv/bin/riscv64-unknown-elf-gdb
>>> riscv_gdbarch_init()
>>>     bits_per_word=64
>>>     tdesc_has_register() -> 0
>>>     info.abfd=(nil)
>>>     abi=1073741824
GNU gdb (GDB) 8.0.50.20170724-git
...
(gdb) target extended-remote localhost:38295

target extended-remote localhost:38295
Remote debugging using localhost:38295
>>> riscv_gdbarch_init()
>>>     bits_per_word=64
>>>     tdesc_has_register() -> 1
>>>     info.abfd=(nil)
>>>     abi=1073741824
warning: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.
0x00000000800009f0 in ?? ()
(gdb) file HiFive1_debug-32
>>> riscv_gdbarch_init()

>>>     bits_per_word=32
>>>     tdesc_has_register() -> 1
>>>     info.abfd=0x55a8a1f4e7f0
>>>     flavour=5
>>>     abi=0
>>> riscv_gdbarch_init()
>>>     bits_per_word=32
>>>     tdesc_has_register() -> 0
>>>     info.abfd=0x55a8a1f4e7f0
>>>     flavour=5
>>>     abi=0
Reading symbols from HiFive1_debug-32...done.
(gdb) set arch riscv:rv32
>>> riscv_gdbarch_init()
>>>     bits_per_word=32
>>>     tdesc_has_register() -> 1
>>>     info.abfd=0x55a8a1f4e7f0
>>>     flavour=5
>>>     abi=0
The target architecture is assumed to be riscv:rv32

It almost feels like I’m on completely the wrong track by initializing
registers in riscv_gdbarch_init(), but that’s what the ARM and MIPS targets
do. A lot of code in their gdbarch_init() is dedicated to figuring out the
ABI in use. How are ABIs and registers related? In my world view the
hardware has certain registers, and how the software chooses to use those
registers is the ABI. But changing the ABI doesn’t change what registers
exist.

Are there callbacks I can use that are called when we connect to/disconnect
from a remote server like OpenOCD?

Thank you,
Tim
​


             reply	other threads:[~2017-12-06 20:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-06 20:21 Tim Newsome [this message]
2017-12-07 14:21 ` Handling language trampoline Dmitry Antipov
2017-12-07 14:58   ` Pedro Alves
2017-12-08  6:39     ` Dmitry Antipov
2017-12-08 11:12       ` Pedro Alves
2017-12-07 21:22 ` gdbarch_init, ABI, and registers Tim Newsome
2017-12-08 12:20   ` Ulrich Weigand
2017-12-08 20:03     ` Tim Newsome
2017-12-09 11:27       ` Ulrich Weigand

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='CAGDihekNnrW=JnVGuXHaPE6G3KPqxYBqwfCYhqSje_tFvCZztg@mail.gmail.com' \
    --to=tim@sifive.com \
    --cc=gdb@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: 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