Added the ability to disable ASLR (Address Space Layout Randomization). ASLR
is disabled by default, and can be enabled using:
(lldb) set disable-aslr 0
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@112616 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 2a07ee9..e8d596a 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -375,6 +375,7 @@
Module* module,
char const *argv[],
char const *envp[],
+ uint32_t launch_flags,
const char *stdin_path,
const char *stdout_path,
const char *stderr_path
@@ -404,6 +405,7 @@
NULL, //stdin_path,
LLDB_INVALID_PROCESS_ID,
NULL, false,
+ launch_flags & eLaunchFlagDisableASLR != 0,
inferior_arch);
if (error.Fail())
return error;
@@ -422,6 +424,7 @@
NULL, //stdin_path,
LLDB_INVALID_PROCESS_ID,
NULL, false,
+ launch_flags & eLaunchFlagDisableASLR != 0,
inferior_arch);
if (error.Fail())
return error;
@@ -639,12 +642,14 @@
SetPrivateState (eStateAttaching);
char host_port[128];
snprintf (host_port, sizeof(host_port), "localhost:%u", get_random_port ());
- error = StartDebugserverProcess (host_port,
- NULL,
- NULL,
- NULL,
- LLDB_INVALID_PROCESS_ID,
- NULL, false,
+ error = StartDebugserverProcess (host_port, // debugserver_url
+ NULL, // inferior_argv
+ NULL, // inferior_envp
+ NULL, // stdin_path
+ LLDB_INVALID_PROCESS_ID, // attach_pid
+ NULL, // attach_pid_name
+ false, // wait_for_launch
+ false, // disable_aslr
arch_spec);
if (error.Fail())
@@ -740,12 +745,14 @@
char host_port[128];
ArchSpec arch_spec = GetTarget().GetArchitecture();
snprintf (host_port, sizeof(host_port), "localhost:%u", get_random_port ());
- error = StartDebugserverProcess (host_port,
- NULL,
- NULL,
- NULL,
- LLDB_INVALID_PROCESS_ID,
- NULL, false,
+ error = StartDebugserverProcess (host_port, // debugserver_url
+ NULL, // inferior_argv
+ NULL, // inferior_envp
+ NULL, // stdin_path
+ LLDB_INVALID_PROCESS_ID, // attach_pid
+ NULL, // attach_pid_name
+ false, // wait_for_launch
+ false, // disable_aslr
arch_spec);
if (error.Fail())
{
@@ -1644,6 +1651,7 @@
lldb::pid_t attach_pid, // If inferior inferior_argv == NULL, and attach_pid != LLDB_INVALID_PROCESS_ID then attach to this attach_pid
const char *attach_name, // Wait for the next process to launch whose basename matches "attach_name"
bool wait_for_launch, // Wait for the process named "attach_name" to launch
+ bool disable_aslr, // Disable ASLR
ArchSpec& inferior_arch // The arch of the inferior that we will launch
)
{
@@ -1771,6 +1779,9 @@
// signals generated by special terminal key
// sequences (^C) don't affect debugserver
+ if (disable_aslr)
+ debugserver_args.AppendArguments("--disable-aslr");
+
// Only set the inferior
if (launch_process)
{