Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@cygnus.com>
To: Andrew Cagney <ac131313@cygnus.com>, Eli Zaretskii <eliz@is.elta.co.il>
Cc: Naushit_Sakarvadia@quintum.com, gdb@sources.redhat.com
Subject: Re: 8 bit read
Date: Thu, 26 Jul 2001 09:20:00 -0000	[thread overview]
Message-ID: <1010726161854.ZM24609@ocotillo.lan> (raw)
In-Reply-To: <Pine.SUN.3.91.1010726163652.1520C-100000@is>

On Jul 26,  4:45pm, Eli Zaretskii wrote:

> On Thu, 26 Jul 2001, Andrew Cagney wrote:
> 
> > > No, because CORE_ADDR is not wide enough to engulf both.  Making
> > > CORE_ADDR wider is something I'd prefer to avoid, since it will affect
> > > Binutils as well.
> > 
> > What Kevin is suggesting here is, from GDB's point of view, the correct 
> > approach.  A CORE_ADDR is a cannonical address - any pointer expression 
> > is converted to that cannonical value.  On the x86, it could carry an 
> > indication that the offset part belongs to either code, I/O, .. space.
> 
> The problem is, I don't have enough bits in CORE_ADDR to include those 
> indications.

I think if you review the mailing list archives, you'll find that more
than one person has suggested turning CORE_ADDR into a struct.  What
would such a struct look like?  Maybe something like this:

    struct core_addr
      {
        bfd_vma addr;		/* what we have now...  */
	int addr_space;		/* address space selector */
				/* maybe this should be an enum?  */
      };
    typedef struct core_addr CORE_ADDR;

(I'm sure we can think of better names for the members, but you get
the idea.)

I we take such a step, there'll be a fair chunk of code which won't
really notice the difference.  Such code performs no real manipulation
of a CORE_ADDR, it either stashes the value away and/or passes it on
to somewhere else.

The code that's going to be affected is that in which a constant is
added to or subtracted from a CORE_ADDR.  (There's some masking that
goes on too sometimes.)  For these, we'll need a constructor.  I.e,
something like the following...

    CORE_ADDR pc = read_pc ();
    ...
    pc = pc + 4;		/* Advance pc to next instruction.  */
    
might become...

    CORE_ADDR pc = read_pc ();
    ...
    pc = core_addr_add_int (pc, 4);
				/* Advance pc to next instruction.  */

where core_addr_add_int() has the obvious definition...

    CORE_ADDR
    core_addr_add_int (CORE_ADDR addr, int offset)
    {
      CORE_ADDR retval;

      retval.addr_space = addr.addr_space;
      retval.addr = addr.addr + offset;

      return retval;
    }

The nice thing about all of this is that a core_addr_add_core_addr()
could be made to internal_error() when attempting to add incompatible
addresses.  (As it is, our Harvard architecture implementations won't
care if you try to add a data address to a code address.  Doing so
probably represents a programming error though.)

Kevin


  parent reply	other threads:[~2001-07-26  9:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-23  9:04 Naushit Sakarvadia
2001-07-23  9:56 ` Daniel Jacobowitz
2001-07-23 11:50 ` Andrew Cagney
2001-07-24  4:49   ` Eli Zaretskii
2001-07-24  9:25     ` Kevin Buettner
2001-07-24 11:11       ` Eli Zaretskii
2001-07-24 14:11         ` Kevin Buettner
2001-07-25  1:45           ` Eli Zaretskii
2001-07-25 11:40             ` Kevin Buettner
2001-07-25 23:39               ` Eli Zaretskii
2001-07-26  6:17                 ` Andrew Cagney
2001-07-26  6:45                   ` Eli Zaretskii
2001-07-26  6:53                     ` Andrew Cagney
2001-07-26  6:59                       ` Eli Zaretskii
2001-07-26  7:09                         ` Andrew Cagney
2001-07-26  7:01                     ` Andrew Cagney
2001-07-26  9:20                     ` Kevin Buettner [this message]
2001-07-26  9:25                       ` Eli Zaretskii

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=1010726161854.ZM24609@ocotillo.lan \
    --to=kevinb@cygnus.com \
    --cc=Naushit_Sakarvadia@quintum.com \
    --cc=ac131313@cygnus.com \
    --cc=eliz@is.elta.co.il \
    --cc=gdb@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