From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29628 invoked by alias); 23 Jul 2012 07:22:21 -0000 Received: (qmail 29606 invoked by uid 22791); 23 Jul 2012 07:22:19 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,TW_EG,TW_XC,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Jul 2012 07:22:02 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6N7LbHn026726 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 23 Jul 2012 03:21:37 -0400 Received: from host2.jankratochvil.net (ovpn-116-30.ams2.redhat.com [10.36.116.30]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6N7LUEv008276 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 23 Jul 2012 03:21:33 -0400 Date: Mon, 23 Jul 2012 07:22:00 -0000 From: Jan Kratochvil To: Philippe Waroquiers Cc: Joel Brobecker , gdb-patches@sourceware.org, Pedro Alves Subject: [patch] [i386] Put hlt at the ON_STACK breakpoint [Re: GDB 7.4.91 available for testing] Message-ID: <20120723072125.GA12958@host2.jankratochvil.net> References: <20120718163413.GA17548@adacore.com> <1342739016.2220.32.camel@soleil> <20120720071158.GA7053@host2.jankratochvil.net> <1342817409.2149.41.camel@soleil> <20120722173053.GA22036@host2.jankratochvil.net> <1342983655.2301.55.camel@soleil> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1342983655.2301.55.camel@soleil> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-07/txt/msg00436.txt.bz2 On Sun, 22 Jul 2012 21:00:55 +0200, Philippe Waroquiers wrote: > The problem with the above technique is that there is no valid > instruction at the ON_STACK breakpoint address, and the valgrind > translator does not like this. Therefore is it enough for valgrind to fix it by the patch below? It would be a good GDB user convenience fix anyway. Former: (gdb) up #1 (gdb) x/i $pc => 0x455210 <_start>: xor %ebp,%ebp Current: (gdb) up #1 (gdb) x/i $pc => 0x7fffffffda8f: add %al,(%rax) Current patched: (gdb) up #1 (gdb) x/i $pc => 0x7fffffffda0f: hlt (gdb) Thanks, Jan gdb/ 2012-07-23 Jan Kratochvil * i386-tdep.c (i386_push_dummy_code): New variable hlt. Call write_memoryg for it. diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 84e9794..712f0ff 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2340,10 +2340,17 @@ i386_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache) { + /* This hlt instruction is never executed. */ + static const bfd_byte hlt = 0xf4; + /* Use 0xcc breakpoint - 1 byte. */ *bp_addr = sp - 1; *real_pc = funaddr; + /* While inferior execution will trap on the 0xcc int3 instruction user + investigating the memory from GDB could see uninitialized bytes. */ + write_memory (*bp_addr, &hlt, sizeof (hlt)); + /* Keep the stack aligned. */ return sp - 16; }