本文整理汇总了C++中CommandReturnObject::Succeeded方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandReturnObject::Succeeded方法的具体用法?C++ CommandReturnObject::Succeeded怎么用?C++ CommandReturnObject::Succeeded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandReturnObject
的用法示例。
在下文中一共展示了CommandReturnObject::Succeeded方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoExecute
virtual bool
DoExecute (Args& command,
CommandReturnObject &result)
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
return false;
Mutex::Locker locker;
target->GetWatchpointList().GetListMutex(locker);
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
if (num_watchpoints == 0)
{
result.AppendError("No watchpoints exist to be enabled.");
result.SetStatus(eReturnStatusFailed);
return false;
}
if (command.GetArgumentCount() == 0)
{
// No watchpoint selected; enable all currently set watchpoints.
target->EnableAllWatchpoints();
result.AppendMessageWithFormat("All watchpoints enabled. (%" PRIu64 " watchpoints)\n", (uint64_t)num_watchpoints);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
else
{
// Particular watchpoints selected; enable them.
std::vector<uint32_t> wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);
return false;
}
int count = 0;
const size_t size = wp_ids.size();
for (size_t i = 0; i < size; ++i)
if (target->EnableWatchpointByID(wp_ids[i]))
++count;
result.AppendMessageWithFormat("%d watchpoints enabled.\n", count);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
return result.Succeeded();
}
示例2: DoExecute
bool
DoExecute (Args& command,
CommandReturnObject &result) override
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
return false;
std::unique_lock<std::recursive_mutex> lock;
target->GetWatchpointList().GetListMutex(lock);
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
if (num_watchpoints == 0)
{
result.AppendError("No watchpoints exist to be ignored.");
result.SetStatus(eReturnStatusFailed);
return false;
}
if (command.GetArgumentCount() == 0)
{
target->IgnoreAllWatchpoints(m_options.m_ignore_count);
result.AppendMessageWithFormat("All watchpoints ignored. (%" PRIu64 " watchpoints)\n", (uint64_t)num_watchpoints);
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
else
{
// Particular watchpoints selected; ignore them.
std::vector<uint32_t> wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);
return false;
}
int count = 0;
const size_t size = wp_ids.size();
for (size_t i = 0; i < size; ++i)
if (target->IgnoreWatchpointByID(wp_ids[i], m_options.m_ignore_count))
++count;
result.AppendMessageWithFormat("%d watchpoints ignored.\n",count);
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
return result.Succeeded();
}
示例3: platform_sp
virtual bool
DoExecute (Args& args, CommandReturnObject &result)
{
Stream &ostrm = result.GetOutputStream();
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp)
{
platform_sp->GetStatus (ostrm);
result.SetStatus (eReturnStatusSuccessFinishResult);
}
else
{
result.AppendError ("no platform us currently selected\n");
result.SetStatus (eReturnStatusFailed);
}
return result.Succeeded();
}
示例4: exe_ctx
bool
DoExecute (Args& command,
CommandReturnObject &result)
{
ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
StackFrame *frame = exe_ctx.GetFramePtr();
if (frame)
{
frame->DumpUsingSettingsFormat (&result.GetOutputStream());
result.SetStatus (eReturnStatusSuccessFinishResult);
}
else
{
result.AppendError ("no current frame");
result.SetStatus (eReturnStatusFailed);
}
return result.Succeeded();
}
示例5: channel
virtual bool
Execute (CommandInterpreter &interpreter,
Args& args,
CommandReturnObject &result)
{
const size_t argc = args.GetArgumentCount();
if (argc == 0)
{
Log::ListAllLogChannels (&result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishResult);
}
else
{
for (size_t i=0; i<argc; ++i)
{
Log::Callbacks log_callbacks;
std::string channel(args.GetArgumentAtIndex(i));
if (Log::GetLogChannelCallbacks (channel.c_str(), log_callbacks))
{
log_callbacks.list_categories (&result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishResult);
}
else if (channel == "all")
{
Log::ListAllLogChannels (&result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishResult);
}
else
{
LogChannelSP log_channel_sp (GetLogChannelPluginForChannel(channel.c_str()));
if (log_channel_sp)
{
log_channel_sp->ListCategories(&result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
else
result.AppendErrorWithFormat("Invalid log channel '%s'.\n", args.GetArgumentAtIndex(0));
}
}
}
return result.Succeeded();
}
示例6: DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override {
if (!command.empty()) {
result.AppendErrorWithFormat("'%s' takes no arguments",
m_cmd_name.c_str());
return false;
}
auto &r = repro::Reproducer::Instance();
if (r.GetGenerator()) {
result.GetOutputStream() << "Reproducer is in capture mode.\n";
} else if (r.GetLoader()) {
result.GetOutputStream() << "Reproducer is in replay mode.\n";
} else {
result.GetOutputStream() << "Reproducer is off.\n";
}
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
示例7: DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override {
size_t argc = command.GetArgumentCount();
if (argc != 1) {
result.AppendError("'plugin load' requires one argument");
result.SetStatus(eReturnStatusFailed);
return false;
}
Status error;
FileSpec dylib_fspec(command[0].ref, true);
if (m_interpreter.GetDebugger().LoadPlugin(dylib_fspec, error))
result.SetStatus(eReturnStatusSuccessFinishResult);
else {
result.AppendError(error.AsCString());
result.SetStatus(eReturnStatusFailed);
}
return result.Succeeded();
}
示例8: channel
virtual bool
DoExecute (Args& args,
CommandReturnObject &result)
{
const size_t argc = args.GetArgumentCount();
if (argc == 0)
{
result.AppendErrorWithFormat("%s takes a log channel and one or more log types.\n", m_cmd_name.c_str());
}
else
{
Log::Callbacks log_callbacks;
std::string channel(args.GetArgumentAtIndex(0));
args.Shift (); // Shift off the channel
if (Log::GetLogChannelCallbacks (ConstString(channel.c_str()), log_callbacks))
{
log_callbacks.disable (args.GetConstArgumentVector(), &result.GetErrorStream());
result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
else if (channel == "all")
{
Log::DisableAllLogChannels(&result.GetErrorStream());
}
else
{
LogChannelSP log_channel_sp (LogChannel::FindPlugin(channel.c_str()));
if (log_channel_sp)
{
log_channel_sp->Disable(args.GetConstArgumentVector(), &result.GetErrorStream());
result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
else
result.AppendErrorWithFormat("Invalid log channel '%s'.\n", args.GetArgumentAtIndex(0));
}
}
return result.Succeeded();
}
示例9: mangled_cs
bool
DoExecute(Args& command, CommandReturnObject &result) override
{
bool demangled_any = false;
bool error_any = false;
for (size_t i = 0; i < command.GetArgumentCount(); i++)
{
auto arg = command.GetArgumentAtIndex(i);
if (arg && *arg)
{
ConstString mangled_cs(arg);
// the actual Mangled class should be strict about this, but on the command line
// if you're copying mangled names out of 'nm' on Darwin, they will come out with
// an extra underscore - be willing to strip this on behalf of the user
// This is the moral equivalent of the -_/-n options to c++filt
if (mangled_cs.GetStringRef().startswith("__Z"))
mangled_cs.SetCString(arg+1);
Mangled mangled(mangled_cs, true);
if (mangled.GuessLanguage() == lldb::eLanguageTypeC_plus_plus)
{
ConstString demangled(mangled.GetDisplayDemangledName(lldb::eLanguageTypeC_plus_plus));
demangled_any = true;
result.AppendMessageWithFormat("%s ---> %s\n", arg, demangled.GetCString());
}
else
{
error_any = true;
result.AppendErrorWithFormat("%s is not a valid C++ mangled name\n", arg);
}
}
}
result.SetStatus(error_any ? lldb::eReturnStatusFailed :
(demangled_any ? lldb::eReturnStatusSuccessFinishResult : lldb::eReturnStatusSuccessFinishNoResult));
return result.Succeeded();
}
示例10: DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override {
bool demangled_any = false;
bool error_any = false;
for (auto &entry : command.entries()) {
if (entry.ref.empty())
continue;
// the actual Mangled class should be strict about this, but on the
// command line if you're copying mangled names out of 'nm' on Darwin,
// they will come out with an extra underscore - be willing to strip
// this on behalf of the user. This is the moral equivalent of the -_/-n
// options to c++filt
auto name = entry.ref;
if (name.startswith("__Z"))
name = name.drop_front();
Mangled mangled(name, true);
if (mangled.GuessLanguage() == lldb::eLanguageTypeC_plus_plus) {
ConstString demangled(
mangled.GetDisplayDemangledName(lldb::eLanguageTypeC_plus_plus));
demangled_any = true;
result.AppendMessageWithFormat("%s ---> %s\n", entry.ref.str().c_str(),
demangled.GetCString());
} else {
error_any = true;
result.AppendErrorWithFormat("%s is not a valid C++ mangled name\n",
entry.ref.str().c_str());
}
}
result.SetStatus(
error_any ? lldb::eReturnStatusFailed
: (demangled_any ? lldb::eReturnStatusSuccessFinishResult
: lldb::eReturnStatusSuccessFinishNoResult));
return result.Succeeded();
}
示例11:
bool
CommandObjectShow::Execute
(
CommandInterpreter &interpreter,
Args& command,
CommandReturnObject &result
)
{
CommandInterpreter::VariableMap::iterator pos;
if (command.GetArgumentCount())
{
// The user requested to see the value of a particular variable.
const char *var_name = command.GetArgumentAtIndex(0);
StateVariable *var = interpreter.GetStateVariable(var_name);
if (var)
{
var->AppendVariableInformation (result);
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
else
{
result.AppendErrorWithFormat ("Unrecognized variable '%s'; cannot do 'show' command.\n", var_name);
result.SetStatus (eReturnStatusFailed);
}
}
else
{
// The user didn't specify a particular variable, so show the values of all of them.
interpreter.ShowVariableValues(result);
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
return result.Succeeded();
}
示例12: if
//.........这里部分代码省略.........
range.GetBaseAddress() = sc.symbol->GetAddress();
else
range.GetBaseAddress() = frame->GetFrameCodeAddress();
}
if (!range.GetBaseAddress().IsValid())
{
result.AppendError ("invalid frame");
result.SetStatus (eReturnStatusFailed);
return false;
}
}
bool print_sc_header = ranges.size() > 1;
for (AddressRange cur_range : ranges)
{
if (Disassembler::Disassemble (m_interpreter.GetDebugger(),
m_options.arch,
plugin_name,
flavor_string,
m_exe_ctx,
cur_range.GetBaseAddress(),
m_options.num_instructions,
m_options.show_mixed ? m_options.num_lines_context : 0,
options,
result.GetOutputStream()))
{
result.SetStatus (eReturnStatusSuccessFinishResult);
}
else
{
if (m_options.start_addr != LLDB_INVALID_ADDRESS)
result.AppendErrorWithFormat ("Failed to disassemble memory at 0x%8.8" PRIx64 ".\n", m_options.start_addr);
else if (m_options.symbol_containing_addr != LLDB_INVALID_ADDRESS)
result.AppendErrorWithFormat ("Failed to disassemble memory in function at 0x%8.8" PRIx64 ".\n", m_options.symbol_containing_addr);
result.SetStatus (eReturnStatusFailed);
}
}
if (print_sc_header)
result.AppendMessage("\n");
}
else
{
if (ranges.size() == 0)
{
// The default action is to disassemble the current frame function.
if (frame)
{
SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol));
if (sc.function)
range = sc.function->GetAddressRange();
else if (sc.symbol && sc.symbol->ValueIsAddress())
{
range.GetBaseAddress() = sc.symbol->GetAddress();
range.SetByteSize (sc.symbol->GetByteSize());
}
else
range.GetBaseAddress() = frame->GetFrameCodeAddress();
}
else
{
result.AppendError ("invalid frame");
result.SetStatus (eReturnStatusFailed);
return false;
}
ranges.push_back(range);
}
bool print_sc_header = ranges.size() > 1;
for (AddressRange cur_range : ranges)
{
if (cur_range.GetByteSize() == 0)
cur_range.SetByteSize(DEFAULT_DISASM_BYTE_SIZE);
if (Disassembler::Disassemble (m_interpreter.GetDebugger(),
m_options.arch,
plugin_name,
flavor_string,
m_exe_ctx,
cur_range,
m_options.num_instructions,
m_options.show_mixed ? m_options.num_lines_context : 0,
options,
result.GetOutputStream()))
{
result.SetStatus (eReturnStatusSuccessFinishResult);
}
else
{
result.AppendErrorWithFormat ("Failed to disassemble memory at 0x%8.8" PRIx64 ".\n", m_options.start_addr);
result.SetStatus (eReturnStatusFailed);
}
if (print_sc_header)
result.AppendMessage("\n");
}
}
}
return result.Succeeded();
}
示例13: thread_module_sp
//.........这里部分代码省略.........
value.SetValueType(Value::eValueTypeScalar);
void *type;
char *int_pos;
if ((int_pos = strstr (const_cast<char*>(arg_type_cstr), "int")))
{
Encoding encoding = eEncodingSint;
int width = 0;
if (int_pos > arg_type_cstr + 1)
{
result.AppendErrorWithFormat ("Invalid format: %s.\n", arg_type_cstr);
result.SetStatus (eReturnStatusFailed);
return false;
}
if (int_pos == arg_type_cstr + 1 && arg_type_cstr[0] != 'u')
{
result.AppendErrorWithFormat ("Invalid format: %s.\n", arg_type_cstr);
result.SetStatus (eReturnStatusFailed);
return false;
}
if (arg_type_cstr[0] == 'u')
{
encoding = eEncodingUint;
}
char *width_pos = int_pos + 3;
if (!strcmp (width_pos, "8_t"))
width = 8;
else if (!strcmp (width_pos, "16_t"))
width = 16;
else if (!strcmp (width_pos, "32_t"))
width = 32;
else if (!strcmp (width_pos, "64_t"))
width = 64;
else
{
result.AppendErrorWithFormat ("Invalid format: %s.\n", arg_type_cstr);
result.SetStatus (eReturnStatusFailed);
return false;
}
type = ast_context.GetBuiltinTypeForEncodingAndBitSize(encoding, width);
if (!type)
{
result.AppendErrorWithFormat ("Couldn't get Clang type for format %s (%s integer, width %d).\n",
arg_type_cstr,
(encoding == eEncodingSint ? "signed" : "unsigned"),
width);
result.SetStatus (eReturnStatusFailed);
return false;
}
}
else if (strchr (arg_type_cstr, '*'))
{
if (!strcmp (arg_type_cstr, "void*"))
type = ast_context.CreatePointerType (ast_context.GetBuiltInType_void ());
else if (!strcmp (arg_type_cstr, "char*"))
type = ast_context.GetCStringType (false);
else
{
result.AppendErrorWithFormat ("Invalid format: %s.\n", arg_type_cstr);
result.SetStatus (eReturnStatusFailed);
return false;
}
}
else
{
result.AppendErrorWithFormat ("Invalid format: %s.\n", arg_type_cstr);
result.SetStatus (eReturnStatusFailed);
return false;
}
value.SetContext (Value::eContextTypeClangType, type);
value_list.PushValue(value);
}
if (!abi->GetArgumentValues (*thread, value_list))
{
result.AppendError ("Couldn't get argument values");
result.SetStatus (eReturnStatusFailed);
return false;
}
result.GetOutputStream ().Printf("Arguments : \n");
for (arg_index = 0; arg_index < num_args; ++arg_index)
{
result.GetOutputStream ().Printf ("%zu (%s): ", arg_index, args.GetArgumentAtIndex (arg_index));
value_list.GetValueAtIndex (arg_index)->Dump (&result.GetOutputStream ());
result.GetOutputStream ().Printf("\n");
}
return result.Succeeded();
}
示例14: scoped_timer
bool
CommandObjectFile::Execute
(
CommandInterpreter &interpreter,
Args& command,
CommandReturnObject &result
)
{
const char *file_path = command.GetArgumentAtIndex(0);
Timer scoped_timer(__PRETTY_FUNCTION__, "(dbg) file '%s'", file_path);
const int argc = command.GetArgumentCount();
if (argc == 1)
{
FileSpec file_spec (file_path);
if (! file_spec.Exists())
{
result.AppendErrorWithFormat ("File '%s' does not exist.\n", file_path);
result.SetStatus (eReturnStatusFailed);
return result.Succeeded();
}
TargetSP target_sp;
ArchSpec arch;
if (m_options.m_arch.IsValid())
arch = m_options.m_arch;
else
{
arch = lldb_private::GetDefaultArchitecture ();
if (!arch.IsValid())
arch = LLDB_ARCH_DEFAULT;
}
Debugger &debugger = interpreter.GetDebugger();
Error error = debugger.GetTargetList().CreateTarget (debugger, file_spec, arch, NULL, true, target_sp);
if (error.Fail() && !m_options.m_arch.IsValid())
{
if (arch == LLDB_ARCH_DEFAULT_32BIT)
arch = LLDB_ARCH_DEFAULT_64BIT;
else
arch = LLDB_ARCH_DEFAULT_32BIT;
error = debugger.GetTargetList().CreateTarget (debugger, file_spec, arch, NULL, true, target_sp);
}
if (target_sp)
{
debugger.GetTargetList().SetCurrentTarget(target_sp.get());
result.AppendMessageWithFormat ("Current executable set to '%s' (%s).\n", file_path, arch.AsCString());
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
else
{
result.AppendError(error.AsCString());
result.SetStatus (eReturnStatusFailed);
}
}
else
{
result.AppendErrorWithFormat("'%s' takes exactly one executable path argument.\n", m_cmd_name.c_str());
result.SetStatus (eReturnStatusFailed);
}
return result.Succeeded();
}
示例15: DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override {
m_exe_ctx.GetFrameRef().DumpUsingSettingsFormat(&result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}