summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-11-08 02:43:13 +0000
committerGreg Clayton <gclayton@apple.com>2011-11-08 02:43:13 +0000
commit1d8859668f49b36a8240f6b9da1c1db49fb60bf8 (patch)
treecae1ba6c95ee936710657fa65b2dd873f7b8586b /lldb/source/Commands
parentad45a8681dba6047e1bfdb85bb951ba9238213e1 (diff)
downloadbcm5719-llvm-1d8859668f49b36a8240f6b9da1c1db49fb60bf8.tar.gz
bcm5719-llvm-1d8859668f49b36a8240f6b9da1c1db49fb60bf8.zip
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. llvm-svn: 144061
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp42
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp147
-rw-r--r--lldb/source/Commands/CommandObjectSettings.cpp8
3 files changed, 99 insertions, 98 deletions
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 7c7762c60a7..e2136d32cac 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -374,17 +374,21 @@ public:
Error error;
const uint32_t argc = args.GetArgumentCount();
Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
- if (target)
+ if (target == NULL)
{
- Module *exe_module = target->GetExecutableModulePointer();
- if (exe_module)
- {
- m_options.launch_info.GetExecutableFile () = exe_module->GetFileSpec();
- char exe_path[PATH_MAX];
- if (m_options.launch_info.GetExecutableFile ().GetPath (exe_path, sizeof(exe_path)))
- m_options.launch_info.GetArguments().AppendArgument (exe_path);
- m_options.launch_info.GetArchitecture() = exe_module->GetArchitecture();
- }
+ result.AppendError ("invalid target, create a debug target using the 'target create' command");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+
+ Module *exe_module = target->GetExecutableModulePointer();
+ if (exe_module)
+ {
+ m_options.launch_info.GetExecutableFile () = exe_module->GetFileSpec();
+ char exe_path[PATH_MAX];
+ if (m_options.launch_info.GetExecutableFile ().GetPath (exe_path, sizeof(exe_path)))
+ m_options.launch_info.GetArguments().AppendArgument (exe_path);
+ m_options.launch_info.GetArchitecture() = exe_module->GetArchitecture();
}
if (argc > 0)
@@ -412,21 +416,9 @@ public:
if (argc == 0)
{
- lldb::UserSettingsControllerSP process_usc_sp (Process::GetSettingsController ());
- if (process_usc_sp)
- {
- SettableVariableType type;
- StringList settings_args (process_usc_sp->GetVariable ("process.run-args",
- type,
- m_interpreter.GetDebugger().GetInstanceName().GetCString(),
- error));
- if (error.Success())
- {
- const size_t num_settings_args = settings_args.GetSize();
- for (size_t i=0; i<num_settings_args; ++i)
- m_options.launch_info.GetArguments().AppendArgument (settings_args.GetStringAtIndex(i));
- }
- }
+ const Args &target_settings_args = target->GetRunArguments();
+ if (target_settings_args.GetArgumentCount())
+ m_options.launch_info.GetArguments() = target_settings_args;
}
ProcessSP process_sp (platform_sp->DebugProcess (m_options.launch_info,
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 2c8a0dd022d..ae6984e0f0a 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -151,7 +151,9 @@ public:
bool
Execute (Args& launch_args, CommandReturnObject &result)
{
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Debugger &debugger = m_interpreter.GetDebugger();
+ Target *target = debugger.GetSelectedTarget().get();
+ Error error;
if (target == NULL)
{
@@ -159,7 +161,6 @@ public:
result.SetStatus (eReturnStatusFailed);
return false;
}
-
// If our listener is NULL, users aren't allows to launch
char filename[PATH_MAX];
const Module *exe_module = target->GetExecutableModulePointer();
@@ -197,102 +198,110 @@ public:
}
else
{
- Error error (process->Destroy());
- if (error.Success())
+ Error destroy_error (process->Destroy());
+ if (destroy_error.Success())
{
result.SetStatus (eReturnStatusSuccessFinishResult);
}
else
{
- result.AppendErrorWithFormat ("Failed to kill process: %s\n", error.AsCString());
+ result.AppendErrorWithFormat ("Failed to kill process: %s\n", destroy_error.AsCString());
result.SetStatus (eReturnStatusFailed);
}
}
}
}
- if (state != eStateConnected)
- {
- const char *plugin_name = m_options.launch_info.GetProcessPluginName();
-
- process = target->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name).get();
- if (process == NULL)
- {
- result.AppendErrorWithFormat ("Failed to find a process plugin for executable.\n");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
- }
-
if (launch_args.GetArgumentCount() > 0)
{
m_options.launch_info.GetArguments().AppendArguments (launch_args);
}
- else
- {
- const Args &process_args = process->GetRunArguments();
- if (process_args.GetArgumentCount() > 0)
- m_options.launch_info.GetArguments().AppendArguments (process_args);
- }
-
- if (m_options.launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY))
+
+ if (state == eStateConnected)
{
- if (state == eStateConnected)
+ if (m_options.launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY))
{
- result.AppendWarning("launch in tty option is ignored when launching through a remote connection");
+ result.AppendWarning("can't launch in tty when launching through a remote connection");
m_options.launch_info.GetFlags().Clear (eLaunchFlagLaunchInTTY);
}
}
-
- Args environment;
- process->GetEnvironmentAsArgs (environment);
- m_options.launch_info.GetEnvironmentEntries ().AppendArguments (environment);
-
- if (process->GetDisableASLR())
- m_options.launch_info.GetFlags().Set (eLaunchFlagDisableASLR);
-
- if (m_options.launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY) == false &&
- m_options.launch_info.GetNumFileActions() == 0)
+ else
{
- // Only use the settings value if the user hasn't specified any options that would override it.
- if (process->GetDisableSTDIO())
- m_options.launch_info.GetFlags().Set (eLaunchFlagDisableSTDIO);
-
- const char *path;
- path = process->GetStandardErrorPath();
- if (path)
+ const char *plugin_name = m_options.launch_info.GetProcessPluginName();
+
+ if (m_options.launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY))
{
- ProcessLaunchInfo::FileAction file_action;
- const bool read = true;
- const bool write = true;
- if (file_action.Open(STDERR_FILENO, path, read, write))
- m_options.launch_info.AppendFileAction (file_action);
+ process = target->GetPlatform()->DebugProcess (m_options.launch_info,
+ debugger,
+ target,
+ debugger.GetListener(),
+ error).get();
}
- path = process->GetStandardInputPath();
- if (path)
+ else
{
- ProcessLaunchInfo::FileAction file_action;
- const bool read = true;
- const bool write = false;
- if (file_action.Open(STDIN_FILENO, path, read, write))
- m_options.launch_info.AppendFileAction (file_action);
- }
+ process = target->CreateProcess (debugger.GetListener(), plugin_name).get();
+
+ if (launch_args.GetArgumentCount() == 0)
+ {
+ const Args &process_args = target->GetRunArguments();
+ if (process_args.GetArgumentCount() > 0)
+ m_options.launch_info.GetArguments().AppendArguments (process_args);
+ }
- path = process->GetStandardOutputPath();
- if (path)
+ Args environment;
+ target->GetEnvironmentAsArgs (environment);
+ m_options.launch_info.GetEnvironmentEntries ().AppendArguments (environment);
+
+ if (target->GetDisableASLR())
+ m_options.launch_info.GetFlags().Set (eLaunchFlagDisableASLR);
+
+ if (m_options.launch_info.GetNumFileActions() == 0)
+ {
+ // Only use the settings value if the user hasn't specified any options that would override it.
+ if (target->GetDisableSTDIO())
+ m_options.launch_info.GetFlags().Set (eLaunchFlagDisableSTDIO);
+
+ const char *path;
+ path = target->GetStandardErrorPath();
+ if (path)
+ {
+ ProcessLaunchInfo::FileAction file_action;
+ const bool read = true;
+ const bool write = true;
+ if (file_action.Open(STDERR_FILENO, path, read, write))
+ m_options.launch_info.AppendFileAction (file_action);
+ }
+ path = target->GetStandardInputPath();
+ if (path)
+ {
+ ProcessLaunchInfo::FileAction file_action;
+ const bool read = true;
+ const bool write = false;
+ if (file_action.Open(STDIN_FILENO, path, read, write))
+ m_options.launch_info.AppendFileAction (file_action);
+ }
+
+ path = target->GetStandardOutputPath();
+ if (path)
+ {
+ ProcessLaunchInfo::FileAction file_action;
+ const bool read = false;
+ const bool write = true;
+ if (file_action.Open(STDOUT_FILENO, path, read, write))
+ m_options.launch_info.AppendFileAction (file_action);
+ }
+ }
+ error = process->Launch (m_options.launch_info);
+ }
+ if (process == NULL)
{
- ProcessLaunchInfo::FileAction file_action;
- const bool read = false;
- const bool write = true;
- if (file_action.Open(STDOUT_FILENO, path, read, write))
- m_options.launch_info.AppendFileAction (file_action);
+ result.AppendErrorWithFormat ("Failed to find a process plugin for executable.\n");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
}
}
- Error error;
-
- error = process->Launch (m_options.launch_info);
-
+
if (error.Success())
{
const char *archname = exe_module->GetArchitecture().GetArchitectureName();
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index 2421af5e882..63f5048b875 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -83,14 +83,14 @@ CommandObjectSettingsSet::CommandObjectSettingsSet (CommandInterpreter &interpre
"When setting a dictionary or array variable, you can set multiple entries \n\
at once by giving the values to the set command. For example: \n\
\n\
-(lldb) settings set target.process.run-args value1 value2 value3 \n\
-(lldb) settings set target.process.env-vars [\"MYPATH\"]=~/.:/usr/bin [\"SOME_ENV_VAR\"]=12345 \n\
+(lldb) settings set target.run-args value1 value2 value3 \n\
+(lldb) settings set target.env-vars [\"MYPATH\"]=~/.:/usr/bin [\"SOME_ENV_VAR\"]=12345 \n\
\n\
-(lldb) settings show target.process.run-args \n\
+(lldb) settings show target.run-args \n\
[0]: 'value1' \n\
[1]: 'value2' \n\
[3]: 'value3' \n\
-(lldb) settings show target.process.env-vars \n\
+(lldb) settings show target.env-vars \n\
'MYPATH=~/.:/usr/bin'\n\
'SOME_ENV_VAR=12345' \n\
\n\
OpenPOWER on IntegriCloud