public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: qiyaoltc@gmail.com (Yao Qi)
Cc: qiyaoltc@gmail.com (Yao Qi), cole945@gmail.com (Wei-cheng Wang),
	       gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2 v2] Re-check fastpoint after reloading symbols.
Date: Wed, 16 Sep 2015 12:41:00 -0000	[thread overview]
Message-ID: <20150916124125.CEEDA1DA8@oc7340732750.ibm.com> (raw)
In-Reply-To: <8637ye3go8.fsf@gmail.com> from "Yao Qi" at Sep 16, 2015 09:35:35 AM

Yao Qi wrote:
> "Ulrich Weigand" <uweigand@de.ibm.com> writes:
> 
> > I guess I'm not really sure what the difference is between checks
> > "using GDBserver internal knowledge" and those that don't.  Doesn't
> > the x86 check, strictly speaking, also use GDBserver internal knowlegde,
> > i.e. it knows which instruction GDBserver attempts to place at the
> > tracepoint location, and therefore knows how much space must be
> > available there?
> 
> It is different when GDB talks with some debugging stubs other than
> GDBserver, which support tracepoint too.  It is OK that GDB checks fast
> tracepoint's validity according to GDB's own knowledge, such as
> instruction size.  That is what x86 does nowadays.  However, GDB can't
> check validity by checking whether it is too far to jump to the jumppad
> from the tracepoint address.  Jumppad address is unknown to GDB, and
> other debugging stub may allocate jumppad differently.  PPC GDB
> tracepoint do checks in this way, which isn't right to me.

I understand simply measuring how much space is *available* does not
require any GDBserver knowledge.  But how much space is *required*
does depend on the agent implementation.  However, what I missed is
that this fact is actually retrieved from the target using a special
target_get_min_fast_tracepoint_insn_len callback.

So you're right that the current x86 implementation does not rely on
agent implentation details in GDB.  I guess we could do something
similar for ppc64 by adding a new remote protocol command to verify
whether a tracepoint address is valid.  (This could in fact supersede
the target_get_min_fast_tracepoint_insn_len callback then.)

But I guess I'd still prefer to do it this way, to avoid needing
two packet round trips for each tracepoint:

> > That's why I am now wondering whether the best fix shouldn't be to
> > simply remove the GDB-side check completely, even on x86, and solely
> > rely on GDBserver reporting errors via the remote protocol ...
> 
> It is fine with me to move validity checks to GDBserver side, but we
> need to add some thing to decode x86 instructions and get to know
> instruction length.  Nowadays, we are using gdb_print_insn which
> calls some function in opcodes in GDB side, but it doesn't exist
> in GDBserver side.

That's true, but this information is computed by GDB and passed to
the remote agent via the orig_size field of the tracepoint packet
anyway, see this piece of code in remote_download_tracepoint:

    xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":F%x",
               gdb_insn_length (loc->gdbarch, tpaddr));

So the remote agent doesn't actually need to compute it again.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com

      reply	other threads:[~2015-09-16 12:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-01 18:25 Wei-cheng Wang
2015-09-02 15:51 ` Yao Qi
     [not found]   ` <CAPmZyH61j2ECFu7vcg6ZAyhJWNGHpUHk60fOfkXG5qb9M-5pFA@mail.gmail.com>
2015-09-12 18:01     ` Wei-cheng Wang
2015-09-14 12:20       ` Ulrich Weigand
2015-09-14 15:34         ` Yao Qi
2015-09-15 16:22           ` Ulrich Weigand
2015-09-16  8:35             ` Yao Qi
2015-09-16 12:41               ` Ulrich Weigand [this message]

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=20150916124125.CEEDA1DA8@oc7340732750.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=cole945@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).