Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,57 @@
add_lldb_library(lldbInterpreter
Args.cpp
CommandAlias.cpp
CommandHistory.cpp
CommandInterpreter.cpp
CommandObject.cpp
CommandObjectRegexCommand.cpp
CommandObjectScript.cpp
CommandOptionValidators.cpp
CommandReturnObject.cpp
OptionGroupArchitecture.cpp
OptionGroupBoolean.cpp
OptionGroupFile.cpp
OptionGroupFormat.cpp
OptionGroupOutputFile.cpp
OptionGroupPlatform.cpp
OptionGroupString.cpp
OptionGroupUInt64.cpp
OptionGroupUUID.cpp
OptionGroupValueObjectDisplay.cpp
OptionValue.cpp
OptionValueArch.cpp
OptionValueArgs.cpp
OptionValueArray.cpp
OptionValueBoolean.cpp
OptionValueChar.cpp
OptionValueDictionary.cpp
OptionValueEnumeration.cpp
OptionValueFileSpec.cpp
OptionValueFileSpecLIst.cpp
OptionValueFormat.cpp
OptionValueFormatEntity.cpp
OptionValueLanguage.cpp
OptionValuePathMappings.cpp
OptionValueProperties.cpp
OptionValueRegex.cpp
OptionValueSInt64.cpp
OptionValueString.cpp
OptionValueUInt64.cpp
OptionValueUUID.cpp
OptionGroupVariable.cpp
OptionGroupWatchpoint.cpp
Options.cpp
Property.cpp
ScriptInterpreter.cpp
LINK_LIBS
lldbCommands
lldbCore
lldbDataFormatters
lldbHost
lldbTarget
lldbUtility
LINK_COMPONENTS
Support
)

View File

@@ -0,0 +1,252 @@
//===-- CommandAlias.cpp -----------------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/CommandAlias.h"
#include "llvm/Support/ErrorHandling.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp,
llvm::StringRef options_args,
OptionArgVectorSP &option_arg_vector_sp) {
bool success = true;
OptionArgVector *option_arg_vector = option_arg_vector_sp.get();
if (options_args.size() < 1)
return true;
Args args(options_args);
std::string options_string(options_args);
CommandReturnObject result;
// Check to see if the command being aliased can take any command options.
Options *options = cmd_obj_sp->GetOptions();
if (options) {
// See if any options were specified as part of the alias; if so, handle
// them appropriately.
ExecutionContext exe_ctx =
cmd_obj_sp->GetCommandInterpreter().GetExecutionContext();
options->NotifyOptionParsingStarting(&exe_ctx);
args.Unshift(llvm::StringRef("dummy_arg"));
options_string = args.ParseAliasOptions(*options, result, option_arg_vector,
options_args);
args.Shift();
if (result.Succeeded())
options->VerifyPartialOptions(result);
if (!result.Succeeded() &&
result.GetStatus() != lldb::eReturnStatusStarted) {
result.AppendError("Unable to create requested alias.\n");
return false;
}
}
if (!options_string.empty()) {
if (cmd_obj_sp->WantsRawCommandString())
option_arg_vector->emplace_back("<argument>", -1, options_string);
else {
for (auto &entry : args.entries()) {
if (!entry.ref.empty())
option_arg_vector->emplace_back("<argument>", -1, entry.ref);
}
}
}
return success;
}
CommandAlias::CommandAlias(CommandInterpreter &interpreter,
lldb::CommandObjectSP cmd_sp,
llvm::StringRef options_args, llvm::StringRef name,
llvm::StringRef help, llvm::StringRef syntax,
uint32_t flags)
: CommandObject(interpreter, name, help, syntax, flags),
m_underlying_command_sp(), m_option_string(options_args),
m_option_args_sp(new OptionArgVector),
m_is_dashdash_alias(eLazyBoolCalculate), m_did_set_help(false),
m_did_set_help_long(false) {
if (ProcessAliasOptionsArgs(cmd_sp, options_args, m_option_args_sp)) {
m_underlying_command_sp = cmd_sp;
for (int i = 0;
auto cmd_entry = m_underlying_command_sp->GetArgumentEntryAtIndex(i);
i++) {
m_arguments.push_back(*cmd_entry);
}
if (!help.empty()) {
StreamString sstr;
StreamString translation_and_help;
GetAliasExpansion(sstr);
translation_and_help.Printf(
"(%s) %s", sstr.GetData(),
GetUnderlyingCommand()->GetHelp().str().c_str());
SetHelp(translation_and_help.GetString());
}
}
}
bool CommandAlias::WantsRawCommandString() {
if (IsValid())
return m_underlying_command_sp->WantsRawCommandString();
return false;
}
bool CommandAlias::WantsCompletion() {
if (IsValid())
return m_underlying_command_sp->WantsCompletion();
return false;
}
int CommandAlias::HandleCompletion(Args &input, int &cursor_index,
int &cursor_char_position,
int match_start_point,
int max_return_elements, bool &word_complete,
StringList &matches) {
if (IsValid())
return m_underlying_command_sp->HandleCompletion(
input, cursor_index, cursor_char_position, match_start_point,
max_return_elements, word_complete, matches);
return -1;
}
int CommandAlias::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) {
if (IsValid())
return m_underlying_command_sp->HandleArgumentCompletion(
input, cursor_index, cursor_char_position, opt_element_vector,
match_start_point, max_return_elements, word_complete, matches);
return -1;
}
Options *CommandAlias::GetOptions() {
if (IsValid())
return m_underlying_command_sp->GetOptions();
return nullptr;
}
bool CommandAlias::Execute(const char *args_string,
CommandReturnObject &result) {
llvm_unreachable("CommandAlias::Execute is not to be called");
}
void CommandAlias::GetAliasExpansion(StreamString &help_string) const {
llvm::StringRef command_name = m_underlying_command_sp->GetCommandName();
help_string.Printf("'%*s", (int)command_name.size(), command_name.data());
if (!m_option_args_sp) {
help_string.Printf("'");
return;
}
OptionArgVector *options = m_option_args_sp.get();
std::string opt;
std::string value;
for (const auto &opt_entry : *options) {
std::tie(opt, std::ignore, value) = opt_entry;
if (opt == "<argument>") {
help_string.Printf(" %s", value.c_str());
} else {
help_string.Printf(" %s", opt.c_str());
if ((value.compare("<no-argument>") != 0) &&
(value.compare("<need-argument") != 0)) {
help_string.Printf(" %s", value.c_str());
}
}
}
help_string.Printf("'");
}
bool CommandAlias::IsDashDashCommand() {
if (m_is_dashdash_alias != eLazyBoolCalculate)
return (m_is_dashdash_alias == eLazyBoolYes);
m_is_dashdash_alias = eLazyBoolNo;
if (!IsValid())
return false;
std::string opt;
std::string value;
for (const auto &opt_entry : *GetOptionArguments()) {
std::tie(opt, std::ignore, value) = opt_entry;
if (opt == "<argument>" && !value.empty() &&
llvm::StringRef(value).endswith("--")) {
m_is_dashdash_alias = eLazyBoolYes;
break;
}
}
// if this is a nested alias, it may be adding arguments on top of an
// already dash-dash alias
if ((m_is_dashdash_alias == eLazyBoolNo) && IsNestedAlias())
m_is_dashdash_alias =
(GetUnderlyingCommand()->IsDashDashCommand() ? eLazyBoolYes
: eLazyBoolNo);
return (m_is_dashdash_alias == eLazyBoolYes);
}
bool CommandAlias::IsNestedAlias() {
if (GetUnderlyingCommand())
return GetUnderlyingCommand()->IsAlias();
return false;
}
std::pair<lldb::CommandObjectSP, OptionArgVectorSP> CommandAlias::Desugar() {
auto underlying = GetUnderlyingCommand();
if (!underlying)
return {nullptr, nullptr};
if (underlying->IsAlias()) {
auto desugared = ((CommandAlias *)underlying.get())->Desugar();
auto options = GetOptionArguments();
options->insert(options->begin(), desugared.second->begin(),
desugared.second->end());
return {desugared.first, options};
}
return {underlying, GetOptionArguments()};
}
// allow CommandAlias objects to provide their own help, but fallback to the
// info
// for the underlying command if no customization has been provided
void CommandAlias::SetHelp(llvm::StringRef str) {
this->CommandObject::SetHelp(str);
m_did_set_help = true;
}
void CommandAlias::SetHelpLong(llvm::StringRef str) {
this->CommandObject::SetHelpLong(str);
m_did_set_help_long = true;
}
llvm::StringRef CommandAlias::GetHelp() {
if (!m_cmd_help_short.empty() || m_did_set_help)
return m_cmd_help_short;
if (IsValid())
return m_underlying_command_sp->GetHelp();
return llvm::StringRef();
}
llvm::StringRef CommandAlias::GetHelpLong() {
if (!m_cmd_help_long.empty() || m_did_set_help_long)
return m_cmd_help_long;
if (IsValid())
return m_underlying_command_sp->GetHelpLong();
return llvm::StringRef();
}

