From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31848 invoked by alias); 23 Jul 2012 16:00:15 -0000 Received: (qmail 31791 invoked by uid 22791); 23 Jul 2012 16:00:10 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_NO,TW_EG,TW_XC X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Jul 2012 15:59:56 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 6C8951C6B26; Mon, 23 Jul 2012 11:59:55 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id DrYurEM4nntg; Mon, 23 Jul 2012 11:59:55 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 12AB51C69E8; Mon, 23 Jul 2012 11:59:54 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id A52EA14561A; Mon, 23 Jul 2012 08:59:51 -0700 (PDT) Date: Mon, 23 Jul 2012 16:00:00 -0000 From: Joel Brobecker To: Jan Kratochvil 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: <20120723155951.GA24718@adacore.com> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120723072125.GA12958@host2.jankratochvil.net> User-Agent: Mutt/1.5.20 (2009-06-14) 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/msg00453.txt.bz2 > 2012-07-23 Jan Kratochvil > > * i386-tdep.c (i386_push_dummy_code): New variable hlt. Call > write_memoryg for it. Not really a review (not the maintainer), but it looks like a good idea. It even seems to me that this should be done on all platforms, no? If agreed, perhaps this should be a gdbarch-specific part of the infcall sequence. And instead of writing an instruction of the arch's choosing, why not write the breakpoint trap instruction? In the meantime, a quick fix like yours seems like a good first step. > 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; Why make it static? Isn't that going to force the compiler to make that variable global (put into RO section)? > + /* 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)); 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. */ -- Joel