Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@redhat.com>
To: "Nathan J. Williams" <nathanw@wasabisystems.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: RFA: assert that target_fetch_registers did its job
Date: Fri, 06 Aug 2004 23:43:00 -0000	[thread overview]
Message-ID: <vt2llgrrg22.fsf@zenia.home> (raw)
In-Reply-To: <mtuy8ks9ej3.fsf@contents-vnder-pressvre.mit.edu>

"Nathan J. Williams" <nathanw@wasabisystems.com> writes:

> Jim Blandy <jimb@redhat.com> writes:
> 
> > Does anyone see anything wrong with this?  Should it be an error, or a
> > warning, instead of an internal error?  It seems to me that the error
> > should be furnished by the target-specific code; if
> > target_fetch_registers returns silently, it should have done its job.
> 
> I noticed that "info reg" tripped over this with the BSD KVM target,
> because the KVM backend only loads in the registers that are present
> in the PCB. Should the KVM backend be zeroing out everything else
> explicitly (is there a regcache call to do the wipe for us)?

Silently supplying dummy register contents is confusing to developers
and users.  That just seems uncool.

There's no way to return an 'unavailable' indication from the regcache
cooked read functions.  And there are so many clients of that
interface it might be hard to introduce such an indication.  (Although
most of the uses are in -tdep.c files; the only real use in core code
is in sentinal_frame_prev_register, which does have a way to return
'unavailable'.  Hmm.)

Throwing an error would interrupt the register listing, even if later
registers were available.

So that leaves printing a warning message and supplying a dummy
value.  

Perhaps another option would be something like the below: it informs
users that things are not as they seem, and encourages developers to
fix up their targets.  Comments?


2004-08-06  Jim Blandy  <jimb@redhat.com>

	* regcache.c (regcache_raw_read): Replace assertion with a warning
	message.

Index: gdb/regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.125
diff -c -p -r1.125 regcache.c
*** gdb/regcache.c	4 Aug 2004 17:50:55 -0000	1.125
--- gdb/regcache.c	6 Aug 2004 23:42:56 -0000
*************** regcache_raw_read (struct regcache *regc
*** 614,620 ****
  	}
        if (!register_cached (regnum))
  	target_fetch_registers (regnum);
!       gdb_assert (register_cached (regnum));
      }
    /* Copy the value directly into the register cache.  */
    memcpy (buf, register_buffer (regcache, regnum),
--- 614,649 ----
  	}
        if (!register_cached (regnum))
  	target_fetch_registers (regnum);
! 
!       /* FIXME: jimb/2004-08-06: Ideally, this would just be an
!          assert: target_fetch_registers should either throw an error,
!          or print a warning and furnish dummy register contents.  But
!          it should never say "okay" without actually supplying the
!          register.
! 
!          But in reality, there are a lot of arch / target combinations
!          where the arch's regset has grown beyond what the target
!          actually supplies.  Having GDB crash is too disruptive, but
!          silently using uninitialized bits is misleading as well.
! 
!          So this warning is here to prompt people to work on their
!          targets and get the mismatches sorted out, and to warn users
!          that they're not getting real data.  */
!       if (! register_cached (regnum))
!         {
!           struct gdbarch *arch = get_regcache_arch (regcache);
!           const char *name = gdbarch_register_name (arch, regnum);
! 
!           if (name)
!             warning ("unable to retrieve contents of raw register '%s' (#%d).",
!                      name, regnum);
!           else
!             warning ("unable to retrieve contents of raw register #%d.",
!                      regnum);
! 
!           memset (register_buffer (regcache, regnum), 0xff,
!                   regcache->descr->sizeof_register[regnum]);
!         }
      }
    /* Copy the value directly into the register cache.  */
    memcpy (buf, register_buffer (regcache, regnum),


  reply	other threads:[~2004-08-06 23:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-23 23:00 Jim Blandy
2004-07-24  0:45 ` Daniel Jacobowitz
2004-08-03 14:23   ` Andrew Cagney
2004-08-07 18:42     ` Daniel Jacobowitz
2004-08-07 18:54       ` Andrew Cagney
2004-08-04 17:51   ` Jim Blandy
2004-08-06 20:50 ` Nathan J. Williams
2004-08-06 23:43   ` Jim Blandy [this message]
2004-08-07  1:47     ` Ian Lance Taylor
2004-08-07 16:13       ` Andrew Cagney
2004-08-07 18:31         ` Jim Blandy

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=vt2llgrrg22.fsf@zenia.home \
    --to=jimb@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=nathanw@wasabisystems.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