View File

@@ -0,0 +1,110 @@
//===-- CommandHistory.cpp --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <inttypes.h>
#include "lldb/Interpreter/CommandHistory.h"
using namespace lldb;
using namespace lldb_private;
CommandHistory::CommandHistory() : m_mutex(), m_history() {}
CommandHistory::~CommandHistory() {}
size_t CommandHistory::GetSize() const {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_history.size();
}
bool CommandHistory::IsEmpty() const {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_history.empty();
}
llvm::Optional<llvm::StringRef>
CommandHistory::FindString(llvm::StringRef input_str) const {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (input_str.size() < 2)
return llvm::None;
if (input_str[0] != g_repeat_char)
return llvm::None;
if (input_str[1] == g_repeat_char) {
if (m_history.empty())
return llvm::None;
return llvm::StringRef(m_history.back());
}
input_str = input_str.drop_front();
size_t idx = 0;
if (input_str.front() == '-') {
if (input_str.drop_front(1).getAsInteger(0, idx))
return llvm::None;
if (idx >= m_history.size())
return llvm::None;
idx = m_history.size() - idx;
} else {
if (input_str.getAsInteger(0, idx))
return llvm::None;
if (idx >= m_history.size())
return llvm::None;
}
return llvm::StringRef(m_history[idx]);
}
llvm::StringRef CommandHistory::GetStringAtIndex(size_t idx) const {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (idx < m_history.size())
return m_history[idx];
return "";
}
llvm::StringRef CommandHistory::operator[](size_t idx) const {
return GetStringAtIndex(idx);
}
llvm::StringRef CommandHistory::GetRecentmostString() const {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_history.empty())
return "";
return m_history.back();
}
void CommandHistory::AppendString(llvm::StringRef str, bool reject_if_dupe) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (reject_if_dupe) {
if (!m_history.empty()) {
if (str == m_history.back())
return;
}
}
m_history.push_back(str);
}
void CommandHistory::Clear() {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_history.clear();
}
void CommandHistory::Dump(Stream &stream, size_t start_idx,
size_t stop_idx) const {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
stop_idx = std::min(stop_idx + 1, m_history.size());
for (size_t counter = start_idx; counter < stop_idx; counter++) {
const std::string hist_item = m_history[counter];
if (!hist_item.empty()) {
stream.Indent();
stream.Printf("%4" PRIu64 ": %s\n", (uint64_t)counter, hist_item.c_str());
}
}
}

