Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Greg Law <glaw@undo-software.com>
To: gdb-patches@sourceware.org
Subject: Re: SIGSEGV on gdb 6.7*
Date: Mon, 04 Feb 2008 21:39:00 -0000	[thread overview]
Message-ID: <47A785DB.7010108@undo-software.com> (raw)
In-Reply-To: <20080204210333.GA23250@caradoc.them.org>

Daniel Jacobowitz wrote:
> On Mon, Feb 04, 2008 at 08:49:48PM +0000, Greg Law wrote:
>> yet there appear to be pointers to the regcache squirrelled away in  
>> various other places, notably the prologue_cache member of the 
>> frame_info structure.
>
> Could you give a specific example?  I don't think there should be such
> pointers.

When a register is examined, we (eventually) get to frame_register_unwind.  
This does:

frame->unwind->prev_register (frame->next, &frame->prologue_cache, regnum,
                optimizedp, lvalp, addrp, realnump, bufferp);

which is actually a function pointer to (on plain old x86 Linux) 
sentinel_frame_prev_register, which goes:

static void
sentinel_frame_prev_register (struct frame_info *next_frame,
                  void **this_prologue_cache,
                  int regnum, int *optimized,
                  enum lval_type *lvalp, CORE_ADDR *addrp,
                  int *realnum, gdb_byte *bufferp)
{
 struct frame_unwind_cache *cache = *this_prologue_cache;
 /* Describe the register's location.  A reg-frame maps all registers
    onto the corresponding hardware register.  */
 *optimized = 0;
 *lvalp = lval_register;
 *addrp = register_offset_hack (current_gdbarch, regnum);
 *realnum = regnum;

 /* If needed, find and return the value of the register.  */
 if (bufferp != NULL)
   {
     /* Return the actual value.  */
     /* Use the regcache_cooked_read() method so that it, on the fly,
        constructs either a raw or pseudo register from the raw
        register cache.  */
     regcache_cooked_read (cache->regcache, regnum, bufferp);
   }
}

note the first line which is an assignment to 'cache' from
*this_prologue_cache.  The regcache_cooked_read is called, passing 
cache->regcache.  If flushregs has been called, the regcache appears 
to be garbage.  If I've not got myself terribly confused, this is 
not especially surprising, since we freed the regcache at
registers_changed(), leaving the frame_info structure pointing at
invalid memory.

>
>> I guess this might result in some "unnecessary" fetches of the register  
>> state, but that has to be favourable to a SEGV :)
>
> Not really - we go to a lot of trouble to avoid this.

Yeah, I guess this more important on remote targets over slow links, 
right?  In that case, do we not need to take care from 
registers_changed() to go and invalidate all the pointers to cached 
registers in the frame structures?  Hmm, although thinking about it 
now, I guess the frame structures all need throwing away/recalculating 
if the registers have changed anyway?  I can't find what causes that 
to happen though.

g


  reply	other threads:[~2008-02-04 21:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-04 20:50 Greg Law
2008-02-04 21:04 ` Daniel Jacobowitz
2008-02-04 21:39   ` Greg Law [this message]
     [not found]   ` <47A7850B.10202@undo-software.com>
2008-02-04 21:45     ` Daniel Jacobowitz
2008-02-04 21:59       ` Greg Law
2008-02-04 22:11         ` Daniel Jacobowitz
2008-02-04 22:36           ` Greg Law
2008-02-11 20:59             ` Greg Law
2008-02-26 23:00 ` Michael Snyder
2008-02-27  0:37   ` Daniel Jacobowitz
2008-02-27  0:43     ` Michael Snyder
2008-02-27  0:51       ` Daniel Jacobowitz
2008-02-27  0:54         ` Michael Snyder
2008-02-27  1:05           ` Daniel Jacobowitz
2008-02-27  1:08             ` Michael Snyder
2008-02-27 20:23               ` Greg Law
2008-02-28  7:46                 ` Vladimir Prus
2008-02-28 14:17                   ` Thiago Jung Bauermann
2008-02-28 16:18                     ` Daniel Jacobowitz
2008-02-28 14:17                   ` Daniel Jacobowitz
2008-03-04 20:09               ` Joel Brobecker

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=47A785DB.7010108@undo-software.com \
    --to=glaw@undo-software.com \
    --cc=gdb-patches@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