From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26900 invoked by alias); 20 Jul 2012 20:49:31 -0000 Received: (qmail 26891 invoked by uid 22791); 20 Jul 2012 20:49:30 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE,TW_XC X-Spam-Check-By: sourceware.org Received: from mailrelay010.isp.belgacom.be (HELO mailrelay010.isp.belgacom.be) (195.238.6.177) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 Jul 2012 20:49:16 +0000 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqgBADzDCVBR9oWA/2dsb2JhbAANOIV0sAaGfQEBAQQjVhALGAICJgICVwYusn9ukwSBIIouhU6BEgOoMA Received: from 128.133-246-81.adsl-dyn.isp.belgacom.be (HELO [192.168.1.2]) ([81.246.133.128]) by relay.skynet.be with ESMTP; 20 Jul 2012 22:49:14 +0200 Subject: Re: GDB 7.4.91 available for testing From: Philippe Waroquiers To: Jan Kratochvil Cc: Joel Brobecker , gdb@sourceware.org In-Reply-To: <20120720071158.GA7053@host2.jankratochvil.net> References: <20120718163413.GA17548@adacore.com> <1342739016.2220.32.camel@soleil> <20120720071158.GA7053@host2.jankratochvil.net> Content-Type: text/plain; charset="UTF-8" Date: Fri, 20 Jul 2012 20:49:00 -0000 Message-ID: <1342817409.2149.41.camel@soleil> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-07/txt/msg00065.txt.bz2 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