View File

@@ -0,0 +1 @@
8dc5637b6e4ebec1543b41e3a46f3394f72b5145

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,121 @@
//===-- CommandObjectRegexCommand.cpp ---------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/CommandObjectRegexCommand.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
using namespace lldb;
using namespace lldb_private;
//----------------------------------------------------------------------
// CommandObjectRegexCommand constructor
//----------------------------------------------------------------------
CommandObjectRegexCommand::CommandObjectRegexCommand(
CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help,
llvm::StringRef syntax, uint32_t max_matches, uint32_t completion_type_mask,
bool is_removable)
: CommandObjectRaw(interpreter, name, help, syntax),
m_max_matches(max_matches), m_completion_type_mask(completion_type_mask),
m_entries(), m_is_removable(is_removable) {}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
CommandObjectRegexCommand::~CommandObjectRegexCommand() {}
bool CommandObjectRegexCommand::DoExecute(const char *command,
CommandReturnObject &result) {
if (command) {
EntryCollection::const_iterator pos, end = m_entries.end();
for (pos = m_entries.begin(); pos != end; ++pos) {
RegularExpression::Match regex_match(m_max_matches);
if (pos->regex.Execute(command, &regex_match)) {
std::string new_command(pos->command);
std::string match_str;
char percent_var[8];
size_t idx, percent_var_idx;
for (uint32_t match_idx = 1; match_idx <= m_max_matches; ++match_idx) {
if (regex_match.GetMatchAtIndex(command, match_idx, match_str)) {
const int percent_var_len =
::snprintf(percent_var, sizeof(percent_var), "%%%u", match_idx);
for (idx = 0; (percent_var_idx = new_command.find(
percent_var, idx)) != std::string::npos;) {
new_command.erase(percent_var_idx, percent_var_len);
new_command.insert(percent_var_idx, match_str);
idx += percent_var_idx + match_str.size();
}
}
}
// Interpret the new command and return this as the result!
if (m_interpreter.GetExpandRegexAliases())
result.GetOutputStream().Printf("%s\n", new_command.c_str());
// Pass in true for "no context switching". The command that called us
// should have set up the context
// appropriately, we shouldn't have to redo that.
return m_interpreter.HandleCommand(new_command.c_str(),
eLazyBoolCalculate, result, nullptr,
true, true);
}
}
result.SetStatus(eReturnStatusFailed);
if (!GetSyntax().empty())
result.AppendError(GetSyntax());
else
result.AppendErrorWithFormat("Command contents '%s' failed to match any "
"regular expression in the '%s' regex "
"command.\n",
command, m_cmd_name.c_str());
return false;
}
result.AppendError("empty command passed to regular expression command");
result.SetStatus(eReturnStatusFailed);
return false;
}
bool CommandObjectRegexCommand::AddRegexCommand(const char *re_cstr,
const char *command_cstr) {
m_entries.resize(m_entries.size() + 1);
// Only add the regular expression if it compiles
if (m_entries.back().regex.Compile(
llvm::StringRef::withNullAsEmpty(re_cstr))) {
m_entries.back().command.assign(command_cstr);
return true;
}
// The regex didn't compile...
m_entries.pop_back();
return false;
}
int CommandObjectRegexCommand::HandleCompletion(Args &input, int &cursor_index,
int &cursor_char_position,
int match_start_point,
int max_return_elements,
bool &word_complete,
StringList &matches) {
if (m_completion_type_mask) {
std::string completion_str(input.GetArgumentAtIndex(cursor_index),
cursor_char_position);
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), m_completion_type_mask, completion_str.c_str(),
match_start_point, max_return_elements, nullptr, word_complete,
matches);
return matches.GetSize();
} else {
matches.Clear();
word_complete = false;
}
return 0;
}

View File

@@ -0,0 +1,86 @@
//===-- CommandObjectScript.cpp ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "CommandObjectScript.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Debugger.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
using namespace lldb;
using namespace lldb_private;
//-------------------------------------------------------------------------
// CommandObjectScript
//-------------------------------------------------------------------------
CommandObjectScript::CommandObjectScript(CommandInterpreter &interpreter,
ScriptLanguage script_lang)
: CommandObjectRaw(
interpreter, "script",
"Invoke the script interpreter with provided code and display any "
"results. Start the interactive interpreter if no code is supplied.",
"script [<script-code>]") {}
CommandObjectScript::~CommandObjectScript() {}
bool CommandObjectScript::DoExecute(const char *command,
CommandReturnObject &result) {
#ifdef LLDB_DISABLE_PYTHON
// if we ever support languages other than Python this simple #ifdef won't
// work
result.AppendError("your copy of LLDB does not support scripting.");
result.SetStatus(eReturnStatusFailed);
return false;
#else
if (m_interpreter.GetDebugger().GetScriptLanguage() ==
lldb::eScriptLanguageNone) {
result.AppendError(
"the script-lang setting is set to none - scripting not available");
result.SetStatus(eReturnStatusFailed);
return false;
}
ScriptInterpreter *script_interpreter = m_interpreter.GetScriptInterpreter();
if (script_interpreter == nullptr) {
result.AppendError("no script interpreter");
result.SetStatus(eReturnStatusFailed);
return false;
}
DataVisualization::ForceUpdate(); // script might change Python code we use
// for formatting.. make sure we keep up to
// date with it
if (command == nullptr || command[0] == '\0') {
script_interpreter->ExecuteInterpreterLoop();
result.SetStatus(eReturnStatusSuccessFinishNoResult);
return result.Succeeded();
}
// We can do better when reporting the status of one-liner script execution.
if (script_interpreter->ExecuteOneLine(command, &result))
result.SetStatus(eReturnStatusSuccessFinishNoResult);
else
result.SetStatus(eReturnStatusFailed);
return result.Succeeded();
#endif
}

