Moved many of the "settings" that used to be in "target.process.*" to just
be in the target. All of the environment, args, stdin/out/err files, etc have
all been moved. Also re-enabled the ability to launch a process in a separate
terminal on MacOSX.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144061 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index a7279c1..bfc7319 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -250,6 +250,60 @@
}
}
+void
+ProcessLaunchInfo::FinalizeFileActions (Target *target, Process *process)
+{
+ // If notthing was specified, then check the process for any default
+ // settings that were set with "settings set"
+ if (m_file_actions.empty())
+ {
+ const char *path;
+ if (m_flags.Test(eLaunchFlagDisableSTDIO))
+ {
+ AppendSuppressFileAction (STDERR_FILENO, true , true );
+ AppendSuppressFileAction (STDIN_FILENO , true , false);
+ AppendSuppressFileAction (STDOUT_FILENO, false, true );
+ }
+ else
+ {
+ // Check for any values that might have gotten set with any of:
+ // (lldb) settings set target.input-path
+ // (lldb) settings set target.output-path
+ // (lldb) settings set target.error-path
+ if (target)
+ {
+ path = target->GetStandardErrorPath();
+ if (path)
+ {
+ const bool read = true;
+ const bool write = true;
+ AppendOpenFileAction(STDERR_FILENO, path, read, write);
+ }
+ path = target->GetStandardInputPath();
+ if (path)
+ {
+ const bool read = true;
+ const bool write = false;
+ AppendOpenFileAction(STDIN_FILENO, path, read, write);
+ }
+
+ path = target->GetStandardOutputPath();
+ if (path)
+ {
+ const bool read = false;
+ const bool write = true;
+ AppendOpenFileAction(STDOUT_FILENO, path, read, write);
+ }
+ }
+
+ // If we still don't have any actions...
+ if (m_file_actions.empty())
+ {
+ }
+ }
+ }
+}
+
bool
ProcessLaunchInfo::FileAction::Open (int fd, const char *path, bool read, bool write)
{
@@ -466,6 +520,7 @@
{ LLDB_OPT_SET_ALL, false, "working-dir", 'w', required_argument, NULL, 0, eArgTypePath, "Set the current working directory to <path> when running the inferior."},
{ LLDB_OPT_SET_ALL, false, "arch", 'a', required_argument, NULL, 0, eArgTypeArchitecture, "Set the architecture for the process to launch when ambiguous."},
{ LLDB_OPT_SET_ALL, false, "environment", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify an environment variable name/value stirng (--environement NAME=VALUE). Can be specified multiple times for subsequent environment entries."},
+{ LLDB_OPT_SET_ALL, false, "shell", 'c', no_argument, NULL, 0, eArgTypeNone, "Run the process in a shell (not supported on all platforms)."},
{ LLDB_OPT_SET_1 , false, "stdin", 'i', required_argument, NULL, 0, eArgTypePath, "Redirect stdin for the process to <path>."},
{ LLDB_OPT_SET_1 , false, "stdout", 'o', required_argument, NULL, 0, eArgTypePath, "Redirect stdout for the process to <path>."},
@@ -475,7 +530,6 @@
{ LLDB_OPT_SET_3 , false, "no-stdio", 'n', no_argument, NULL, 0, eArgTypeNone, "Do not set up for terminal I/O to go to running process."},
-{ LLDB_OPT_SET_4 , false, "shell", 'c', no_argument, NULL, 0, eArgTypeNone, "Run the process in a shell (not supported on all platforms)."},
{ 0 , false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
};
@@ -949,50 +1003,6 @@
}
-void
-Process::ProcessInstanceSettings::GetHostEnvironmentIfNeeded ()
-{
- if (m_inherit_host_env && !m_got_host_env)
- {
- m_got_host_env = true;
- StringList host_env;
- const size_t host_env_count = Host::GetEnvironment (host_env);
- for (size_t idx=0; idx<host_env_count; idx++)
- {
- const char *env_entry = host_env.GetStringAtIndex (idx);
- if (env_entry)
- {
- const char *equal_pos = ::strchr(env_entry, '=');
- if (equal_pos)
- {
- std::string key (env_entry, equal_pos - env_entry);
- std::string value (equal_pos + 1);
- if (m_env_vars.find (key) == m_env_vars.end())
- m_env_vars[key] = value;
- }
- }
- }
- }
-}
-
-
-size_t
-Process::ProcessInstanceSettings::GetEnvironmentAsArgs (Args &env)
-{
- GetHostEnvironmentIfNeeded ();
-
- dictionary::const_iterator pos, end = m_env_vars.end();
- for (pos = m_env_vars.begin(); pos != end; ++pos)
- {
- std::string env_var_equal_value (pos->first);
- env_var_equal_value.append(1, '=');
- env_var_equal_value.append (pos->second);
- env.AppendArgument (env_var_equal_value.c_str());
- }
- return env.GetArgumentCount();
-}
-
-
const char *
Process::GetExitDescription ()
{
@@ -4044,28 +4054,19 @@
bool live_instance,
const char *name
) :
- InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance),
- m_run_args (),
- m_env_vars (),
- m_input_path (),
- m_output_path (),
- m_error_path (),
- m_disable_aslr (true),
- m_disable_stdio (false),
- m_inherit_host_env (true),
- m_got_host_env (false)
+ InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance)
{
// CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called
// until the vtables for ProcessInstanceSettings are properly set up, i.e. AFTER all the initializers.
// For this reason it has to be called here, rather than in the initializer or in the parent constructor.
// This is true for CreateInstanceName() too.
-
+
if (GetInstanceName () == InstanceSettings::InvalidName())
{
ChangeInstanceName (std::string (CreateInstanceName().AsCString()));
m_owner.RegisterInstanceSettings (this);
}
-
+
if (live_instance)
{
const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
@@ -4075,14 +4076,7 @@
}
ProcessInstanceSettings::ProcessInstanceSettings (const ProcessInstanceSettings &rhs) :
- InstanceSettings (*Process::GetSettingsController(), CreateInstanceName().AsCString()),
- m_run_args (rhs.m_run_args),
- m_env_vars (rhs.m_env_vars),
- m_input_path (rhs.m_input_path),
- m_output_path (rhs.m_output_path),
- m_error_path (rhs.m_error_path),
- m_disable_aslr (rhs.m_disable_aslr),
- m_disable_stdio (rhs.m_disable_stdio)
+ InstanceSettings (*Process::GetSettingsController(), CreateInstanceName().AsCString())
{
if (m_instance_name != InstanceSettings::GetDefaultName())
{
@@ -4101,14 +4095,6 @@
{
if (this != &rhs)
{
- m_run_args = rhs.m_run_args;
- m_env_vars = rhs.m_env_vars;
- m_input_path = rhs.m_input_path;
- m_output_path = rhs.m_output_path;
- m_error_path = rhs.m_error_path;
- m_disable_aslr = rhs.m_disable_aslr;
- m_disable_stdio = rhs.m_disable_stdio;
- m_inherit_host_env = rhs.m_inherit_host_env;
}
return *this;
@@ -4125,45 +4111,16 @@
Error &err,
bool pending)
{
- if (var_name == RunArgsVarName())
- UserSettingsController::UpdateStringArrayVariable (op, index_value, m_run_args, value, err);
- else if (var_name == EnvVarsVarName())
- {
- // This is nice for local debugging, but it is isn't correct for
- // remote debugging. We need to stop process.env-vars from being
- // populated with the host environment and add this as a launch option
- // and get the correct environment from the Target's platform.
- // GetHostEnvironmentIfNeeded ();
- UserSettingsController::UpdateDictionaryVariable (op, index_value, m_env_vars, value, err);
- }
- else if (var_name == InputPathVarName())
- UserSettingsController::UpdateStringVariable (op, m_input_path, value, err);
- else if (var_name == OutputPathVarName())
- UserSettingsController::UpdateStringVariable (op, m_output_path, value, err);
- else if (var_name == ErrorPathVarName())
- UserSettingsController::UpdateStringVariable (op, m_error_path, value, err);
- else if (var_name == DisableASLRVarName())
- UserSettingsController::UpdateBooleanVariable (op, m_disable_aslr, value, true, err);
- else if (var_name == DisableSTDIOVarName ())
- UserSettingsController::UpdateBooleanVariable (op, m_disable_stdio, value, false, err);
}
void
ProcessInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings,
bool pending)
{
- if (new_settings.get() == NULL)
- return;
-
- ProcessInstanceSettings *new_process_settings = (ProcessInstanceSettings *) new_settings.get();
-
- m_run_args = new_process_settings->m_run_args;
- m_env_vars = new_process_settings->m_env_vars;
- m_input_path = new_process_settings->m_input_path;
- m_output_path = new_process_settings->m_output_path;
- m_error_path = new_process_settings->m_error_path;
- m_disable_aslr = new_process_settings->m_disable_aslr;
- m_disable_stdio = new_process_settings->m_disable_stdio;
+// if (new_settings.get() == NULL)
+// return;
+//
+// ProcessInstanceSettings *new_process_settings = (ProcessInstanceSettings *) new_settings.get();
}
bool
@@ -4172,69 +4129,9 @@
StringList &value,
Error *err)
{
- if (var_name == RunArgsVarName())
- {
- if (m_run_args.GetArgumentCount() > 0)
- {
- for (int i = 0; i < m_run_args.GetArgumentCount(); ++i)
- value.AppendString (m_run_args.GetArgumentAtIndex (i));
- }
- }
- else if (var_name == EnvVarsVarName())
- {
- GetHostEnvironmentIfNeeded ();
-
- if (m_env_vars.size() > 0)
- {
- std::map<std::string, std::string>::iterator pos;
- for (pos = m_env_vars.begin(); pos != m_env_vars.end(); ++pos)
- {
- StreamString value_str;
- value_str.Printf ("%s=%s", pos->first.c_str(), pos->second.c_str());
- value.AppendString (value_str.GetData());
- }
- }
- }
- else if (var_name == InputPathVarName())
- {
- value.AppendString (m_input_path.c_str());
- }
- else if (var_name == OutputPathVarName())
- {
- value.AppendString (m_output_path.c_str());
- }
- else if (var_name == ErrorPathVarName())
- {
- value.AppendString (m_error_path.c_str());
- }
- else if (var_name == InheritHostEnvVarName())
- {
- if (m_inherit_host_env)
- value.AppendString ("true");
- else
- value.AppendString ("false");
- }
- else if (var_name == DisableASLRVarName())
- {
- if (m_disable_aslr)
- value.AppendString ("true");
- else
- value.AppendString ("false");
- }
- else if (var_name == DisableSTDIOVarName())
- {
- if (m_disable_stdio)
- value.AppendString ("true");
- else
- value.AppendString ("false");
- }
- else
- {
- if (err)
- err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString());
- return false;
- }
- return true;
+ if (err)
+ err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString());
+ return false;
}
const ConstString
@@ -4250,70 +4147,6 @@
return ret_val;
}
-const ConstString &
-ProcessInstanceSettings::RunArgsVarName ()
-{
- static ConstString run_args_var_name ("run-args");
-
- return run_args_var_name;
-}
-
-const ConstString &
-ProcessInstanceSettings::EnvVarsVarName ()
-{
- static ConstString env_vars_var_name ("env-vars");
-
- return env_vars_var_name;
-}
-
-const ConstString &
-ProcessInstanceSettings::InheritHostEnvVarName ()
-{
- static ConstString g_name ("inherit-env");
-
- return g_name;
-}
-
-const ConstString &
-ProcessInstanceSettings::InputPathVarName ()
-{
- static ConstString input_path_var_name ("input-path");
-
- return input_path_var_name;
-}
-
-const ConstString &
-ProcessInstanceSettings::OutputPathVarName ()
-{
- static ConstString output_path_var_name ("output-path");
-
- return output_path_var_name;
-}
-
-const ConstString &
-ProcessInstanceSettings::ErrorPathVarName ()
-{
- static ConstString error_path_var_name ("error-path");
-
- return error_path_var_name;
-}
-
-const ConstString &
-ProcessInstanceSettings::DisableASLRVarName ()
-{
- static ConstString disable_aslr_var_name ("disable-aslr");
-
- return disable_aslr_var_name;
-}
-
-const ConstString &
-ProcessInstanceSettings::DisableSTDIOVarName ()
-{
- static ConstString disable_stdio_var_name ("disable-stdio");
-
- return disable_stdio_var_name;
-}
-
//--------------------------------------------------
// SettingsController Variable Tables
//--------------------------------------------------
@@ -4330,17 +4163,9 @@
Process::SettingsController::instance_settings_table[] =
{
//{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"},
- { "run-args", eSetVarTypeArray, NULL, NULL, false, false, "A list containing all the arguments to be passed to the executable when it is run." },
- { "env-vars", eSetVarTypeDictionary, NULL, NULL, false, false, "A list of all the environment variables to be passed to the executable's environment, and their values." },
- { "inherit-env", eSetVarTypeBoolean, "true", NULL, false, false, "Inherit the environment from the process that is running LLDB." },
- { "input-path", eSetVarTypeString, NULL, NULL, false, false, "The file/path to be used by the executable program for reading its input." },
- { "output-path", eSetVarTypeString, NULL, NULL, false, false, "The file/path to be used by the executable program for writing its output." },
- { "error-path", eSetVarTypeString, NULL, NULL, false, false, "The file/path to be used by the executable program for writings its error messages." },
- { "plugin", eSetVarTypeEnum, NULL, NULL, false, false, "The plugin to be used to run the process." },
- { "disable-aslr", eSetVarTypeBoolean, "true", NULL, false, false, "Disable Address Space Layout Randomization (ASLR)" },
- { "disable-stdio", eSetVarTypeBoolean, "false", NULL, false, false, "Disable stdin/stdout for process (e.g. for a GUI application)" },
{ NULL, eSetVarTypeNone, NULL, NULL, false, false, NULL }
};
+
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index aec81ff..866810c 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -1973,14 +1973,22 @@
}
-#define TSC_DEFAULT_ARCH "default-arch"
-#define TSC_EXPR_PREFIX "expr-prefix"
-#define TSC_PREFER_DYNAMIC "prefer-dynamic-value"
-#define TSC_SKIP_PROLOGUE "skip-prologue"
-#define TSC_SOURCE_MAP "source-map"
-#define TSC_MAX_CHILDREN "max-children-count"
-#define TSC_MAX_STRLENSUMMARY "max-string-summary-length"
-#define TSC_PLATFORM_AVOID "breakpoints-use-platform-avoid-list"
+#define TSC_DEFAULT_ARCH "default-arch"
+#define TSC_EXPR_PREFIX "expr-prefix"
+#define TSC_PREFER_DYNAMIC "prefer-dynamic-value"
+#define TSC_SKIP_PROLOGUE "skip-prologue"
+#define TSC_SOURCE_MAP "source-map"
+#define TSC_MAX_CHILDREN "max-children-count"
+#define TSC_MAX_STRLENSUMMARY "max-string-summary-length"
+#define TSC_PLATFORM_AVOID "breakpoints-use-platform-avoid-list"
+#define TSC_RUN_ARGS "run-args"
+#define TSC_ENV_VARS "env-vars"
+#define TSC_INHERIT_ENV "inherit-env"
+#define TSC_STDIN_PATH "input-path"
+#define TSC_STDOUT_PATH "output-path"
+#define TSC_STDERR_PATH "error-path"
+#define TSC_DISABLE_ASLR "disable-aslr"
+#define TSC_DISABLE_STDIO "disable-stdio"
static const ConstString &
@@ -2039,6 +2047,61 @@
return g_const_string;
}
+const ConstString &
+GetSettingNameForRunArgs ()
+{
+ static ConstString g_const_string (TSC_RUN_ARGS);
+ return g_const_string;
+}
+
+const ConstString &
+GetSettingNameForEnvVars ()
+{
+ static ConstString g_const_string (TSC_ENV_VARS);
+ return g_const_string;
+}
+
+const ConstString &
+GetSettingNameForInheritHostEnv ()
+{
+ static ConstString g_const_string (TSC_INHERIT_ENV);
+ return g_const_string;
+}
+
+const ConstString &
+GetSettingNameForInputPath ()
+{
+ static ConstString g_const_string (TSC_STDIN_PATH);
+ return g_const_string;
+}
+
+const ConstString &
+GetSettingNameForOutputPath ()
+{
+ static ConstString g_const_string (TSC_STDOUT_PATH);
+ return g_const_string;
+}
+
+const ConstString &
+GetSettingNameForErrorPath ()
+{
+ static ConstString g_const_string (TSC_STDERR_PATH);
+ return g_const_string;
+}
+
+const ConstString &
+GetSettingNameForDisableASLR ()
+{
+ static ConstString g_const_string (TSC_DISABLE_ASLR);
+ return g_const_string;
+}
+
+const ConstString &
+GetSettingNameForDisableSTDIO ()
+{
+ static ConstString g_const_string (TSC_DISABLE_STDIO);
+ return g_const_string;
+}
bool
Target::SettingsController::SetGlobalVariable (const ConstString &var_name,
@@ -2094,7 +2157,16 @@
m_source_map (NULL, NULL),
m_max_children_display(256),
m_max_strlen_length(1024),
- m_breakpoints_use_platform_avoid (true, true)
+ m_breakpoints_use_platform_avoid (true, true),
+ m_run_args (),
+ m_env_vars (),
+ m_input_path (),
+ m_output_path (),
+ m_error_path (),
+ m_disable_aslr (true),
+ m_disable_stdio (false),
+ m_inherit_host_env (true),
+ m_got_host_env (false)
{
// CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called
// until the vtables for TargetInstanceSettings are properly set up, i.e. AFTER all the initializers.
@@ -2121,9 +2193,17 @@
m_prefer_dynamic_value (rhs.m_prefer_dynamic_value),
m_skip_prologue (rhs.m_skip_prologue),
m_source_map (rhs.m_source_map),
- m_max_children_display(rhs.m_max_children_display),
- m_max_strlen_length(rhs.m_max_strlen_length),
- m_breakpoints_use_platform_avoid (rhs.m_breakpoints_use_platform_avoid)
+ m_max_children_display (rhs.m_max_children_display),
+ m_max_strlen_length (rhs.m_max_strlen_length),
+ m_breakpoints_use_platform_avoid (rhs.m_breakpoints_use_platform_avoid),
+ m_run_args (rhs.m_run_args),
+ m_env_vars (rhs.m_env_vars),
+ m_input_path (rhs.m_input_path),
+ m_output_path (rhs.m_output_path),
+ m_error_path (rhs.m_error_path),
+ m_disable_aslr (rhs.m_disable_aslr),
+ m_disable_stdio (rhs.m_disable_stdio),
+ m_inherit_host_env (rhs.m_inherit_host_env)
{
if (m_instance_name != InstanceSettings::GetDefaultName())
{
@@ -2141,6 +2221,22 @@
{
if (this != &rhs)
{
+ m_expr_prefix_file = rhs.m_expr_prefix_file;
+ m_expr_prefix_contents_sp = rhs.m_expr_prefix_contents_sp;
+ m_prefer_dynamic_value = rhs.m_prefer_dynamic_value;
+ m_skip_prologue = rhs.m_skip_prologue;
+ m_source_map = rhs.m_source_map;
+ m_max_children_display = rhs.m_max_children_display;
+ m_max_strlen_length = rhs.m_max_strlen_length;
+ m_breakpoints_use_platform_avoid = rhs.m_breakpoints_use_platform_avoid;
+ m_run_args = rhs.m_run_args;
+ m_env_vars = rhs.m_env_vars;
+ m_input_path = rhs.m_input_path;
+ m_output_path = rhs.m_output_path;
+ m_error_path = rhs.m_error_path;
+ m_disable_aslr = rhs.m_disable_aslr;
+ m_disable_stdio = rhs.m_disable_stdio;
+ m_inherit_host_env = rhs.m_inherit_host_env;
}
return *this;
@@ -2274,6 +2370,39 @@
{
err = UserSettingsController::UpdateBooleanOptionValue (value, op, m_breakpoints_use_platform_avoid);
}
+ else if (var_name == GetSettingNameForRunArgs())
+ {
+ UserSettingsController::UpdateStringArrayVariable (op, index_value, m_run_args, value, err);
+ }
+ else if (var_name == GetSettingNameForEnvVars())
+ {
+ // This is nice for local debugging, but it is isn't correct for
+ // remote debugging. We need to stop process.env-vars from being
+ // populated with the host environment and add this as a launch option
+ // and get the correct environment from the Target's platform.
+ // GetHostEnvironmentIfNeeded ();
+ UserSettingsController::UpdateDictionaryVariable (op, index_value, m_env_vars, value, err);
+ }
+ else if (var_name == GetSettingNameForInputPath())
+ {
+ UserSettingsController::UpdateStringVariable (op, m_input_path, value, err);
+ }
+ else if (var_name == GetSettingNameForOutputPath())
+ {
+ UserSettingsController::UpdateStringVariable (op, m_output_path, value, err);
+ }
+ else if (var_name == GetSettingNameForErrorPath())
+ {
+ UserSettingsController::UpdateStringVariable (op, m_error_path, value, err);
+ }
+ else if (var_name == GetSettingNameForDisableASLR())
+ {
+ UserSettingsController::UpdateBooleanVariable (op, m_disable_aslr, value, true, err);
+ }
+ else if (var_name == GetSettingNameForDisableSTDIO ())
+ {
+ UserSettingsController::UpdateBooleanVariable (op, m_disable_stdio, value, false, err);
+ }
}
void
@@ -2284,13 +2413,7 @@
if (!new_settings_ptr)
return;
- m_expr_prefix_file = new_settings_ptr->m_expr_prefix_file;
- m_expr_prefix_contents_sp = new_settings_ptr->m_expr_prefix_contents_sp;
- m_prefer_dynamic_value = new_settings_ptr->m_prefer_dynamic_value;
- m_skip_prologue = new_settings_ptr->m_skip_prologue;
- m_max_children_display = new_settings_ptr->m_max_children_display;
- m_max_strlen_length = new_settings_ptr->m_max_strlen_length;
- m_breakpoints_use_platform_avoid = new_settings_ptr->m_breakpoints_use_platform_avoid;
+ *this = *new_settings_ptr;
}
bool
@@ -2339,16 +2462,115 @@
else
value.AppendString ("false");
}
+ else if (var_name == GetSettingNameForRunArgs())
+ {
+ if (m_run_args.GetArgumentCount() > 0)
+ {
+ for (int i = 0; i < m_run_args.GetArgumentCount(); ++i)
+ value.AppendString (m_run_args.GetArgumentAtIndex (i));
+ }
+ }
+ else if (var_name == GetSettingNameForEnvVars())
+ {
+ GetHostEnvironmentIfNeeded ();
+
+ if (m_env_vars.size() > 0)
+ {
+ std::map<std::string, std::string>::iterator pos;
+ for (pos = m_env_vars.begin(); pos != m_env_vars.end(); ++pos)
+ {
+ StreamString value_str;
+ value_str.Printf ("%s=%s", pos->first.c_str(), pos->second.c_str());
+ value.AppendString (value_str.GetData());
+ }
+ }
+ }
+ else if (var_name == GetSettingNameForInputPath())
+ {
+ value.AppendString (m_input_path.c_str());
+ }
+ else if (var_name == GetSettingNameForOutputPath())
+ {
+ value.AppendString (m_output_path.c_str());
+ }
+ else if (var_name == GetSettingNameForErrorPath())
+ {
+ value.AppendString (m_error_path.c_str());
+ }
+ else if (var_name == GetSettingNameForInheritHostEnv())
+ {
+ if (m_inherit_host_env)
+ value.AppendString ("true");
+ else
+ value.AppendString ("false");
+ }
+ else if (var_name == GetSettingNameForDisableASLR())
+ {
+ if (m_disable_aslr)
+ value.AppendString ("true");
+ else
+ value.AppendString ("false");
+ }
+ else if (var_name == GetSettingNameForDisableSTDIO())
+ {
+ if (m_disable_stdio)
+ value.AppendString ("true");
+ else
+ value.AppendString ("false");
+ }
else
{
if (err)
err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString());
return false;
}
-
return true;
}
+void
+Target::TargetInstanceSettings::GetHostEnvironmentIfNeeded ()
+{
+ if (m_inherit_host_env && !m_got_host_env)
+ {
+ m_got_host_env = true;
+ StringList host_env;
+ const size_t host_env_count = Host::GetEnvironment (host_env);
+ for (size_t idx=0; idx<host_env_count; idx++)
+ {
+ const char *env_entry = host_env.GetStringAtIndex (idx);
+ if (env_entry)
+ {
+ const char *equal_pos = ::strchr(env_entry, '=');
+ if (equal_pos)
+ {
+ std::string key (env_entry, equal_pos - env_entry);
+ std::string value (equal_pos + 1);
+ if (m_env_vars.find (key) == m_env_vars.end())
+ m_env_vars[key] = value;
+ }
+ }
+ }
+ }
+}
+
+
+size_t
+Target::TargetInstanceSettings::GetEnvironmentAsArgs (Args &env)
+{
+ GetHostEnvironmentIfNeeded ();
+
+ dictionary::const_iterator pos, end = m_env_vars.end();
+ for (pos = m_env_vars.begin(); pos != end; ++pos)
+ {
+ std::string env_var_equal_value (pos->first);
+ env_var_equal_value.append(1, '=');
+ env_var_equal_value.append (pos->second);
+ env.AppendArgument (env_var_equal_value.c_str());
+ }
+ return env.GetArgumentCount();
+}
+
+
const ConstString
TargetInstanceSettings::CreateInstanceName ()
{
@@ -2395,5 +2617,14 @@
{ TSC_MAX_CHILDREN , eSetVarTypeInt , "256" , NULL, true, false, "Maximum number of children to expand in any level of depth." },
{ TSC_MAX_STRLENSUMMARY , eSetVarTypeInt , "1024" , NULL, true, false, "Maximum number of characters to show when using %s in summary strings." },
{ TSC_PLATFORM_AVOID , eSetVarTypeBoolean, "true" , NULL, false, false, "Consult the platform module avoid list when setting non-module specific breakpoints." },
+ { TSC_RUN_ARGS , eSetVarTypeArray , NULL , NULL, false, false, "A list containing all the arguments to be passed to the executable when it is run." },
+ { TSC_ENV_VARS , eSetVarTypeDictionary, NULL , NULL, false, false, "A list of all the environment variables to be passed to the executable's environment, and their values." },
+ { TSC_INHERIT_ENV , eSetVarTypeBoolean, "true" , NULL, false, false, "Inherit the environment from the process that is running LLDB." },
+ { TSC_STDIN_PATH , eSetVarTypeString , NULL , NULL, false, false, "The file/path to be used by the executable program for reading its standard input." },
+ { TSC_STDOUT_PATH , eSetVarTypeString , NULL , NULL, false, false, "The file/path to be used by the executable program for writing its standard output." },
+ { TSC_STDERR_PATH , eSetVarTypeString , NULL , NULL, false, false, "The file/path to be used by the executable program for writing its standard error." },
+// { "plugin", eSetVarTypeEnum, NULL, NULL, false, false, "The plugin to be used to run the process." },
+ { TSC_DISABLE_ASLR , eSetVarTypeBoolean, "true" , NULL, false, false, "Disable Address Space Layout Randomization (ASLR)" },
+ { TSC_DISABLE_STDIO , eSetVarTypeBoolean, "false" , NULL, false, false, "Disable stdin/stdout for process (e.g. for a GUI application)" },
{ NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL }
};