Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Randolph Chung <randolph@tausq.org>
To: gdb-patches@sources.redhat.com
Subject: Re: [rfc] dummy calls for hppa64-hpux
Date: Fri, 10 Dec 2004 19:04:00 -0000	[thread overview]
Message-ID: <20041210180102.GX29171@tausq.org> (raw)
In-Reply-To: <20041209050558.GD29171@tausq.org>

In reference to a message from Randolph Chung, dated Dec 08:
> this patch is not yet ready for inclusion, i'm only posting it for
> comments because it's rather unorthodox.

ok, here's another unfinished idea..... Dave Anglin suggested an
alternative scheme to me that seems more robust.  I haven't written the
code for it yet, but here's a 50-line comment to explain it. Comments
before i try it? :)


   /* In order to make an interspace call, we need to go through a stub.
      gcc supplies an appropriate stub called "__gcc_plt_call", however, if
      an application is compiled with HP compilers then this stub is not
      available.  We used to fallback to "__d_plt_call", however that stub
      is not entirely useful for us because it doesn't do an interspace
      return back to the caller.  In order to keep the code uniform, we
      instead don't use either of these stubs, but instead write our own
      onto the stack.

      A problem arises since the stack is located in a different space than
      code, so in order to branch to a stack stub, we will need to do an
      interspace branch.  Previous versions of gdb did this by modifying code
      at the current pc and doing single-stepping to set the pcsq.  Since this
      is highly undesirable, we use a different scheme:

      All we really need to do the branch to the stub is a short instruction
      sequence like this:

      PA1.1:
                ldsid (rX),r1
                mtsp r1,sr0
                be,n (sr0,rX)

      PA2.0:
                bve,n (sr0,rX)

      Instead of writing these sequences ourselves, we can find it in
      the instruction stream that belongs to the current space.  While this
      seems difficult at first, we are actually guaranteed to find the sequences
      in several places:

      - in export stubs for shared libraries
      - For 32-bit code, in the "noshlibs" routine in the main module
      - For 64-bit code, in the "$START$" routine in the main module

      (Note that we can cache the address of these sequences in
      the objfile's private data.)

      So, what we do is:
      - write a stack trampoline
      - look for a suitable instruction sequence in the current space
      - point the sequence at the trampoline
      - set the return address of the trampoline to the current instruction (*)
      - set the continuing address of the "dummy code" as the sequence.

      (*) An additional twist is that, in order for us to restore the space
      register to its starting state, we need the trampoline to return
      to the instruction where we started the call.  However, if we put
      the breakpoint there, gdb will complain because it will find two
      frames on the stack with the same (sp, pc) (with the dummy frame in
      between).  Currently, we set the return pointer to (pc - 4) of the
      current function.  FIXME: This is not an ideal solution; possibly if the
      current pc is at the beginning of a page, this will cause a page fault.
      Need to understand this better and figure out a better way to fix it.  */

Is this better? :)

randolph
-- 
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/


  reply	other threads:[~2004-12-10 18:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-09 13:31 Randolph Chung
2004-12-10 19:04 ` Randolph Chung [this message]
2004-12-10 21:35   ` Daniel Jacobowitz

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=20041210180102.GX29171@tausq.org \
    --to=randolph@tausq.org \
    --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