public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Joel Brobecker <brobecker@adacore.com>, gdb@sourceware.org
Subject: Re: GDB 7.4.91 available for testing
Date: Fri, 20 Jul 2012 20:49:00 -0000	[thread overview]
Message-ID: <1342817409.2149.41.camel@soleil> (raw)
In-Reply-To: <20120720071158.GA7053@host2.jankratochvil.net>

On Fri, 2012-07-20 at 09:11 +0200, Jan Kratochvil wrote:
> On Fri, 20 Jul 2012 01:03:36 +0200, Philippe Waroquiers wrote:
> > The Valgrind gdbserver is handling Z0 and Z1 packets to insert
> > breakpoints. So, GDB inserts a breakpoint on the stack using
> > a Z0 packet. However, from what I can see, no 0xcc instruction
> > has been written on the stack by GDB.
> 
> The Z0 packet instructs gdbserver to put 0xcc there,
> linux-x86-low.c:x86_breakpoint.  gdbserver does it.
Thanks for the clarification.
I now understand that my expectation to have GDB writing 0xCC was quite
wrong: if GDB would be responsible to write 0xCC, then why would a Z0
packet be needed ?

Note that I am wondering how this ON_STACK technique works.
E.g. on gcc20, readelf -a indicates the GNU_STACK is RW, but not E or X
or similar.

In any case, with this better understanding, I see no other solution
than to have the Valgrind gdbserver writing a breakpoint instruction
at the Z0 provided address (even if with the current technique Valgrind
gdbserver uses to implement breakpoints, this instruction will in fact
never be executed but only translated).

The tricky part will be to guess that a breakpoint is for the
'return address for an inferior call', as Valgrind is not expected
(or allowed) to modify the code sections of the guest client being
executed.

For this guess, I am thinking to use the following conditions:
    1. the stack pointer in the register cache has been changed
       to grow the stack
  and
    2. the breakpoint address is in this "grown zone" 

Comments/feedback on the above ?

Thanks

Philippe


  reply	other threads:[~2012-07-20 20:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 16:34 Joel Brobecker
2012-07-19 13:44 ` Mike Frysinger
2012-07-19 23:02 ` Philippe Waroquiers
2012-07-20  7:12   ` Jan Kratochvil
2012-07-20 20:49     ` Philippe Waroquiers [this message]
2012-07-22 17:31       ` Jan Kratochvil
2012-07-22 19:01         ` Philippe Waroquiers
2012-07-23  7:23           ` Jan Kratochvil

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=1342817409.2149.41.camel@soleil \
    --to=philippe.waroquiers@skynet.be \
    --cc=brobecker@adacore.com \
    --cc=gdb@sourceware.org \
    --cc=jan.kratochvil@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).