summaryrefslogtreecommitdiff
path: root/source/Commands/CommandObjectProcess.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-07-28 11:09:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-07-28 11:09:23 +0000
commitf73363f1dd94996356cefbf24388f561891acf0b (patch)
treee3c31248bdb36eaec5fd833490d4278162dba2a0 /source/Commands/CommandObjectProcess.cpp
parent160ee69dd7ae18978f4068116777639ea98dc951 (diff)
Notes
Diffstat (limited to 'source/Commands/CommandObjectProcess.cpp')
-rw-r--r--source/Commands/CommandObjectProcess.cpp99
1 files changed, 41 insertions, 58 deletions
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index 9fbdd76305481..3ac27918df4cf 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -21,9 +21,9 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Host/StringConvert.h"
-#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
@@ -31,6 +31,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/UnixSignals.h"
+#include "lldb/Utility/Args.h"
using namespace lldb;
using namespace lldb_private;
@@ -133,20 +134,14 @@ public:
~CommandObjectProcessLaunch() override = default;
- int HandleArgumentCompletion(Args &input, int &cursor_index,
- int &cursor_char_position,
- OptionElementVector &opt_element_vector,
- int match_start_point, int max_return_elements,
- bool &word_complete,
- StringList &matches) override {
- std::string completion_str(input.GetArgumentAtIndex(cursor_index));
- completion_str.erase(cursor_char_position);
+ int HandleArgumentCompletion(
+ CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
- completion_str.c_str(), match_start_point, max_return_elements, nullptr,
- word_complete, matches);
- return matches.GetSize();
+ request, nullptr);
+ return request.GetMatches().GetSize();
}
Options *GetOptions() override { return &m_options; }
@@ -179,18 +174,18 @@ protected:
llvm::StringRef target_settings_argv0 = target->GetArg0();
// 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
+ // (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.
+ // 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.
+ // The user did not explicitly specify whether to disable ASLR. Fall
+ // back to the target.disable-aslr setting.
disable_aslr = target->GetDisableASLR();
}
@@ -205,11 +200,7 @@ protected:
if (target->GetDisableSTDIO())
m_options.launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO);
- Args environment;
- target->GetEnvironmentAsArgs(environment);
- if (environment.GetArgumentCount() > 0)
- m_options.launch_info.GetEnvironmentEntries().AppendArguments(
- environment);
+ m_options.launch_info.GetEnvironment() = target->GetEnvironment();
if (!target_settings_argv0.empty()) {
m_options.launch_info.GetArguments().AppendArgument(
@@ -237,11 +228,10 @@ protected:
ProcessSP process_sp(target->GetProcessSP());
if (process_sp) {
// There is a race condition where this thread will return up the call
- // stack to the main command
- // handler and show an (lldb) prompt before HandlePrivateEvent (from
- // PrivateStateThread) has
- // a chance to call PushProcessIOHandler().
- process_sp->SyncIOHandler(0, 2000);
+ // stack to the main command handler and show an (lldb) prompt before
+ // HandlePrivateEvent (from PrivateStateThread) has a chance to call
+ // PushProcessIOHandler().
+ process_sp->SyncIOHandler(0, std::chrono::seconds(2));
llvm::StringRef data = stream.GetString();
if (!data.empty())
@@ -362,7 +352,8 @@ public:
break;
case 'n':
- attach_info.GetExecutableFile().SetFile(option_arg, false);
+ attach_info.GetExecutableFile().SetFile(option_arg, false,
+ FileSpec::Style::native);
break;
case 'w':
@@ -390,11 +381,8 @@ public:
}
bool HandleOptionArgumentCompletion(
- Args &input, int cursor_index, int char_pos,
- OptionElementVector &opt_element_vector, int opt_element_index,
- int match_start_point, int max_return_elements,
- CommandInterpreter &interpreter, bool &word_complete,
- StringList &matches) override {
+ CompletionRequest &request, OptionElementVector &opt_element_vector,
+ int opt_element_index, CommandInterpreter &interpreter) override {
int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos;
int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index;
@@ -404,11 +392,10 @@ public:
// Are we in the name?
// Look to see if there is a -P argument provided, and if so use that
- // plugin, otherwise
- // use the default plugin.
+ // plugin, otherwise use the default plugin.
const char *partial_name = nullptr;
- partial_name = input.GetArgumentAtIndex(opt_arg_pos);
+ partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos);
PlatformSP platform_sp(interpreter.GetPlatform(true));
if (platform_sp) {
@@ -416,14 +403,14 @@ public:
ProcessInstanceInfoMatch match_info;
if (partial_name) {
match_info.GetProcessInfo().GetExecutableFile().SetFile(
- partial_name, false);
+ partial_name, false, FileSpec::Style::native);
match_info.SetNameMatchType(NameMatch::StartsWith);
}
platform_sp->FindProcesses(match_info, process_infos);
const size_t num_matches = process_infos.GetSize();
if (num_matches > 0) {
for (size_t i = 0; i < num_matches; ++i) {
- matches.AppendString(
+ request.GetMatches().AppendString(
process_infos.GetProcessNameAtIndex(i),
process_infos.GetProcessNameLengthAtIndex(i));
}
@@ -456,10 +443,9 @@ protected:
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
// N.B. The attach should be synchronous. It doesn't help much to get the
- // prompt back between initiating the attach
- // and the target actually stopping. So even if the interpreter is set to
- // be asynchronous, we wait for the stop
- // ourselves here.
+ // prompt back between initiating the attach and the target actually
+ // stopping. So even if the interpreter is set to be asynchronous, we wait
+ // for the stop ourselves here.
StateType state = eStateInvalid;
Process *process = m_exe_ctx.GetProcessPtr();
@@ -485,9 +471,8 @@ protected:
}
// Record the old executable module, we want to issue a warning if the
- // process of attaching changed the
- // current executable (like somebody said "file foo" then attached to a PID
- // whose executable was bar.)
+ // process of attaching changed the current executable (like somebody said
+ // "file foo" then attached to a PID whose executable was bar.)
ModuleSP old_exec_module_sp = target->GetExecutableModule();
ArchSpec old_arch_spec = target->GetArchitecture();
@@ -556,8 +541,8 @@ protected:
target->GetArchitecture().GetTriple().getTriple().c_str());
}
- // This supports the use-case scenario of immediately continuing the process
- // once attached.
+ // This supports the use-case scenario of immediately continuing the
+ // process once attached.
if (m_options.attach_info.GetContinueOnceAttached())
m_interpreter.HandleCommand("process continue", eLazyBoolNo, result);
@@ -695,11 +680,10 @@ protected:
if (error.Success()) {
// There is a race condition where this thread will return up the call
- // stack to the main command
- // handler and show an (lldb) prompt before HandlePrivateEvent (from
- // PrivateStateThread) has
- // a chance to call PushProcessIOHandler().
- process->SyncIOHandler(iohandler_id, 2000);
+ // stack to the main command handler and show an (lldb) prompt before
+ // HandlePrivateEvent (from PrivateStateThread) has a chance to call
+ // PushProcessIOHandler().
+ process->SyncIOHandler(iohandler_id, std::chrono::seconds(2));
result.AppendMessageWithFormat("Process %" PRIu64 " resuming\n",
process->GetID());
@@ -760,7 +744,7 @@ public:
case 's':
bool tmp_result;
bool success;
- tmp_result = Args::StringToBoolean(option_arg, false, &success);
+ tmp_result = OptionArgParser::ToBoolean(option_arg, false, &success);
if (!success)
error.SetErrorStringWithFormat("invalid boolean option: \"%s\"",
option_arg.str().c_str());
@@ -991,7 +975,7 @@ public:
case 'i':
do_install = true;
if (!option_arg.empty())
- install_path.SetFile(option_arg, false);
+ install_path.SetFile(option_arg, false, FileSpec::Style::native);
break;
default:
error.SetErrorStringWithFormat("invalid short option character '%c'",
@@ -1444,7 +1428,7 @@ public:
bool VerifyCommandOptionValue(const std::string &option, int &real_value) {
bool okay = true;
bool success = false;
- bool tmp_value = Args::StringToBoolean(option, false, &success);
+ bool tmp_value = OptionArgParser::ToBoolean(option, false, &success);
if (success && tmp_value)
real_value = 1;
@@ -1563,8 +1547,7 @@ protected:
int32_t signo = signals_sp->GetSignalNumberFromName(arg.c_str());
if (signo != LLDB_INVALID_SIGNAL_NUMBER) {
// Casting the actions as bools here should be okay, because
- // VerifyCommandOptionValue guarantees
- // the value is either 0 or 1.
+ // VerifyCommandOptionValue guarantees the value is either 0 or 1.
if (stop_action != -1)
signals_sp->SetShouldStop(signo, stop_action);
if (pass_action != -1) {