Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: jimw@sifive.com,	palmer@sifive.com,	jhb@FreeBSD.org,
	Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCH 0/4] Re: gdb/riscv: Add read_description method for riscv_linux_nat_target
Date: Thu, 29 Nov 2018 16:50:00 -0000	[thread overview]
Message-ID: <cover.1543509416.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <CAFyWVabMg7KYrE64GBz2qLcNJob=zOJLjWg0cFz1De-mRFoM+A@mail.gmail.com>

* Jim Wilson <jimw@sifive.com> [2018-11-28 18:05:21 -0800]:

> On Wed, Nov 28, 2018 at 2:49 PM Andrew Burgess
> <andrew.burgess@embecosm.com> wrote:
> > Adds riscv_linux_nat_target::read_description method to find a
> > suitable target description for the native linux target we are running
> > on.
> 
> I tested this on my HiFive Unleashed running a 4.15 kernel with
> patches for gcc, gdb, and glibc support.  It looks good.  It correctly
> detects the FP register support.  I get 3 extra failures
> FAIL: gdb.base/solib-display.exp: NO: continue
> FAIL: gdb.base/solib-display.exp: IN: continue
> FAIL: gdb.base/solib-display.exp: SEP: continue
> which looks a little odd since there is no obvious connection to the
> target description support, but this is repeatable so something is
> going on here.  Anyways, I'm OK with this for now, we can worry about
> debugging this problem later.

Thanks for looking at this Jim.

I dug a little deeper, and now understand what is going on here.  We
(or I) currently create a new target description on every call into
`riscv_create_target_description', I (incorrectly) thought that
`riscv_gdbarch_init' would sort it all out.  However, it turns out GDB
relies on identical target descriptions being the exact same object.

This new set of patches does a little prep-work, and then adds a cache
so that calls to `riscv_create_target_description' with the same
feature set will return the exact same target description object.

With this done, the tests listed above now pass.

But why I hear you ask?

Well, in the test we we set up a 'display' of a function local static
variable.  When the 'display' is setup GDB evaluates the expression
and captures the block and symbol.  Then, later, when we stop we can
display the value of the symbol even though (technically) its out of
scope (as we have the block cached).

In the test in question we actually set up the display, and the
restart GDB, however, we still manage to keep displaying the static
variable as we have the block cached, and (I guess) as we are running
the same program everything is still valid (I hope).

Anyway, GDB does have one safety check built in - has the gdbarch
changed.  If it has then GDB ditches the cached block and symbol, and
tries to reevaluate the 'display' string.  However, when this happens
the function local static variable is out of scope, and the display
expression gets deleted.

Conclusion, we need to make sure we don't create new gdbarch objects
when we don't need to (well obviously) and to do this we need to make
sure that we reuse target descriptions.

This is still running through testing at my end, so far its looking
good, but I thought I'd share in case you also wanted to test.

Thanks,
Andrew


---

Andrew Burgess (4):
  gdb/riscv: Make some target description functions constant
  gdb/riscv: Add equality operators to riscv_gdb_features
  gdb/riscv: Create each unique target description only once
  gdb/riscv: Add read_description method for riscv_linux_nat_target

 gdb/ChangeLog         | 27 +++++++++++++++++++++++
 gdb/arch/riscv.c      | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 gdb/arch/riscv.h      | 15 ++++++++++++-
 gdb/riscv-linux-nat.c | 38 +++++++++++++++++++++++++++++++++
 gdb/riscv-tdep.c      |  6 ++----
 5 files changed, 139 insertions(+), 6 deletions(-)

-- 
2.14.5


  parent reply	other threads:[~2018-11-29 16:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-28 22:50 [RFC] " Andrew Burgess
2018-11-28 23:37 ` Jim Wilson
2018-11-29  2:23 ` Jim Wilson
2018-11-29 16:50   ` [PATCH 1/4] gdb/riscv: Make some target description functions constant Andrew Burgess
2018-11-29 16:50   ` Andrew Burgess [this message]
2018-11-29 16:50   ` [PATCH 4/4] gdb/riscv: Add read_description method for riscv_linux_nat_target Andrew Burgess
2018-11-29 22:22     ` Jim Wilson
2018-11-29 16:50   ` [PATCH 2/4] gdb/riscv: Add equality operators to riscv_gdb_features Andrew Burgess
2018-11-29 16:50   ` [PATCH 3/4] gdb/riscv: Create each unique target description only once Andrew Burgess
2018-11-29 18:12     ` Pedro Alves
2018-11-29 19:17       ` Andrew Burgess
2018-11-29 22:32       ` Andrew Burgess
2018-11-30 17:07         ` Pedro Alves

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=cover.1543509416.git.andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@FreeBSD.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