Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Luis Machado <lgustavo@codesourcery.com>
To: Tom Tromey <tromey@redhat.com>
Cc: "gdb@sourceware.org" <gdb@sourceware.org>,
	 "Maciej W. Rozycki" <macro@codesourcery.com>
Subject: Re: Unreliable BFD caching heuristic
Date: Tue, 03 Dec 2013 15:28:00 -0000	[thread overview]
Message-ID: <529DF865.2070104@codesourcery.com> (raw)
In-Reply-To: <87a9gjw97b.fsf@fleche.redhat.com>

On 12/02/2013 01:42 PM, Tom Tromey wrote:
>>>>>> "Luis" == Luis Machado <lgustavo@codesourcery.com> writes:
>
> Luis> If all those things happen at the same time, the BFD machinery will
> Luis> attempt to use a cached entry to load data from a totally new
> Luis> binary. From that point onwards, things just go downhill.
>
> Luis> This is really a regression compared to older GDB's, and a solution
> Luis> probably involves improving the matching heuristics, in
> Luis> gdb/gdb_bfd.c:eq_bfd, with more data.
>
> Another idea occurred to me recently, which is that gdb could use
> inotify to notice when a file is changed.  However this only works on
> some limited set of hosts.  It's probably overkill as well.
>
> There's actually a second problem here: the BFD file descriptor cache
> (see bfd/cache.c).  Sometimes gdb closes all the file descriptors in
> this cache, and BFD will reopen them without considering whether the
> file has changed.  So, it is probably possible to construct test cases
> that fail even with older versions of gdb.

It seems to be the case. That will need to be fixed eventually.

>
> Even on Linux I think gdb sometimes needs to close the file descriptors
> -- e.g., when "set write on" is in effect, "run" needs to close them to
> avoid ETXTBSY.  I'm not sure how to solve this.
>
> Yet another idea lurking in here is that if a file does change, we
> should probably disable trust-readonly-sections for it.

Right. For now, it seems the ELF headers provide enough information to 
tell two different files apart.

The problem there is that we need to open the BFD and read some of its 
data, which in turn requires us to detect architecture size and 
endianness. Only then we will be able to see if we are dealing with two 
different files.

I did an experiment with using the inode number in the cache check. It 
seems to work for the hosts that support that information. On Windows i 
think we fake inode numbers based on the file name and timestamp, so it 
could be a simpler solution.

Luis


  reply	other threads:[~2013-12-03 15:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-21 17:39 Luis Machado
2013-11-21 17:58 ` Pedro Alves
2013-11-21 21:58   ` Tom Tromey
2013-11-23 12:14     ` Phi Debian
2013-11-25 17:45   ` Luis Machado
2013-11-25 18:07     ` Pedro Alves
2013-11-25 18:08     ` Maciej W. Rozycki
2013-11-25 18:21     ` Pedro Alves
2013-12-02 15:42 ` Tom Tromey
2013-12-03 15:28   ` Luis Machado [this message]
     [not found]     ` <CAC=yr6DRDsRLStnDNZW_2=0vOQY-oJHd55_nLUeb8Qetxo=yXw@mail.gmail.com>
2013-12-04  0:01       ` Luis Machado
2013-12-04  3:47         ` Eli Zaretskii
2013-12-04 15:54           ` Tom Tromey

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=529DF865.2070104@codesourcery.com \
    --to=lgustavo@codesourcery.com \
    --cc=gdb@sourceware.org \
    --cc=macro@codesourcery.com \
    --cc=tromey@redhat.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