View File

@@ -0,0 +1,38 @@
//===-- CommandObjectScript.h -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_CommandObjectScript_h_
#define liblldb_CommandObjectScript_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Interpreter/CommandObject.h"
namespace lldb_private {
//-------------------------------------------------------------------------
// CommandObjectScript
//-------------------------------------------------------------------------
class CommandObjectScript : public CommandObjectRaw {
public:
CommandObjectScript(CommandInterpreter &interpreter,
lldb::ScriptLanguage script_lang);
~CommandObjectScript() override;
protected:
bool DoExecute(const char *command, CommandReturnObject &result) override;
};
} // namespace lldb_private
#endif // liblldb_CommandObjectScript_h_

View File

@@ -0,0 +1,37 @@
//===-- CommandOptionValidators.cpp -----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/CommandOptionValidators.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Target/Platform.h"
using namespace lldb;
using namespace lldb_private;
bool PosixPlatformCommandOptionValidator::IsValid(
Platform &platform, const ExecutionContext &target) const {
llvm::Triple::OSType os =
platform.GetSystemArchitecture().GetTriple().getOS();
switch (os) {
// Are there any other platforms that are not POSIX-compatible?
case llvm::Triple::Win32:
return false;
default:
return true;
}
}
const char *PosixPlatformCommandOptionValidator::ShortConditionString() const {
return "POSIX";
}
const char *PosixPlatformCommandOptionValidator::LongConditionString() const {
return "Option only valid for POSIX-compliant hosts.";
}

View File

@@ -0,0 +1,175 @@
//===-- CommandReturnObject.cpp ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/CommandReturnObject.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
static void DumpStringToStreamWithNewline(Stream &strm, const std::string &s,
bool add_newline_if_empty) {
bool add_newline = false;
if (s.empty()) {
add_newline = add_newline_if_empty;
} else {
// We already checked for empty above, now make sure there is a newline
// in the error, and if there isn't one, add one.
strm.Write(s.c_str(), s.size());
const char last_char = *s.rbegin();
add_newline = last_char != '\n' && last_char != '\r';
}
if (add_newline)
strm.EOL();
}
CommandReturnObject::CommandReturnObject()
: m_out_stream(), m_err_stream(), m_status(eReturnStatusStarted),
m_did_change_process_state(false), m_interactive(true),
m_abnormal_stop_was_expected(false) {}
CommandReturnObject::~CommandReturnObject() {}
void CommandReturnObject::AppendErrorWithFormat(const char *format, ...) {
if (!format)
return;
va_list args;
va_start(args, format);
StreamString sstrm;
sstrm.PrintfVarArg(format, args);
va_end(args);
const std::string &s = sstrm.GetString();
if (!s.empty()) {
Stream &error_strm = GetErrorStream();
error_strm.PutCString("error: ");
DumpStringToStreamWithNewline(error_strm, s, false);
}
}
void CommandReturnObject::AppendMessageWithFormat(const char *format, ...) {
if (!format)
return;
va_list args;
va_start(args, format);
StreamString sstrm;
sstrm.PrintfVarArg(format, args);
va_end(args);
GetOutputStream() << sstrm.GetString();
}
void CommandReturnObject::AppendWarningWithFormat(const char *format, ...) {
if (!format)
return;
va_list args;
va_start(args, format);
StreamString sstrm;
sstrm.PrintfVarArg(format, args);
va_end(args);
GetErrorStream() << "warning: " << sstrm.GetString();
}
void CommandReturnObject::AppendMessage(llvm::StringRef in_string) {
if (in_string.empty())
return;
GetOutputStream() << in_string << "\n";
}
void CommandReturnObject::AppendWarning(llvm::StringRef in_string) {
if (in_string.empty())
return;
GetErrorStream() << "warning: " << in_string << "\n";
}
// Similar to AppendWarning, but do not prepend 'warning: ' to message, and
// don't append "\n" to the end of it.
void CommandReturnObject::AppendRawWarning(llvm::StringRef in_string) {
if (in_string.empty())
return;
GetErrorStream() << in_string;
}
void CommandReturnObject::AppendError(llvm::StringRef in_string) {
if (in_string.empty())
return;
GetErrorStream() << "error: " << in_string << "\n";
}
void CommandReturnObject::SetError(const Status &error,
const char *fallback_error_cstr) {
const char *error_cstr = error.AsCString();
if (error_cstr == nullptr)
error_cstr = fallback_error_cstr;
SetError(error_cstr);
}
void CommandReturnObject::SetError(llvm::StringRef error_str) {
if (error_str.empty())
return;
AppendError(error_str);
SetStatus(eReturnStatusFailed);
}
// Similar to AppendError, but do not prepend 'Status: ' to message, and
// don't append "\n" to the end of it.
void CommandReturnObject::AppendRawError(llvm::StringRef in_string) {
if (in_string.empty())
return;
GetErrorStream() << in_string;
}
void CommandReturnObject::SetStatus(ReturnStatus status) { m_status = status; }
ReturnStatus CommandReturnObject::GetStatus() { return m_status; }
bool CommandReturnObject::Succeeded() {
return m_status <= eReturnStatusSuccessContinuingResult;
}
bool CommandReturnObject::HasResult() {
return (m_status == eReturnStatusSuccessFinishResult ||
m_status == eReturnStatusSuccessContinuingResult);
}
void CommandReturnObject::Clear() {
lldb::StreamSP stream_sp;
stream_sp = m_out_stream.GetStreamAtIndex(eStreamStringIndex);
if (stream_sp)
static_cast<StreamString *>(stream_sp.get())->Clear();
stream_sp = m_err_stream.GetStreamAtIndex(eStreamStringIndex);
if (stream_sp)
static_cast<StreamString *>(stream_sp.get())->Clear();
m_status = eReturnStatusStarted;
m_did_change_process_state = false;
m_interactive = true;
}
bool CommandReturnObject::GetDidChangeProcessState() {
return m_did_change_process_state;
}
void CommandReturnObject::SetDidChangeProcessState(bool b) {
m_did_change_process_state = b;
}
bool CommandReturnObject::GetInteractive() const { return m_interactive; }
void CommandReturnObject::SetInteractive(bool b) { m_interactive = b; }

