Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@redhat.com>
To: Andrew Cagney <ac131313@cygnus.com>
Cc: Kevin Buettner <kevinb@redhat.com>, gdb@sources.redhat.com
Subject: Re: [rfc] ``pc'' -> resume_addr?
Date: Thu, 11 Apr 2002 17:34:00 -0000	[thread overview]
Message-ID: <3CB628D0.8DC57F22@redhat.com> (raw)
In-Reply-To: <3CB60B21.10407@cygnus.com>

Andrew Cagney wrote:
> 
> > On Apr 11,  4:38pm, Andrew Cagney wrote:
> >
> >
> >> GDB, in a number of places, refers to the ``pc'' - PC_REGNUM, frame->pc,
> >> read_pc(), write_pc(), ...
> >>
> >> I think this name choice was unfortunate.  It is too easy for a
> >> developer to confuse ``pc'' with the hardware ``pc''.
> >
> >
> > Could you please explain further why you think the name choice was
> > unfortunate?
> 
> I think the name ``pc'' brings with it a certain amount of baggage.
> When reading a piece of code, it isn't clear if the hardware ``pc''
> (possibly needing adjustment) or the program's resume address is being used.

When are they not the same?

> On an x86, and m68k, for instance, the hardware PC may or may not need
> to be adjusted (decr_pc_after_break()) before it becomes a frame->pc.

Yeah -- but this is done almost immediately after the target stops.
Past that point, the hardware pc _is_ equal to the address at which
execution will resume.  Before that point, we haven't really built
or used very many of these objects called 'pc' or 'something->pc'.
Have we?


> Within the frame, the ``pc'' designates ``resume'' address of the
> function.  Knowing this is important when understanding why some of the
> frame code does:
> 
>         if (frame->next != NULL)
>           return frame->pc - 1;
>         else
>           return frame->pc;

Uggh.  Where does THAT code come from?   ;-)

> >> With this in mind, I'd like to propose a GDBspeak ``resume_addr''.  It
> >> is the address of the first instruction that will be executed when the
> >> target resumes.
> >
> >
> > So, if I understand you correctly, you're suggesting the following
> > renaming:
> >
> >     PC_REGNUM ==> RESUME_ADDR_REGNUM
> 
> This wouldn't change.  If the hardware has a ``PC'' like register then
> likely the maintainer will retain ``PC_REGNUM'' / $pc as an alias for it.
> 
> >     frame->pc ==> frame->resume_addr
> 
> This, I think, should change.  I'm 99% sure that this isn't the hardware
> PC but rather the continue address for the frame (but notice I'm not
> 100% sure thanks to its poor definition).

OK, but in that context, it's supposed to be understood that 
the data structure "frame" contains values for the registers
in that frame's context -- not the actual hardware registers.
They're all saved values -- not just the pc.


> >     read_pc() ==> read_resume_addr()
> 
> This one is harder.  Perhaphs it can be eliminated.
> 
> >     write_pc()        ==> write_resume_addr()
> 
> Check the default implementation.  It not only modifies PC, but also NPC
> and even NNPC.  I think this function should be called something like -
> set_resume_address()?

I can see that ...


> Remember, when making an inferior function call, GDB does not set the
> PC.  Rather it sets the resume/continue address using the debug info.
> For instance, on the sparc, it sets:
> 
>         [PC] = resume_addr;
>         [NPC] = resume_addr + 4;
> 
> This behavour is very different to what the user is trying to achieve if
> they enter:
> 
>         (gdb) jump *foo *bar
> 
> On a sparc, that would execute:
> 
>         *foo
>         *bar
>         *(bar + 4)
>         *(bar + 8)

Whoa, you lost me.  The "jump" command only accepts one argument.
What does "jump *foo *bar" mean?

> > Perhaps I've just gotten fond of ``pc'', but I don't really like any
> > of these.
> 
> If someone uses PC in a typical e-mail, we'll know what they mean.
> However, if someone uses PC when refering to GDB's internals, I don't
> know that we'll be as sure.
> 
> enjoy,
> Andrew


  parent reply	other threads:[~2002-04-12  0:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-11 13:38 Andrew Cagney
2002-04-11 13:58 ` Kevin Buettner
2002-04-11 15:15   ` Andrew Cagney
2002-04-11 16:35     ` Andrew Cagney
2002-04-11 16:48       ` Kevin Buettner
2002-04-11 17:08         ` Andrew Cagney
2002-04-11 17:37       ` Michael Snyder
2002-04-11 16:42     ` Kevin Buettner
2002-04-11 17:39       ` Michael Snyder
2002-04-11 17:34     ` Michael Snyder [this message]
2002-04-12  8:59       ` Andrew Cagney
2002-04-13 20:21         ` Andrew Cagney
2002-04-11 17:25 ` Michael Snyder
2002-04-26  8:09 ` 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=3CB628D0.8DC57F22@redhat.com \
    --to=msnyder@redhat.com \
    --cc=ac131313@cygnus.com \
    --cc=gdb@sources.redhat.com \
    --cc=kevinb@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