Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Cc: Joel Brobecker <brobecker@adacore.com>,
	gdb@sourceware.org,        Pedro Alves <palves@redhat.com>
Subject: Re: GDB 7.4.91 available for testing
Date: Sun, 22 Jul 2012 17:31:00 -0000	[thread overview]
Message-ID: <20120722173053.GA22036@host2.jankratochvil.net> (raw)
In-Reply-To: <1342817409.2149.41.camel@soleil>

On Fri, 20 Jul 2012 22:50:09 +0200, Philippe Waroquiers wrote:
> 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.

Then it may be for example SIGSEGV instead of SIGTRAP but GDB recognizes any
such trap on breakpoint address as a breakpoint hit.


> 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.

As Z0 should insert the 0xcc instruction this issue of never-modified inferior
memory needs to be resolved anyway:

(gdb) monitor help
general valgrind monitor commands:
[...]
(gdb) maintenance info breakpoints 
Num     Type           Disp Enb Address            What
-1      shlib events   keep n   0x0000000004003702 <dl_main+6562> inf 1
-2      shlib events   keep y   0x0000000004003f92 <dl_main+8754> inf 1
[...]
(gdb) set debug remote 1
(gdb) stepi
Sending packet: $Z0,4003f92,1#ab...Packet received: OK
Packet Z0 (software-breakpoint) is supported
[...]
(gdb) show remote Z-packet 
Support for the `Z0' packet is auto-detected, currently enabled.

Maybe it would be enough to treat Z0 packets like Z1 (hardware-breakpoint)
packets?  The valgrind simulator should be able to trap on specified
addresses, shouldn't it?

I am not aware how make GDB to automatically use Z1 packets but I do not have
an idea why it would hurt if Z0 packets behave like Z1 ones.  Just report (on
x86*) PC+1 for SIGTRAP during the breakpoint hit.


> 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" 

With current default 'set breakpoint always-inserted auto' (acting like 'off')
GDB continually removes and re-inserts all the breakpoints.  The "grow" check
will not work on breakpoint re-insertions.


Thanks,
Jan


  reply	other threads:[~2012-07-22 17:31 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
2012-07-22 17:31       ` Jan Kratochvil [this message]
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=20120722173053.GA22036@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb@sourceware.org \
    --cc=palves@redhat.com \
    --cc=philippe.waroquiers@skynet.be \
    /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