View File

@@ -0,0 +1,60 @@
//===-- OptionGroupArchitecture.cpp -----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/OptionGroupArchitecture.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Target/Platform.h"
using namespace lldb;
using namespace lldb_private;
OptionGroupArchitecture::OptionGroupArchitecture() : m_arch_str() {}
OptionGroupArchitecture::~OptionGroupArchitecture() {}
static OptionDefinition g_option_table[] = {
{LLDB_OPT_SET_1, false, "arch", 'a', OptionParser::eRequiredArgument,
nullptr, nullptr, 0, eArgTypeArchitecture,
"Specify the architecture for the target."},
};
llvm::ArrayRef<OptionDefinition> OptionGroupArchitecture::GetDefinitions() {
return llvm::makeArrayRef(g_option_table);
}
bool OptionGroupArchitecture::GetArchitecture(Platform *platform,
ArchSpec &arch) {
arch = Platform::GetAugmentedArchSpec(platform, m_arch_str);
return arch.IsValid();
}
Status
OptionGroupArchitecture::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_arg,
ExecutionContext *execution_context) {
Status error;
const int short_option = g_option_table[option_idx].short_option;
switch (short_option) {
case 'a':
m_arch_str.assign(option_arg);
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
break;
}
return error;
}
void OptionGroupArchitecture::OptionParsingStarting(
ExecutionContext *execution_context) {
m_arch_str.clear();
}

View File

@@ -0,0 +1,61 @@
//===-- OptionGroupBoolean.cpp ----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/OptionGroupBoolean.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Host/OptionParser.h"
using namespace lldb;
using namespace lldb_private;
OptionGroupBoolean::OptionGroupBoolean(uint32_t usage_mask, bool required,
const char *long_option,
int short_option, const char *usage_text,
bool default_value,
bool no_argument_toggle_default)
: m_value(default_value, default_value) {
m_option_definition.usage_mask = usage_mask;
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = no_argument_toggle_default
? OptionParser::eNoArgument
: OptionParser::eRequiredArgument;
m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = 0;
m_option_definition.argument_type = eArgTypeBoolean;
m_option_definition.usage_text = usage_text;
}
OptionGroupBoolean::~OptionGroupBoolean() {}
Status OptionGroupBoolean::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_value,
ExecutionContext *execution_context) {
Status error;
if (m_option_definition.option_has_arg == OptionParser::eNoArgument) {
// Not argument, toggle the default value and mark the option as having been
// set
m_value.SetCurrentValue(!m_value.GetDefaultValue());
m_value.SetOptionWasSet();
} else {
error = m_value.SetValueFromString(option_value);
}
return error;
}
void OptionGroupBoolean::OptionParsingStarting(
ExecutionContext *execution_context) {
m_value.Clear();
}

View File

@@ -0,0 +1,83 @@
//===-- OptionGroupFile.cpp -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/OptionGroupFile.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Host/OptionParser.h"
using namespace lldb;
using namespace lldb_private;
OptionGroupFile::OptionGroupFile(uint32_t usage_mask, bool required,
const char *long_option, int short_option,
uint32_t completion_type,
lldb::CommandArgumentType argument_type,
const char *usage_text)
: m_file() {
m_option_definition.usage_mask = usage_mask;
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = completion_type;
m_option_definition.argument_type = argument_type;
m_option_definition.usage_text = usage_text;
}
OptionGroupFile::~OptionGroupFile() {}
Status OptionGroupFile::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_arg,
ExecutionContext *execution_context) {
Status error(m_file.SetValueFromString(option_arg));
return error;
}
void OptionGroupFile::OptionParsingStarting(
ExecutionContext *execution_context) {
m_file.Clear();
}
OptionGroupFileList::OptionGroupFileList(
uint32_t usage_mask, bool required, const char *long_option,
int short_option, uint32_t completion_type,
lldb::CommandArgumentType argument_type, const char *usage_text)
: m_file_list() {
m_option_definition.usage_mask = usage_mask;
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = completion_type;
m_option_definition.argument_type = argument_type;
m_option_definition.usage_text = usage_text;
}
OptionGroupFileList::~OptionGroupFileList() {}
Status
OptionGroupFileList::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_value,
ExecutionContext *execution_context) {
Status error(m_file_list.SetValueFromString(option_value));
return error;
}
void OptionGroupFileList::OptionParsingStarting(
ExecutionContext *execution_context) {
m_file_list.Clear();
}

View File

