本文整理汇总了C++中Status::SetErrorStringWithFormatv方法的典型用法代码示例。如果您正苦于以下问题:C++ Status::SetErrorStringWithFormatv方法的具体用法?C++ Status::SetErrorStringWithFormatv怎么用?C++ Status::SetErrorStringWithFormatv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Status
的用法示例。
在下文中一共展示了Status::SetErrorStringWithFormatv方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
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 (m_os_version.tryParse(option_arg))
error.SetErrorStringWithFormatv("invalid version string '{0}'",
option_arg);
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;
}
示例2: CreateFromStructuredData
SearchFilterSP SearchFilter::CreateFromStructuredData(
Target &target, const StructuredData::Dictionary &filter_dict,
Status &error) {
SearchFilterSP result_sp;
if (!filter_dict.IsValid()) {
error.SetErrorString("Can't deserialize from an invalid data object.");
return result_sp;
}
llvm::StringRef subclass_name;
bool success = filter_dict.GetValueForKeyAsString(
GetSerializationSubclassKey(), subclass_name);
if (!success) {
error.SetErrorStringWithFormat("Filter data missing subclass key");
return result_sp;
}
FilterTy filter_type = NameToFilterTy(subclass_name);
if (filter_type == UnknownFilter) {
error.SetErrorStringWithFormatv("Unknown filter type: {0}.", subclass_name);
return result_sp;
}
StructuredData::Dictionary *subclass_options = nullptr;
success = filter_dict.GetValueForKeyAsDictionary(
GetSerializationSubclassOptionsKey(), subclass_options);
if (!success || !subclass_options || !subclass_options->IsValid()) {
error.SetErrorString("Filter data missing subclass options key.");
return result_sp;
}
switch (filter_type) {
case Unconstrained:
result_sp = SearchFilterForUnconstrainedSearches::CreateFromStructuredData(
target, *subclass_options, error);
break;
case ByModule:
result_sp = SearchFilterByModule::CreateFromStructuredData(
target, *subclass_options, error);
break;
case ByModules:
result_sp = SearchFilterByModuleList::CreateFromStructuredData(
target, *subclass_options, error);
break;
case ByModulesAndCU:
result_sp = SearchFilterByModuleListAndCU::CreateFromStructuredData(
target, *subclass_options, error);
break;
case Exception:
error.SetErrorString("Can't serialize exception breakpoints yet.");
break;
default:
llvm_unreachable("Should never get an uresolvable filter type.");
}
return result_sp;
}
示例3: AddName
bool Breakpoint::AddName(llvm::StringRef new_name, Status &error) {
if (new_name.empty())
return false;
if (!BreakpointID::StringIsBreakpointName(new_name, error)) {
error.SetErrorStringWithFormatv("input name \"{0}\" not a breakpoint name.",
new_name);
return false;
}
if (!error.Success())
return false;
m_name_list.insert(new_name);
return true;
}
示例4: json_parser
StructuredData::ObjectSP
StructuredData::ParseJSONFromFile(const FileSpec &input_spec, Status &error) {
StructuredData::ObjectSP return_sp;
auto buffer_or_error = llvm::MemoryBuffer::getFile(input_spec.GetPath());
if (!buffer_or_error) {
error.SetErrorStringWithFormatv("could not open input file: {0} - {1}.",
input_spec.GetPath(),
buffer_or_error.getError().message());
return return_sp;
}
JSONParser json_parser(buffer_or_error.get()->getBuffer());
return_sp = ParseJSONValue(json_parser);
return return_sp;
}
示例5: HostProcess
HostProcess
ProcessLauncherPosixFork::LaunchProcess(const ProcessLaunchInfo &launch_info,
Status &error) {
char exe_path[PATH_MAX];
launch_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path));
// A pipe used by the child process to report errors.
PipePosix pipe;
const bool child_processes_inherit = false;
error = pipe.CreateNew(child_processes_inherit);
if (error.Fail())
return HostProcess();
::pid_t pid = ::fork();
if (pid == -1) {
// Fork failed
error.SetErrorStringWithFormatv("Fork failed with error message: {0}",
llvm::sys::StrError());
return HostProcess(LLDB_INVALID_PROCESS_ID);
}
if (pid == 0) {
// child process
pipe.CloseReadFileDescriptor();
ChildFunc(pipe.ReleaseWriteFileDescriptor(), launch_info);
}
// parent process
pipe.CloseWriteFileDescriptor();
char buf[1000];
int r = read(pipe.GetReadFileDescriptor(), buf, sizeof buf);
if (r == 0)
return HostProcess(pid); // No error. We're done.
error.SetErrorString(buf);
llvm::sys::RetryAfterSignal(-1, waitpid, pid, nullptr, 0);
return HostProcess();
}
示例6: CreateFromStructuredData
BreakpointResolverSP BreakpointResolver::CreateFromStructuredData(
const StructuredData::Dictionary &resolver_dict, Status &error) {
BreakpointResolverSP result_sp;
if (!resolver_dict.IsValid()) {
error.SetErrorString("Can't deserialize from an invalid data object.");
return result_sp;
}
llvm::StringRef subclass_name;
bool success = resolver_dict.GetValueForKeyAsString(
GetSerializationSubclassKey(), subclass_name);
if (!success) {
error.SetErrorStringWithFormat(
"Resolver data missing subclass resolver key");
return result_sp;
}
ResolverTy resolver_type = NameToResolverTy(subclass_name);
if (resolver_type == UnknownResolver) {
error.SetErrorStringWithFormatv("Unknown resolver type: {0}.",
subclass_name);
return result_sp;
}
StructuredData::Dictionary *subclass_options = nullptr;
success = resolver_dict.GetValueForKeyAsDictionary(
GetSerializationSubclassOptionsKey(), subclass_options);
if (!success || !subclass_options || !subclass_options->IsValid()) {
error.SetErrorString("Resolver data missing subclass options key.");
return result_sp;
}
lldb::addr_t offset;
success = subclass_options->GetValueForKeyAsInteger(
GetKey(OptionNames::Offset), offset);
if (!success) {
error.SetErrorString("Resolver data missing offset options key.");
return result_sp;
}
BreakpointResolver *resolver;
switch (resolver_type) {
case FileLineResolver:
resolver = BreakpointResolverFileLine::CreateFromStructuredData(
nullptr, *subclass_options, error);
break;
case AddressResolver:
resolver = BreakpointResolverAddress::CreateFromStructuredData(
nullptr, *subclass_options, error);
break;
case NameResolver:
resolver = BreakpointResolverName::CreateFromStructuredData(
nullptr, *subclass_options, error);
break;
case FileRegexResolver:
resolver = BreakpointResolverFileRegex::CreateFromStructuredData(
nullptr, *subclass_options, error);
break;
case PythonResolver:
resolver = BreakpointResolverScripted::CreateFromStructuredData(
nullptr, *subclass_options, error);
break;
case ExceptionResolver:
error.SetErrorString("Exception resolvers are hard.");
break;
default:
llvm_unreachable("Should never get an unresolvable resolver type.");
}
if (!error.Success()) {
return result_sp;
} else {
// Add on the global offset option:
resolver->SetOffset(offset);
return BreakpointResolverSP(resolver);
}
}