Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <ac131313@cygnus.com>
To: gdb-patches@sources.redhat.com
Subject: read_register_bytes() bug; was my Regcache revamp
Date: Sat, 18 Aug 2001 11:08:00 -0000	[thread overview]
Message-ID: <3B7EAF09.4010801@cygnus.com> (raw)

To quote my original e-mail:

http://sources.redhat.com/ml/gdb-patches/2001-03/msg00312.htm

 > Hello,
 >
 > This patch may change your life!
 >
 > Well, yes, ok, I'm probably being a little dramatic!  However, it
 > certainly does change the way targets implement pseudo/cooked registers.
 >
 > The attatched patch revamps the regcache interface along the lines
 > described in:


Well its taken 5 months but I've finaly found a ``bug'' this change
introduces.

The old read_register_bytes() had the logic (greatly simplified):

	o	go through all registers
		and read each valid (as defined
		by REGISTER_NAME()) register
		into the cache

	o	copy out the relevant raw bytes
		from the register buffer

the new code combined those two:

	o	go through all registers
		if valid (as defined by REGISTER_NAME())
			read the register into the cache
			write the register into the buffer

The problem is that the register cache can have ``holes'' in it.  An
invalid/ignore/dne REGNUM, as determined from REGISTER_NAME(), can still
occupy space in the register buffer.  The old code was blindly copying
the contents of the holes.  The new code, skips them, leaving them
undefined - typically picking up garbage from the heap.

This shouldn't hurt since the holes are invalid/ignored/dne/... right?
Nope, a target was getting that ``invalid data'' and then using it - the
corresponding write_register_bytes() doesn't skip invalid/ignore/dne
REGNUMs.

I think the ``real bug'' is that the updated read_register_bytes() can
leave part of the buffer undefined.  I'm thinking of either changing
things to:

	o	initializing the gaps from
		the regcache (restoring old
		behavour)

	o	initializing the gaps with
		0xdeadbeaf.

I am very tempted to implement the latter but suspect I'll be forced to
implement the former, Sigh!

	Andrew


             reply	other threads:[~2001-08-18 11:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-18 11:08 Andrew Cagney [this message]
2001-08-18 14:04 ` [rfc] " Andrew Cagney
     [not found]   ` <9743-Sun19Aug2001093055+0300-eliz@is.elta.co.il>
2001-08-21  6:53     ` What is on the 5.1 branch; Was: " Andrew Cagney
2001-08-19 23:10       ` Eli Zaretskii
2001-08-19 23:16         ` Daniel Jacobowitz
2001-08-20  2:09           ` Eli Zaretskii
2001-08-20 15:07             ` Mark Kettenis
2001-08-20 23:43               ` Eli Zaretskii
2001-08-21  8:17                 ` Andrew Cagney
2001-08-21  9:23                   ` Eli Zaretskii
2001-08-21  6:52             ` Andrew Cagney
2001-08-21  6:52           ` Kevin Buettner
2001-08-21  6:53         ` Andrew Cagney

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=3B7EAF09.4010801@cygnus.com \
    --to=ac131313@cygnus.com \
    --cc=gdb-patches@sources.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