@@ -0,0 +1,272 @@
//===-- OptionGroupFormat.cpp -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/OptionGroupFormat.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
OptionGroupFormat::OptionGroupFormat(lldb::Format default_format,
uint64_t default_byte_size,
uint64_t default_count)
: m_format(default_format, default_format),
m_byte_size(default_byte_size, default_byte_size),
m_count(default_count, default_count), m_prev_gdb_format('x'),
m_prev_gdb_size('w') {}
OptionGroupFormat::~OptionGroupFormat() {}
static OptionDefinition g_option_table[] = {
{LLDB_OPT_SET_1, false, "format", 'f', OptionParser::eRequiredArgument,
nullptr, nullptr, 0, eArgTypeFormat,
"Specify a format to be used for display."},
{LLDB_OPT_SET_2, false, "gdb-format", 'G', OptionParser::eRequiredArgument,
nullptr, nullptr, 0, eArgTypeGDBFormat,
"Specify a format using a GDB format specifier string."},
{LLDB_OPT_SET_3, false, "size", 's', OptionParser::eRequiredArgument,
nullptr, nullptr, 0, eArgTypeByteSize,
"The size in bytes to use when displaying with the selected format."},
{LLDB_OPT_SET_4, false, "count", 'c', OptionParser::eRequiredArgument,
nullptr, nullptr, 0, eArgTypeCount,
"The number of total items to display."},
};
llvm::ArrayRef<OptionDefinition> OptionGroupFormat::GetDefinitions() {
auto result = llvm::makeArrayRef(g_option_table);
if (m_byte_size.GetDefaultValue() < UINT64_MAX) {
if (m_count.GetDefaultValue() < UINT64_MAX)
return result;
else
return result.take_front(3);
}
return result.take_front(2);
}
Status OptionGroupFormat::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_arg,
ExecutionContext *execution_context) {
Status error;
const int short_option = g_option_table[option_idx].short_option;
switch (short_option) {
case 'f':
error = m_format.SetValueFromString(option_arg);
break;
case 'c':
if (m_count.GetDefaultValue() == 0) {
error.SetErrorString("--count option is disabled");
} else {
error = m_count.SetValueFromString(option_arg);
if (m_count.GetCurrentValue() == 0)
error.SetErrorStringWithFormat("invalid --count option value '%s'",
option_arg.str().c_str());
}
break;
case 's':
if (m_byte_size.GetDefaultValue() == 0) {
error.SetErrorString("--size option is disabled");
} else {
error = m_byte_size.SetValueFromString(option_arg);
if (m_byte_size.GetCurrentValue() == 0)
error.SetErrorStringWithFormat("invalid --size option value '%s'",
option_arg.str().c_str());
}
break;
case 'G': {
uint64_t count = 0;
llvm::StringRef gdb_format_str = option_arg;
gdb_format_str.consumeInteger(0, count);
Format format = eFormatDefault;
uint32_t byte_size = 0;
while (!gdb_format_str.empty() &&
ParserGDBFormatLetter(execution_context, gdb_format_str[0], format,
byte_size)) {
gdb_format_str = gdb_format_str.drop_front();
}
// We the first character of the "gdb_format_str" is not the
// NULL terminator, we didn't consume the entire string and
// something is wrong. Also, if none of the format, size or count
// was specified correctly, then abort.
if (!gdb_format_str.empty() ||
(format == eFormatInvalid && byte_size == 0 && count == 0)) {
// Nothing got set correctly
error.SetErrorStringWithFormat("invalid gdb format string '%s'",
option_arg.str().c_str());
return error;
}
// At least one of the format, size or count was set correctly.
// Anything that wasn't set correctly should be set to the
// previous default
if (format == eFormatInvalid)
ParserGDBFormatLetter(execution_context, m_prev_gdb_format, format,
byte_size);
const bool byte_size_enabled = m_byte_size.GetDefaultValue() < UINT64_MAX;
const bool count_enabled = m_count.GetDefaultValue() < UINT64_MAX;
if (byte_size_enabled) {
// Byte size is enabled
if (byte_size == 0)
ParserGDBFormatLetter(execution_context, m_prev_gdb_size, format,
byte_size);
} else {
// Byte size is disabled, make sure it wasn't specified
// but if this is an address, it's actually necessary to
// specify one so don't error out
if (byte_size > 0 && format != lldb::eFormatAddressInfo) {
error.SetErrorString(
"this command doesn't support specifying a byte size");
return error;
}
}
if (count_enabled) {
// Count is enabled and was not set, set it to the default for gdb format
// statements (which is 1).
if (count == 0)
count = 1;
} else {
// Count is disabled, make sure it wasn't specified
if (count > 0) {
error.SetErrorString("this command doesn't support specifying a count");
return error;
}
}
m_format.SetCurrentValue(format);
m_format.SetOptionWasSet();
if (byte_size_enabled) {
m_byte_size.SetCurrentValue(byte_size);
m_byte_size.SetOptionWasSet();
}
if (count_enabled) {
m_count.SetCurrentValue(count);
m_count.SetOptionWasSet();
}
} break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
break;
}
return error;
}
bool OptionGroupFormat::ParserGDBFormatLetter(
ExecutionContext *execution_context, char format_letter, Format &format,
uint32_t &byte_size) {
m_has_gdb_format = true;
switch (format_letter) {
case 'o':
format = eFormatOctal;
m_prev_gdb_format = format_letter;
return true;
case 'x':
format = eFormatHex;
m_prev_gdb_format = format_letter;
return true;
case 'd':
format = eFormatDecimal;
m_prev_gdb_format = format_letter;
return true;
case 'u':
format = eFormatUnsigned;
m_prev_gdb_format = format_letter;
return true;
case 't':
format = eFormatBinary;
m_prev_gdb_format = format_letter;
return true;
case 'f':
format = eFormatFloat;
m_prev_gdb_format = format_letter;
return true;
case 'a':
format = eFormatAddressInfo;
{
TargetSP target_sp =
execution_context ? execution_context->GetTargetSP() : TargetSP();
if (target_sp)
byte_size = target_sp->GetArchitecture().GetAddressByteSize();
m_prev_gdb_format = format_letter;
return true;
}
case 'i':
format = eFormatInstruction;
m_prev_gdb_format = format_letter;
return true;
case 'c':
format = eFormatChar;
m_prev_gdb_format = format_letter;
return true;
case 's':
format = eFormatCString;
m_prev_gdb_format = format_letter;
return true;
case 'T':
format = eFormatOSType;
m_prev_gdb_format = format_letter;
return true;
case 'A':
format = eFormatHexFloat;
m_prev_gdb_format = format_letter;
return true;
case 'b':
case 'h':
case 'w':
case 'g':
{
// Size isn't used for printing instructions, so if a size is specified, and
// the previous format was
// 'i', then we should reset it to the default ('x'). Otherwise we'll
// continue to print as instructions,
// which isn't expected.
if (format_letter == 'b')
byte_size = 1;
else if (format_letter == 'h')
byte_size = 2;
else if (format_letter == 'w')
byte_size = 4;
else if (format_letter == 'g')
byte_size = 8;
m_prev_gdb_size = format_letter;
if (m_prev_gdb_format == 'i')
m_prev_gdb_format = 'x';
return true;
}
break;
default:
break;
}
return false;
}
void OptionGroupFormat::OptionParsingStarting(
ExecutionContext *execution_context) {
m_format.Clear();
m_byte_size.Clear();
m_count.Clear();
m_has_gdb_format = false;
}

