diff options
author | Ulrich Weigand <uweigand@de.ibm.com> | 2011-10-07 12:06:48 +0000 |
---|---|---|
committer | Ulrich Weigand <uweigand@de.ibm.com> | 2011-10-07 12:06:48 +0000 |
commit | 03583c206f350870e077f4e112f83b3c4bdd0b27 (patch) | |
tree | f21677825f84019f3963478b1f560a497081f4d2 /gdb/remote.c | |
parent | 01b71697807be429fbd5d960e4228c04837024e3 (diff) | |
download | gdb-03583c206f350870e077f4e112f83b3c4bdd0b27.zip gdb-03583c206f350870e077f4e112f83b3c4bdd0b27.tar.gz gdb-03583c206f350870e077f4e112f83b3c4bdd0b27.tar.bz2 |
* 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 <sys/personality.h>.
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.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r-- | gdb/remote.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gdb/remote.c b/gdb/remote.c index 1c9e965..32e68f3 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1263,6 +1263,7 @@ enum { PACKET_TracepointSource, PACKET_QAllow, PACKET_qXfer_fdpic, + PACKET_QDisableRandomization, PACKET_MAX }; @@ -3761,6 +3762,8 @@ static struct protocol_feature remote_protocol_features[] = { remote_enable_disable_tracepoint_feature, -1 }, { "qXfer:fdpic:read", PACKET_DISABLE, remote_supported_packet, PACKET_qXfer_fdpic }, + { "QDisableRandomization", PACKET_DISABLE, remote_supported_packet, + PACKET_QDisableRandomization }, }; static char *remote_support_xml; @@ -7484,6 +7487,28 @@ extended_remote_mourn (struct target_ops *ops) } static int +extended_remote_supports_disable_randomization (void) +{ + return (remote_protocol_packets[PACKET_QDisableRandomization].support + == PACKET_ENABLE); +} + +static void +extended_remote_disable_randomization (int val) +{ + struct remote_state *rs = get_remote_state (); + char *reply; + + sprintf (rs->buf, "QDisableRandomization:%x", val); + putpkt (rs->buf); + reply = remote_get_noisy_reply (&target_buf, &target_buf_size); + if (*reply == '\0') + error (_("Target does not support QDisableRandomization.")); + if (strcmp (reply, "OK") != 0) + error (_("Bogus QDisableRandomization reply from target: %s"), reply); +} + +static int extended_remote_run (char *args) { struct remote_state *rs = get_remote_state (); @@ -7559,6 +7584,10 @@ extended_remote_create_inferior_1 (char *exec_file, char *args, if (target_can_async_p ()) target_async (inferior_event_handler, 0); + /* Disable address space randomization if requested (and supported). */ + if (extended_remote_supports_disable_randomization ()) + extended_remote_disable_randomization (disable_randomization); + /* Now restart the remote server. */ if (extended_remote_run (args) == -1) { @@ -9665,6 +9694,13 @@ remote_supports_non_stop (void) } static int +remote_supports_disable_randomization (void) +{ + /* Only supported in extended mode. */ + return 0; +} + +static int remote_supports_multi_process (void) { struct remote_state *rs = get_remote_state (); @@ -10420,6 +10456,8 @@ Specify the serial device it is connected to\n\ remote_ops.to_terminal_ours = remote_terminal_ours; remote_ops.to_supports_non_stop = remote_supports_non_stop; remote_ops.to_supports_multi_process = remote_supports_multi_process; + remote_ops.to_supports_disable_randomization + = remote_supports_disable_randomization; remote_ops.to_supports_enable_disable_tracepoint = remote_supports_enable_disable_tracepoint; remote_ops.to_trace_init = remote_trace_init; remote_ops.to_download_tracepoint = remote_download_tracepoint; @@ -10472,6 +10510,8 @@ Specify the serial device it is connected to (e.g. /dev/ttya)."; extended_remote_ops.to_detach = extended_remote_detach; extended_remote_ops.to_attach = extended_remote_attach; extended_remote_ops.to_kill = extended_remote_kill; + extended_remote_ops.to_supports_disable_randomization + = extended_remote_supports_disable_randomization; } static int @@ -10944,6 +10984,9 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL, add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_fdpic], "qXfer:fdpic:read", "read-fdpic-loadmap", 0); + add_packet_config_cmd (&remote_protocol_packets[PACKET_QDisableRandomization], + "QDisableRandomization", "disable-randomization", 0); + /* Keep the old ``set remote Z-packet ...'' working. Each individual Z sub-packet has its own set and show commands, but users may have sets to this variable in their .gdbinit files (or in their |