public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb@sourceware.org
Subject: Re: GDB 7.4.91 available for testing
Date: Thu, 19 Jul 2012 23:02:00 -0000	[thread overview]
Message-ID: <1342739016.2220.32.camel@soleil> (raw)
In-Reply-To: <20120718163413.GA17548@adacore.com>

On Wed, 2012-07-18 at 09:34 -0700, Joel Brobecker wrote:
> Hello,
> 
> I have just finished creating the gdb-7.4.91 pre-release.
> It is available for download at the following location:
> 
>     ftp://sourceware.org/pub/gdb/snapshots/branch/gdb-7.4.91.tar.bz2
> 
> A gzip'ed version is also available: gdb-7.4.91.tar.gz.
> 
> Please give it a test if you can and report any problems you might find.

The new version causes a regression with the Valgrind gdbserver.

At least on x86 and on amd64, the Valgrind regression tests for
inferior calls in the Valgrind gdbserver are failing as
Valgrind reports errors such as:
vex x86->IR: unhandled instruction bytes: 0xF 0x21 0x0 0xC0.
(inferior calls are working with GDB 7.4).

I believe this difference is caused by the fact that infcall.c
has switched from AT_ENTRY_POINT to ON_STACK technique for the
breakpoint for the fake return address of the pushed function call.

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.

When a function call returns, Valgrind translates and instrument
(if not yet done) the instructions at the return address.
(if there is a break at this address, the instrumented code
will start with a call to a Valgrind helper function which reports
the breakpoint to GDB and reads remote protocol packets).

In case of the fake return address on the stack, I believe no
instruction was effectively written by GDB (i.e. no 0xcc was written).
So, when the return instruction of the pushed fn call is executed,
Valgrind tries to translate and instrument what is on the stack at
the return address, and then finds whatever random or invalid
instruction bytes and then reports the above error.

I do not see a clean/easy way to solve this problem.
The only way I see (quite ugly, machine dependent, ...) will be for
Valgrind gdbserver to guess that a breakpoint on the stack
(when the stack was just increased before by changing sp) implies
to write a valid dummy instruction on the stack to allow
the Valgrind translator to work properly.
It is not yet clear how to implement the above guess properly,
and I do not like the idea to have Valgrind gdbserver writing
itself dummy or break instructions on the stack (such work/knowledge
is better done by GDB).

Is there anything easier which could be done at GDB 
and/or by having Valgrind gdbserver handling differently some
protocol packets ?

(of course, I suppose there was a very good reason to switch to
ON_STACK technique and that switching back is not an option).

Philippe


  parent reply	other threads:[~2012-07-19 23:02 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 [this message]
2012-07-20  7:12   ` Jan Kratochvil
2012-07-20 20:49     ` Philippe Waroquiers
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=1342739016.2220.32.camel@soleil \
    --to=philippe.waroquiers@skynet.be \
    --cc=brobecker@adacore.com \
    --cc=gdb@sourceware.org \
    /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).