View File

@@ -0,0 +1,69 @@
//===-- OptionGroupOutputFile.cpp -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/OptionGroupOutputFile.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Host/OptionParser.h"
using namespace lldb;
using namespace lldb_private;
OptionGroupOutputFile::OptionGroupOutputFile()
: m_file(), m_append(false, false) {}
OptionGroupOutputFile::~OptionGroupOutputFile() {}
static const uint32_t SHORT_OPTION_APND = 0x61706e64; // 'apnd'
static OptionDefinition g_option_table[] = {
{LLDB_OPT_SET_1, false, "outfile", 'o', OptionParser::eRequiredArgument,
nullptr, nullptr, 0, eArgTypeFilename,
"Specify a path for capturing command output."},
{LLDB_OPT_SET_1, false, "append-outfile", SHORT_OPTION_APND,
OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
"Append to the file specified with '--outfile <path>'."},
};
llvm::ArrayRef<OptionDefinition> OptionGroupOutputFile::GetDefinitions() {
return llvm::makeArrayRef(g_option_table);
}
Status
OptionGroupOutputFile::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_arg,
ExecutionContext *execution_context) {
Status error;
const int short_option = g_option_table[option_idx].short_option;
switch (short_option) {
case 'o':
error = m_file.SetValueFromString(option_arg);
break;
case SHORT_OPTION_APND:
m_append.SetCurrentValue(true);
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
break;
}
return error;
}
void OptionGroupOutputFile::OptionParsingStarting(
ExecutionContext *execution_context) {
m_file.Clear();
m_append.Clear();
}

View File

@@ -0,0 +1,160 @@
//===-- OptionGroupPlatform.cpp ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/OptionGroupPlatform.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Target/Platform.h"
using namespace lldb;
using namespace lldb_private;
PlatformSP OptionGroupPlatform::CreatePlatformWithOptions(
CommandInterpreter &interpreter, const ArchSpec &arch, bool make_selected,
Status &error, ArchSpec &platform_arch) const {
PlatformSP platform_sp;
if (!m_platform_name.empty()) {
platform_sp = Platform::Create(ConstString(m_platform_name.c_str()), error);
if (platform_sp) {
if (platform_arch.IsValid() &&
!platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch)) {
error.SetErrorStringWithFormat("platform '%s' doesn't support '%s'",
platform_sp->GetName().GetCString(),
arch.GetTriple().getTriple().c_str());
platform_sp.reset();
return platform_sp;
}
}
} else if (arch.IsValid()) {
platform_sp = Platform::Create(arch, &platform_arch, error);
}
if (platform_sp) {
interpreter.GetDebugger().GetPlatformList().Append(platform_sp,
make_selected);
if (m_os_version_major != UINT32_MAX) {
platform_sp->SetOSVersion(m_os_version_major, m_os_version_minor,
m_os_version_update);
}
if (m_sdk_sysroot)
platform_sp->SetSDKRootDirectory(m_sdk_sysroot);
if (m_sdk_build)
platform_sp->SetSDKBuild(m_sdk_build);
}
return platform_sp;
}
void OptionGroupPlatform::OptionParsingStarting(
ExecutionContext *execution_context) {
m_platform_name.clear();
m_sdk_sysroot.Clear();
m_sdk_build.Clear();
m_os_version_major = UINT32_MAX;
m_os_version_minor = UINT32_MAX;
m_os_version_update = UINT32_MAX;
}
static OptionDefinition g_option_table[] = {
{LLDB_OPT_SET_ALL, false, "platform", 'p', OptionParser::eRequiredArgument,
nullptr, nullptr, 0, eArgTypePlatform, "Specify name of the platform to "
"use for this target, creating the "
"platform if necessary."},
{LLDB_OPT_SET_ALL, false, "version", 'v', OptionParser::eRequiredArgument,
nullptr, nullptr, 0, eArgTypeNone,
"Specify the initial SDK version to use prior to connecting."},
{LLDB_OPT_SET_ALL, false, "build", 'b', OptionParser::eRequiredArgument,
nullptr, nullptr, 0, eArgTypeNone,
"Specify the initial SDK build number."},
{LLDB_OPT_SET_ALL, false, "sysroot", 'S', OptionParser::eRequiredArgument,
nullptr, nullptr, 0, eArgTypeFilename, "Specify the SDK root directory "
"that contains a root of all "
"remote system files."}};
llvm::ArrayRef<OptionDefinition> OptionGroupPlatform::GetDefinitions() {
llvm::ArrayRef<OptionDefinition> result(g_option_table);
if (m_include_platform_option)
return result;
return result.drop_front();
}
Status
OptionGroupPlatform::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_arg,
ExecutionContext *execution_context) {
Status error;
if (!m_include_platform_option)
++option_idx;
const int short_option = g_option_table[option_idx].short_option;
switch (short_option) {
case 'p':
m_platform_name.assign(option_arg);
break;
case 'v':
if (!Args::StringToVersion(option_arg, m_os_version_major,
m_os_version_minor, m_os_version_update))
error.SetErrorStringWithFormat("invalid version string '%s'",
option_arg.str().c_str());
break;
case 'b':
m_sdk_build.SetString(option_arg);
break;
case 'S':
m_sdk_sysroot.SetString(option_arg);
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
break;
}
return error;
}
bool OptionGroupPlatform::PlatformMatches(
const lldb::PlatformSP &platform_sp) const {
if (platform_sp) {
if (!m_platform_name.empty()) {
if (platform_sp->GetName() != ConstString(m_platform_name.c_str()))
return false;
}
if (m_sdk_build && m_sdk_build != platform_sp->GetSDKBuild())
return false;
if (m_sdk_sysroot && m_sdk_sysroot != platform_sp->GetSDKRootDirectory())
return false;
if (m_os_version_major != UINT32_MAX) {
uint32_t major, minor, update;
if (platform_sp->GetOSVersion(major, minor, update)) {
if (m_os_version_major != major)
return false;
if (m_os_version_minor != minor)
return false;
if (m_os_version_update != update)
return false;
}
}
return true;
}
return false;
}

