Author: tfiala
Date: Tue Aug 19 12:40:43 2014
New Revision: 215996
URL: http://llvm.org/viewvc/llvm-project?rev=215996&view=rev
Log:
Adjust process launch --disable-aslr to take true/false value.
This change modifies the 'process launch' --disable-aslr option to take a
boolean argument. If the user directly specifies --disable-aslr {true,false},
that setting will control whether the process is launched with ASLR disabled
accordingly. In the event that the setting is not explicitly made on the
process launch command line, then the value is retrieved from the
target.disable-aslr setting (i.e. settings show target.disable-aslr).
Modified:
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/source/Commands/CommandObjectProcess.cpp
lldb/trunk/source/Target/Process.cpp
Modified: lldb/trunk/include/lldb/Target/Process.h
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=215996&r1=215995&r2=215996&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Tue Aug 19 12:40:43 2014
@@ -392,6 +392,7 @@ public:
OptionParsingStarting ()
{
launch_info.Clear();
+ disable_aslr = eLazyBoolCalculate;
}
const OptionDefinition*
@@ -407,6 +408,7 @@ public:
// Instance variables to hold the values for command options.
ProcessLaunchInfo launch_info;
+ lldb_private::LazyBool disable_aslr;
};
//----------------------------------------------------------------------
Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=215996&r1=215995&r2=215996&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Tue Aug 19 12:40:43 2014
@@ -205,8 +205,25 @@ protected:
const char *target_settings_argv0 = target->GetArg0();
- if (target->GetDisableASLR())
+ // Determine whether we will disable ASLR or leave it in the default
state (i.e. enabled if the platform supports it).
+ // First check if the process launch options explicitly turn on/off
disabling ASLR. If so, use that setting;
+ // otherwise, use the 'settings target.disable-aslr' setting.
+ bool disable_aslr = false;
+ if (m_options.disable_aslr != eLazyBoolCalculate)
+ {
+ // The user specified an explicit setting on the process launch
line. Use it.
+ disable_aslr = (m_options.disable_aslr == eLazyBoolYes);
+ }
+ else
+ {
+ // The user did not explicitly specify whether to disable ASLR.
Fall back to the target.disable-aslr setting.
+ disable_aslr = target->GetDisableASLR ();
+ }
+
+ if (disable_aslr)
m_options.launch_info.GetFlags().Set (eLaunchFlagDisableASLR);
+ else
+ m_options.launch_info.GetFlags().Clear (eLaunchFlagDisableASLR);
if (target->GetDetachOnError())
m_options.launch_info.GetFlags().Set (eLaunchFlagDetachOnError);
Modified: lldb/trunk/source/Target/Process.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=215996&r1=215995&r2=215996&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Tue Aug 19 12:40:43 2014
@@ -454,11 +454,18 @@ ProcessLaunchCommandOptions::SetOptionVa
launch_info.GetArchitecture().SetTriple (option_arg);
break;
- case 'A':
- launch_info.GetFlags().Set (eLaunchFlagDisableASLR);
+ case 'A': // Disable ASLR.
+ {
+ bool success;
+ const bool disable_aslr_arg = Args::StringToBoolean (option_arg,
true, &success);
+ if (success)
+ disable_aslr = disable_aslr_arg ? eLazyBoolYes : eLazyBoolNo;
+ else
+ error.SetErrorStringWithFormat ("Invalid boolean value for
disable-aslr option: '%s'", option_arg ? option_arg : "<null>");
break;
-
- case 'c':
+ }
+
+ case 'c':
if (option_arg && option_arg[0])
launch_info.SetShell (option_arg);
else
@@ -480,7 +487,7 @@ OptionDefinition
ProcessLaunchCommandOptions::g_option_table[] =
{
{ LLDB_OPT_SET_ALL, false, "stop-at-entry", 's', OptionParser::eNoArgument,
NULL, NULL, 0, eArgTypeNone, "Stop at the entry point of the
program when launching a process."},
-{ LLDB_OPT_SET_ALL, false, "disable-aslr", 'A', OptionParser::eNoArgument,
NULL, NULL, 0, eArgTypeNone, "Disable address space layout
randomization when launching a process."},
+{ LLDB_OPT_SET_ALL, false, "disable-aslr", 'A',
OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Set
whether to disable address space layout randomization when launching a
process."},
{ LLDB_OPT_SET_ALL, false, "plugin", 'p',
OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePlugin, "Name of
the process plugin you want to use."},
{ LLDB_OPT_SET_ALL, false, "working-dir", 'w',
OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeDirectoryName,
"Set the current working directory to <path> when running the inferior."},
{ LLDB_OPT_SET_ALL, false, "arch", 'a',
OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeArchitecture, "Set the
architecture for the process to launch when ambiguous."},
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits