From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7263 invoked by alias); 26 Jun 2008 14:42:14 -0000 Received: (qmail 7254 invoked by uid 22791); 26 Jun 2008 14:42:13 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 26 Jun 2008 14:41:53 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id A75E998366; Thu, 26 Jun 2008 14:41:51 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id 8252C9835A; Thu, 26 Jun 2008 14:41:51 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1KBsfW-0007bI-EH; Thu, 26 Jun 2008 10:41:50 -0400 Date: Thu, 26 Jun 2008 15:52:00 -0000 From: Daniel Jacobowitz To: Jan Kratochvil Cc: Mark Kettenis , gdb-patches@sourceware.org Subject: Re: [patch] Disable child VMA randomizations Message-ID: <20080626144150.GL22726@caradoc.them.org> Mail-Followup-To: Jan Kratochvil , Mark Kettenis , gdb-patches@sourceware.org References: <20080607195343.GA10039@host0.dyn.jankratochvil.net> <200806081513.m58FDwbn000386@brahms.sibelius.xs4all.nl> <20080608164331.GA6358@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080608164331.GA6358@host0.dyn.jankratochvil.net> User-Agent: Mutt/1.5.17 (2008-05-11) 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: 2008-06/txt/msg00478.txt.bz2 Please also add the new commands to NEWS. On Sun, Jun 08, 2008 at 06:43:31PM +0200, Jan Kratochvil wrote: > @@ -149,6 +156,19 @@ show_debug_linux_nat_async (struct ui_fi > value); > } > > +#ifdef HAVE_PERSONALITY > +static int disable_randomization = 1; > + > +static void > +show_disable_randomization (struct ui_file *file, int from_tty, > + struct cmd_list_element *c, const char *value) > +{ > + fprintf_filtered (file, _("\ > +Disabling randomization of debuggee's virtual address space is %s.\n"), > + value); > +} > +#endif /* HAVE_PERSONALITY */ > + > static int linux_parent_pid; > > struct simple_pid_list I think it would be better to register the command unconditionally, but only call personality if it is available. I'd like to keep conditionally compiled code to a minimum. > + warning (_("Error setting the enabled disable-randomization: %s"), Error disabling address space randomization: > + safe_strerror (errno)); > + } > +#endif /* HAVE_PERSONALITY */ > + > linux_ops->to_create_inferior (exec_file, allargs, env, from_tty); > > +#ifdef HAVE_PERSONALITY > + if (personality_set) > + { > + errno = 0; > + personality (personality_orig); > + if (errno != 0) > + warning (_("Problem restoring the disable-randomization state: %s"), Error restoring address space randomization: > +When this mode is on (which is the default), the randomization of\n\ > +the virtual address space is disabled. Standalone programs run with the\n\ > +randomization enabled by default on some platforms."), You don't need "the" before randomization in this case (two places). > +misusing it. Still even a prelinked shared library can get loaded a a new at a > + gdb_test_multiple "continue" $testname { > + -re "address = (0x\[0-9a-f\]*).*Program exited normally..*$gdb_prompt $" { > + pass $testname > + return $expect_out(1,string) > + } Please set a breakpoint and use GDB to print out the variable, instead of relying on printf; some test configurations don't work with stdio. They probably won't work with this test anyway, but no reason to complicate things. > +gdb_test "set disable-randomization off" > +set addr1 [address_get "randomized first address"] > +set addr2 [address_get "randomized second address"] > +set test "randomized addresses should not match" > +if {$addr1 eq $addr2} { > + fail $test > +} else { > + pass $test > +} This test will only pass if the system supports address randomization and has it enabled. I don't know about you, but the first thing I do on a new developer system is turn it off... -- Daniel Jacobowitz CodeSourcery