View File

@@ -0,0 +1,52 @@
//===-- OptionGroupString.cpp ----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/OptionGroupString.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Host/OptionParser.h"
using namespace lldb;
using namespace lldb_private;
OptionGroupString::OptionGroupString(uint32_t usage_mask, bool required,
const char *long_option, int short_option,
uint32_t completion_type,
lldb::CommandArgumentType argument_type,
const char *usage_text,
const char *default_value)
: m_value(default_value, default_value) {
m_option_definition.usage_mask = usage_mask;
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = completion_type;
m_option_definition.argument_type = argument_type;
m_option_definition.usage_text = usage_text;
}
OptionGroupString::~OptionGroupString() {}
Status OptionGroupString::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_arg,
ExecutionContext *execution_context) {
Status error(m_value.SetValueFromString(option_arg));
return error;
}
void OptionGroupString::OptionParsingStarting(
ExecutionContext *execution_context) {
m_value.Clear();
}

View File

@@ -0,0 +1,52 @@
//===-- OptionGroupUInt64.cpp ----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/OptionGroupUInt64.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Host/OptionParser.h"
using namespace lldb;
using namespace lldb_private;
OptionGroupUInt64::OptionGroupUInt64(uint32_t usage_mask, bool required,
const char *long_option, int short_option,
uint32_t completion_type,
lldb::CommandArgumentType argument_type,
const char *usage_text,
uint64_t default_value)
: m_value(default_value, default_value) {
m_option_definition.usage_mask = usage_mask;
m_option_definition.required = required;
m_option_definition.long_option = long_option;
m_option_definition.short_option = short_option;
m_option_definition.validator = nullptr;
m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
m_option_definition.enum_values = nullptr;
m_option_definition.completion_type = completion_type;
m_option_definition.argument_type = argument_type;
m_option_definition.usage_text = usage_text;
}
OptionGroupUInt64::~OptionGroupUInt64() {}
Status OptionGroupUInt64::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_arg,
ExecutionContext *execution_context) {
Status error(m_value.SetValueFromString(option_arg));
return error;
}
void OptionGroupUInt64::OptionParsingStarting(
ExecutionContext *execution_context) {
m_value.Clear();
}

View File

@@ -0,0 +1,58 @@
//===-- OptionGroupUUID.cpp -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/OptionGroupUUID.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Host/OptionParser.h"
using namespace lldb;
using namespace lldb_private;
OptionGroupUUID::OptionGroupUUID() : m_uuid() {}
OptionGroupUUID::~OptionGroupUUID() {}
static OptionDefinition g_option_table[] = {
{LLDB_OPT_SET_1, false, "uuid", 'u', OptionParser::eRequiredArgument,
nullptr, nullptr, 0, eArgTypeNone, "A module UUID value."},
};
llvm::ArrayRef<OptionDefinition> OptionGroupUUID::GetDefinitions() {
return llvm::makeArrayRef(g_option_table);
}
Status OptionGroupUUID::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_arg,
ExecutionContext *execution_context) {
Status error;
const int short_option = g_option_table[option_idx].short_option;
switch (short_option) {
case 'u':
error = m_uuid.SetValueFromString(option_arg);
if (error.Success())
m_uuid.SetOptionWasSet();
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
break;
}
return error;
}
void OptionGroupUUID::OptionParsingStarting(
ExecutionContext *execution_context) {
m_uuid.Clear();
}

Some files were not shown because too many files have changed in this diff Show More