aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectProcess.cpp
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2013-04-30 23:46:08 +0000
committerJim Ingham <jingham@apple.com>2013-04-30 23:46:08 +0000
commita23f73dbbcbc6008162767d64bb019389e6a1bd7 (patch)
tree0ce26237946ccfc99aa54c9f17b996201de04fd2 /lldb/source/Commands/CommandObjectProcess.cpp
parent3ca3cd1ed7f37eef0f9e9c0b39d64ee2d12815b4 (diff)
downloadllvm-a23f73dbbcbc6008162767d64bb019389e6a1bd7.zip
llvm-a23f73dbbcbc6008162767d64bb019389e6a1bd7.tar.gz
llvm-a23f73dbbcbc6008162767d64bb019389e6a1bd7.tar.bz2
Added an option to "process detach" to keep the process stopped, if the process plugin (or in the
case of ProcessGDBRemote the stub we are talking to) know how to do that. rdar://problem/13680832 llvm-svn: 180831
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp101
1 files changed, 98 insertions, 3 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 2221514..7ad5f7b 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -75,7 +75,8 @@ protected:
{
if (process->GetShouldDetach())
{
- Error detach_error (process->Detach());
+ bool keep_stopped = false;
+ Error detach_error (process->Detach(keep_stopped));
if (detach_error.Success())
{
result.SetStatus (eReturnStatusSuccessFinishResult);
@@ -903,6 +904,68 @@ CommandObjectProcessContinue::CommandOptions::g_option_table[] =
class CommandObjectProcessDetach : public CommandObjectParsed
{
public:
+ class CommandOptions : public Options
+ {
+ public:
+
+ CommandOptions (CommandInterpreter &interpreter) :
+ Options (interpreter)
+ {
+ OptionParsingStarting ();
+ }
+
+ ~CommandOptions ()
+ {
+ }
+
+ Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg)
+ {
+ Error error;
+ const int short_option = m_getopt_table[option_idx].val;
+
+ switch (short_option)
+ {
+ case 's':
+ bool tmp_result;
+ bool success;
+ tmp_result = Args::StringToBoolean(option_arg, false, &success);
+ if (!success)
+ error.SetErrorStringWithFormat("invalid boolean option: \"%s\"", option_arg);
+ else
+ {
+ if (tmp_result)
+ m_keep_stopped = eLazyBoolYes;
+ else
+ m_keep_stopped = eLazyBoolNo;
+ }
+ break;
+ default:
+ error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
+ break;
+ }
+ return error;
+ }
+
+ void
+ OptionParsingStarting ()
+ {
+ m_keep_stopped = eLazyBoolCalculate;
+ }
+
+ const OptionDefinition*
+ GetDefinitions ()
+ {
+ return g_option_table;
+ }
+
+ // Options table: Required for subclasses of Options.
+
+ static OptionDefinition g_option_table[];
+
+ // Instance variables to hold the values for command options.
+ LazyBool m_keep_stopped;
+ };
CommandObjectProcessDetach (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
@@ -911,7 +974,8 @@ public:
"process detach",
eFlagRequiresProcess |
eFlagTryTargetAPILock |
- eFlagProcessMustBeLaunched)
+ eFlagProcessMustBeLaunched),
+ m_options(interpreter)
{
}
@@ -919,13 +983,35 @@ public:
{
}
+ Options *
+ GetOptions ()
+ {
+ return &m_options;
+ }
+
+
protected:
bool
DoExecute (Args& command, CommandReturnObject &result)
{
Process *process = m_exe_ctx.GetProcessPtr();
result.AppendMessageWithFormat ("Detaching from process %" PRIu64 "\n", process->GetID());
- Error error (process->Detach());
+ // FIXME: This will be a Command Option:
+ bool keep_stopped;
+ if (m_options.m_keep_stopped == eLazyBoolCalculate)
+ {
+ // Check the process default:
+ if (process->GetDetachKeepsStopped())
+ keep_stopped = true;
+ else
+ keep_stopped = false;
+ }
+ else if (m_options.m_keep_stopped == eLazyBoolYes)
+ keep_stopped = true;
+ else
+ keep_stopped = false;
+
+ Error error (process->Detach(keep_stopped));
if (error.Success())
{
result.SetStatus (eReturnStatusSuccessFinishResult);
@@ -938,6 +1024,15 @@ protected:
}
return result.Succeeded();
}
+
+ CommandOptions m_options;
+};
+
+OptionDefinition
+CommandObjectProcessDetach::CommandOptions::g_option_table[] =
+{
+{ LLDB_OPT_SET_1, false, "keep-stopped", 's', required_argument, NULL, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." },
+{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
};
//-------------------------------------------------------------------------