From 03583c206f350870e077f4e112f83b3c4bdd0b27 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Fri, 7 Oct 2011 12:06:48 +0000 Subject: * inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include . Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro. --- gdb/infrun.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'gdb/infrun.c') diff --git a/gdb/infrun.c b/gdb/infrun.c index 225034c..cc2e29b 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -147,6 +147,37 @@ show_debug_infrun (struct ui_file *file, int from_tty, fprintf_filtered (file, _("Inferior debugging is %s.\n"), value); } + +/* Support for disabling address space randomization. */ + +int disable_randomization = 1; + +static void +show_disable_randomization (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + if (target_supports_disable_randomization ()) + fprintf_filtered (file, + _("Disabling randomization of debuggee's " + "virtual address space is %s.\n"), + value); + else + fputs_filtered (_("Disabling randomization of debuggee's " + "virtual address space is unsupported on\n" + "this platform.\n"), file); +} + +static void +set_disable_randomization (char *args, int from_tty, + struct cmd_list_element *c) +{ + if (!target_supports_disable_randomization ()) + error (_("Disabling randomization of debuggee's " + "virtual address space is unsupported on\n" + "this platform.")); +} + + /* If the program uses ELF-style shared libraries, then calls to functions in shared libraries go through stubs, which live in a table called the PLT (Procedure Linkage Table). The first time the @@ -7232,6 +7263,19 @@ Show whether gdb will detach the child of a fork."), _("\ Tells gdb whether to detach the child of a fork."), NULL, NULL, &setlist, &showlist); + /* Set/show disable address space randomization mode. */ + + add_setshow_boolean_cmd ("disable-randomization", class_support, + &disable_randomization, _("\ +Set disabling of debuggee's virtual address space randomization."), _("\ +Show disabling of debuggee's virtual address space randomization."), _("\ +When this mode is on (which is the default), randomization of the virtual\n\ +address space is disabled. Standalone programs run with the randomization\n\ +enabled by default on some platforms."), + &set_disable_randomization, + &show_disable_randomization, + &setlist, &showlist); + /* ptid initializations */ inferior_ptid = null_ptid; target_last_wait_ptid = minus_one_ptid; -- cgit v1.1