From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3661 invoked by alias); 23 Jul 2012 16:36:19 -0000 Received: (qmail 3542 invoked by uid 22791); 23 Jul 2012 16:36:17 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,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 16:35:48 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6NGZN1N031306 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 23 Jul 2012 12:35:23 -0400 Received: from host2.jankratochvil.net (ovpn-116-30.ams2.redhat.com [10.36.116.30]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6NGZISl006160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 23 Jul 2012 12:35:21 -0400 Date: Mon, 23 Jul 2012 16:36:00 -0000 From: Jan Kratochvil To: Joel Brobecker Cc: Philippe Waroquiers , gdb-patches@sourceware.org, Pedro Alves Subject: Re: [patch] [i386] Put hlt at the ON_STACK breakpoint [Re: GDB 7.4.91 available for testing] Message-ID: <20120723163513.GA1222@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> <20120723072125.GA12958@host2.jankratochvil.net> <20120723155951.GA24718@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120723155951.GA24718@adacore.com> 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/msg00455.txt.bz2 On Mon, 23 Jul 2012 17:59:51 +0200, Joel Brobecker wrote: > It even seems to me that this should be done on all platforms, no? Yes; just looking at the other archs it was not trivial to me so I wanted to be sure it at least really helps valgrind. > And instead of writing an instruction of the > arch's choosing, why not write the breakpoint trap instruction? It depends on the opinion. I wanted to make clear there is a real GDB breakpoint on top of it and in normal GDB control flow the 'hlt' instruction is never executed by CPU. There are other reasons why to put int3 there, maybe it would be more clear to the users that way when I think about it now. It also does not matter much, users do not probably disassemble the frame. > > + /* This hlt instruction is never executed. */ > > + static const bfd_byte hlt = 0xf4; > > Why make it static? Isn't that going to force the compiler to make > that variable global (put into RO section)? It is a nitpick but 'static const' is more effective than just 'const'. In the latter case compiler has to create the storage for variable on stack (probably to at least ensure its unique address), in the former case it just takes an address of .rodata variable, which is generally cheaper. const 4: 48 8d 7c 24 08 lea 0x8(%rsp),%rdi 9: c7 44 24 08 2a 00 00 movl $0x2a,0x8(%rsp) 10: 00 [Nr] Name Type Address Off Size ES Flg Lk Inf Al ---- no .rodata vs. static const 4: bf 00 00 00 00 mov $0x0,%edi 5: R_X86_64_32 .rodata [Nr] Name Type Address Off Size ES Flg Lk Inf Al [ 5] .rodata PROGBITS 0000000000000000 00005c 000004 00 A 0 0 4 > I suggest merging the two comments into one at the point where the > intruction is written. > > /* Write an legitimate instruction at the point where the infcall > breakpoint is going to be inserted. While this instruction > is never going to be executed, a user investigating the memory > from GDB would see this instruction instead of random > uninitialized bytes. */ OK, I will update the patch later for check-in. Thanks, Jan