[lldb] Bring more diagnostics in compliance with our coding standards (#190410)

The LLVM Coding Standards [1] specify that:

> [T]o match error message styles commonly produced by other tools,
> start the first sentence with a lowercase letter, and finish the last
> sentence without a period, if it would end in one otherwise.

Historically, that hasn't been something we've enforced in LLDB, but in
the past year or so I've started to pay more attention to this in code
reviews. This PR brings more error messages in compliance, further
increasing consistency.

I also adopted `createStringErrorV` where it improved the code as a
drive-by for lines I was already touching.

[1] https://llvm.org/docs/CodingStandards.html#error-and-warning-messages

Assisted-by: Claude Code
This commit is contained in:
Jonas Devlieghere 2026-04-05 10:41:47 -07:00 committed by GitHub
parent 36e495dd90
commit f866ef202c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
67 changed files with 214 additions and 232 deletions

View File

@ -21,6 +21,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Utility/StreamString.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorExtras.h"
#include <cstdint>
using namespace lldb;
@ -70,8 +71,7 @@ TypeFilterImpl::FrontEnd::GetIndexOfChildWithName(ConstString name) {
}
}
}
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
std::string TypeFilterImpl::GetDescription() {
@ -225,8 +225,7 @@ bool ScriptedSyntheticChildren::FrontEnd::MightHaveChildren() {
llvm::Expected<size_t>
ScriptedSyntheticChildren::FrontEnd::GetIndexOfChildWithName(ConstString name) {
if (!m_wrapper_sp || m_interpreter == nullptr)
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
return m_interpreter->GetIndexOfChildWithName(m_wrapper_sp,
name.GetCString());
}

View File

@ -2256,7 +2256,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
break;
}
}
return llvm::createStringErrorV("Unhandled opcode {0} in DWARFExpression",
return llvm::createStringErrorV("unhandled opcode {0} in DWARFExpression",
LocationAtom(op));
}
}

View File

@ -39,7 +39,7 @@ lldb_private::FunctionCallLabel::fromString(llvm::StringRef label) {
label.split(components, ":", /*MaxSplit=*/4);
if (components.size() != 5)
return llvm::createStringError("malformed function call label.");
return llvm::createStringError("malformed function call label");
if (components[0] != FunctionCallLabelPrefix)
return llvm::createStringErrorV(
@ -53,12 +53,12 @@ lldb_private::FunctionCallLabel::fromString(llvm::StringRef label) {
lldb::user_id_t module_id = 0;
if (!llvm::to_integer(module_label, module_id))
return llvm::createStringErrorV("failed to parse module ID from '{0}'.",
return llvm::createStringErrorV("failed to parse module ID from '{0}'",
module_label);
lldb::user_id_t die_id;
if (!llvm::to_integer(die_label, die_id))
return llvm::createStringErrorV("failed to parse symbol ID from '{0}'.",
return llvm::createStringErrorV("failed to parse symbol ID from '{0}'",
die_label);
return FunctionCallLabel{/*.discriminator=*/discriminator,

View File

@ -729,7 +729,7 @@ ResolveFunctionCallLabel(FunctionCallLabel &label,
symbol_was_missing_weak = false;
if (!sc.target_sp)
return llvm::createStringError("target not available.");
return llvm::createStringError("target not available");
auto module_sp = sc.target_sp->GetImages().FindModule(label.module_id);
if (!module_sp)

View File

@ -181,7 +181,7 @@ llvm::Error Socket::Initialize() {
if (err == 0) {
if (wsaData.wVersion < wVersion) {
WSACleanup();
return llvm::createStringError("WSASock version is not expected.");
return llvm::createStringError("WSASock version is not expected");
}
} else {
return llvm::errorCodeToError(llvm::mapWindowsError(::WSAGetLastError()));
@ -247,7 +247,7 @@ Socket::CreatePair(std::optional<SocketProtocol> protocol) {
return DomainSocket::CreatePair();
#endif
default:
return llvm::createStringError("Unsupported protocol");
return llvm::createStringError("unsupported protocol");
}
}

View File

@ -267,7 +267,7 @@ llvm::Expected<std::vector<MainLoopBase::ReadHandleUP>>
TCPSocket::Accept(MainLoopBase &loop,
std::function<void(std::unique_ptr<Socket> socket)> sock_cb) {
if (m_listen_sockets.size() == 0)
return llvm::createStringError("No open listening sockets!");
return llvm::createStringError("no open listening sockets!");
std::vector<MainLoopBase::ReadHandleUP> handles;
for (auto socket : m_listen_sockets) {

View File

@ -458,7 +458,7 @@ llvm::Error Host::OpenURL(llvm::StringRef url) {
std::error_code(ENOTSUP, std::system_category()));
#else // !TARGET_OS_OSX
if (url.empty())
return llvm::createStringError("Cannot open empty URL.");
return llvm::createStringError("cannot open empty URL");
LLDB_LOG(GetLog(LLDBLog::Host), "Opening URL: {0}", url);

View File

@ -227,7 +227,7 @@ DomainSocket::FromBoundNativeSocket(NativeSocket sockfd, bool should_close) {
if (getsockname(sockfd, (struct sockaddr *)&addr, &addr_len) == -1)
return llvm::createStringError("not a socket or error occurred");
if (addr.sun_family != AF_UNIX)
return llvm::createStringError("Bad socket type");
return llvm::createStringError("bad socket type");
#ifdef __linux__
if (addr_len > offsetof(struct sockaddr_un, sun_path) &&
addr.sun_path[0] == '\0')

View File

@ -164,7 +164,7 @@ llvm::Error PipePosix::OpenAsWriter(llvm::StringRef name,
const Timeout<std::micro> &timeout) {
std::lock_guard<std::mutex> guard(m_write_mutex);
if (CanReadUnlocked() || CanWriteUnlocked())
return llvm::createStringError("Pipe is already opened");
return llvm::createStringError("pipe is already opened");
int flags = O_WRONLY | O_NONBLOCK | O_CLOEXEC;

View File

@ -947,7 +947,7 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
Option *long_options = GetLongOptions();
if (long_options == nullptr) {
return llvm::createStringError("Invalid long options");
return llvm::createStringError("invalid long options");
}
std::string short_options = BuildShortOptions(long_options);
@ -972,7 +972,7 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
break;
if (val == '?') {
return llvm::createStringError("Unknown or ambiguous option");
return llvm::createStringError("unknown or ambiguous option");
}
if (val == 0)
@ -994,7 +994,7 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
// See if the option takes an argument, and see if one was supplied.
if (long_options_index == -1) {
return llvm::createStringErrorV("Invalid option with value '{0}'.",
return llvm::createStringErrorV("invalid option with value '{0}'",
char(val));
}

View File

@ -20,6 +20,7 @@
#include "lldb/Utility/Log.h"
#include "lldb/ValueObject/ValueObject.h"
#include "lldb/ValueObject/ValueObjectConstResult.h"
#include "llvm/Support/ErrorExtras.h"
using namespace lldb;
using namespace lldb_private;
@ -146,8 +147,7 @@ public:
llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
if (!m_block_struct_type.IsValid())
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
const bool omit_empty_base_classes = false;
return m_block_struct_type.GetIndexOfChildWithName(name.AsCString(),

View File

@ -18,6 +18,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Demangle/ItaniumDemangle.h"
#include "llvm/Support/ErrorExtras.h"
#include "lldb/Core/DemangledNameInfo.h"
#include "lldb/Core/Mangled.h"
@ -260,24 +261,24 @@ static llvm::Expected<std::pair<llvm::StringRef, DemangledNameInfo>>
GetAndValidateInfo(const SymbolContext &sc) {
Mangled mangled = sc.GetPossiblyInlinedFunctionName();
if (!mangled)
return llvm::createStringError("Function does not have a mangled name.");
return llvm::createStringError("function does not have a mangled name");
auto demangled_name = mangled.GetDemangledName().GetStringRef();
if (demangled_name.empty())
return llvm::createStringError(
"Function '%s' does not have a demangled name.",
mangled.GetMangledName().AsCString(""));
return llvm::createStringErrorV(
"function '{0}' does not have a demangled name",
mangled.GetMangledName());
const std::optional<DemangledNameInfo> &info = mangled.GetDemangledInfo();
if (!info)
return llvm::createStringError(
"Function '%s' does not have demangled info.", demangled_name.data());
return llvm::createStringErrorV(
"function '{0}' does not have demangled info", demangled_name);
// Function without a basename is nonsense.
if (!info->hasBasename())
return llvm::createStringError(
"DemangledInfo for '%s does not have basename range.",
demangled_name.data());
return llvm::createStringErrorV(
"demangled info for '{0}' does not have a basename range",
demangled_name);
return std::make_pair(demangled_name, *info);
}
@ -304,8 +305,8 @@ llvm::Expected<llvm::StringRef>
CPlusPlusLanguage::GetDemangledTemplateArguments(
llvm::StringRef demangled, const DemangledNameInfo &info) {
if (!info.hasTemplateArguments())
return llvm::createStringError(
"Template arguments range for '%s' is invalid.", demangled.data());
return llvm::createStringErrorV(
"template arguments range for '{0}' is invalid", demangled);
return demangled.slice(info.TemplateArgumentsRange.first,
info.TemplateArgumentsRange.second);
@ -326,8 +327,8 @@ llvm::Expected<llvm::StringRef>
CPlusPlusLanguage::GetDemangledReturnTypeLHS(llvm::StringRef demangled,
const DemangledNameInfo &info) {
if (info.ScopeRange.first >= demangled.size())
return llvm::createStringError(
"Scope range for '%s' LHS return type is invalid.", demangled.data());
return llvm::createStringErrorV(
"scope range for '{0}' LHS return type is invalid", demangled);
return demangled.substr(0, info.ScopeRange.first);
}
@ -347,8 +348,8 @@ llvm::Expected<llvm::StringRef>
CPlusPlusLanguage::GetDemangledFunctionQualifiers(
llvm::StringRef demangled, const DemangledNameInfo &info) {
if (!info.hasQualifiers())
return llvm::createStringError("Qualifiers range for '%s' is invalid.",
demangled.data());
return llvm::createStringErrorV("qualifiers range for '{0}' is invalid",
demangled);
return demangled.slice(info.QualifiersRange.first,
info.QualifiersRange.second);
@ -370,9 +371,8 @@ llvm::Expected<llvm::StringRef>
CPlusPlusLanguage::GetDemangledReturnTypeRHS(llvm::StringRef demangled,
const DemangledNameInfo &info) {
if (info.QualifiersRange.first < info.ArgumentsRange.second)
return llvm::createStringError(
"Qualifiers range for '%s' RHS return type is invalid.",
demangled.data());
return llvm::createStringErrorV(
"qualifiers range for '{0}' RHS return type is invalid", demangled);
return demangled.slice(info.ArgumentsRange.second,
info.QualifiersRange.first);
@ -393,8 +393,8 @@ llvm::Expected<llvm::StringRef>
CPlusPlusLanguage::GetDemangledScope(llvm::StringRef demangled,
const DemangledNameInfo &info) {
if (!info.hasScope())
return llvm::createStringError("Scope range for '%s' is invalid.",
demangled.data());
return llvm::createStringErrorV("scope range for '{0}' is invalid",
demangled);
return demangled.slice(info.ScopeRange.first, info.ScopeRange.second);
}
@ -414,8 +414,8 @@ llvm::Expected<llvm::StringRef>
CPlusPlusLanguage::GetDemangledFunctionSuffix(llvm::StringRef demangled,
const DemangledNameInfo &info) {
if (!info.hasSuffix())
return llvm::createStringError("Suffix range for '%s' is invalid.",
demangled.data());
return llvm::createStringErrorV("suffix range for '{0}' is invalid",
demangled);
return demangled.slice(info.SuffixRange.first, info.SuffixRange.second);
}
@ -435,8 +435,8 @@ llvm::Expected<llvm::StringRef>
CPlusPlusLanguage::GetDemangledFunctionArguments(
llvm::StringRef demangled, const DemangledNameInfo &info) {
if (!info.hasArguments())
return llvm::createStringError(
"Function arguments range for '%s' is invalid.", demangled.data());
return llvm::createStringErrorV(
"function arguments range for '{0}' is invalid", demangled);
return demangled.slice(info.ArgumentsRange.first, info.ArgumentsRange.second);
}
@ -2488,8 +2488,8 @@ protected:
llvm::Expected<ConstString> substituteImpl(llvm::StringRef Mangled) {
if (this->parse() == nullptr)
return llvm::createStringError(
llvm::formatv("Failed to substitute mangling in '{0}'", Mangled));
return llvm::createStringErrorV("failed to substitute mangling in '{0}'",
Mangled);
if (!Substituted)
return ConstString();

View File

@ -11,6 +11,7 @@
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/VariableList.h"
#include "llvm/Support/ErrorExtras.h"
using namespace lldb;
using namespace lldb_private;
@ -201,8 +202,7 @@ StdlibCoroutineHandleSyntheticFrontEnd::GetIndexOfChildWithName(
return idx;
}
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
SyntheticChildrenFrontEnd *

View File

@ -9,6 +9,7 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/ValueObject/ValueObject.h"
#include "llvm/Support/ErrorExtras.h"
#include <cstddef>
#include <optional>
#include <type_traits>
@ -114,13 +115,11 @@ public:
llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
if (!m_start) {
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
if (!optional_idx) {
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
return *optional_idx;
}

View File

@ -553,11 +553,11 @@ llvm::Expected<uint32_t> MsvcStlListFrontEnd::CalculateNumChildren() {
auto size_sp =
m_backend.GetChildAtNamePath({"_Mypair", "_Myval2", "_Mysize"});
if (!size_sp)
return llvm::createStringError("Failed to resolve size.");
return llvm::createStringError("failed to resolve size");
m_count = size_sp->GetValueAsUnsigned(UINT32_MAX);
if (m_count == UINT32_MAX)
return llvm::createStringError("Failed to read size value.");
return llvm::createStringError("failed to read size value");
return m_count;
}

View File

@ -13,6 +13,7 @@
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Target/Target.h"
#include "llvm/Support/ErrorExtras.h"
using namespace lldb;
using namespace lldb_private;
@ -41,8 +42,7 @@ public:
llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
if (name == "$$dereference$$")
return 0;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
llvm::Expected<uint32_t> CalculateNumChildren() override {

View File

@ -8,6 +8,10 @@
#include "LibCxx.h"
#include "Plugins/Language/CPlusPlus/CxxStringTypes.h"
#include "Plugins/Language/CPlusPlus/Generic.h"
#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
@ -23,13 +27,9 @@
#include "lldb/Utility/Stream.h"
#include "lldb/ValueObject/ValueObject.h"
#include "lldb/ValueObject/ValueObjectConstResult.h"
#include "Plugins/Language/CPlusPlus/CxxStringTypes.h"
#include "Plugins/Language/CPlusPlus/Generic.h"
#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
#include "llvm/Support/ErrorExtras.h"
#include <optional>
#include <tuple>
@ -416,8 +416,7 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
if (name == "object" || name == "$$dereference$$")
return 1;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
@ -519,8 +518,7 @@ lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
return 1;
if (name == "obj" || name == "object" || name == "$$dereference$$")
return 2;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
/// The field layout in a libc++ string (cap, side, data or data, size, cap).

View File

@ -8,6 +8,7 @@
#include "LibCxxAtomic.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "llvm/Support/ErrorExtras.h"
using namespace lldb;
using namespace lldb_private;
@ -135,8 +136,7 @@ lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
GetIndexOfChildWithName(ConstString name) {
if (name == "Value")
return 0;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
SyntheticChildrenFrontEnd *

View File

@ -9,6 +9,7 @@
#include "LibCxx.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@ -19,6 +20,7 @@
#include "lldb/ValueObject/ValueObjectConstResult.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
#include "llvm/Support/ErrorExtras.h"
#include <cstdint>
#include <locale>
#include <optional>
@ -275,7 +277,7 @@ llvm::Expected<uint32_t> lldb_private::formatters::
auto [size_sp, is_compressed_pair] =
GetValueOrOldCompressedPair(*m_tree, "__size_", "__pair3_");
if (!size_sp)
return llvm::createStringError("Unexpected std::map layout");
return llvm::createStringError("unexpected std::map layout");
if (is_compressed_pair)
return CalculateNumChildrenForOldCompressedPairLayout(*size_sp);
@ -482,8 +484,7 @@ llvm::Expected<size_t>
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::
GetIndexOfChildWithName(ConstString name) {
if (!m_pair_sp)
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
return m_pair_sp->GetIndexOfChildWithName(name);
}

View File

@ -10,6 +10,7 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/ValueObject/ValueObject.h"
#include "llvm/Support/ErrorExtras.h"
#include <optional>
using namespace lldb;
@ -177,12 +178,10 @@ llvm::Expected<size_t>
lldb_private::formatters::LibcxxStdProxyArraySyntheticFrontEnd::
GetIndexOfChildWithName(ConstString name) {
if (!m_base)
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
if (!optional_idx) {
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
return *optional_idx;
}

View File

@ -8,6 +8,7 @@
#include "LibCxx.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "llvm/Support/ErrorExtras.h"
using namespace lldb;
using namespace lldb_private;
@ -23,8 +24,7 @@ public:
llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
if (m_container_sp)
return m_container_sp->GetIndexOfChildWithName(name);
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
lldb::ChildCacheState Update() override;

View File

@ -10,6 +10,7 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/ValueObject/ValueObject.h"
#include "llvm/Support/ErrorExtras.h"
#include <optional>
using namespace lldb;
@ -148,12 +149,10 @@ llvm::Expected<size_t>
lldb_private::formatters::LibcxxStdSliceArraySyntheticFrontEnd::
GetIndexOfChildWithName(ConstString name) {
if (!m_start)
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
if (!optional_idx) {
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
return *optional_idx;
}

View File

@ -12,6 +12,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/ValueObject/ValueObject.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/Support/ErrorExtras.h"
#include <optional>
using namespace lldb;
@ -131,12 +132,10 @@ lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::Update() {
llvm::Expected<size_t> lldb_private::formatters::
LibcxxStdSpanSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
if (!m_start)
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
if (!optional_idx) {
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
return *optional_idx;
}

View File

@ -20,6 +20,7 @@
#include "lldb/ValueObject/ValueObjectConstResult.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorExtras.h"
using namespace lldb;
using namespace lldb_private;
@ -222,7 +223,7 @@ lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
return size_sp->GetValueAsUnsigned(0);
if (!is_compressed_pair)
return llvm::createStringError("Unsupported std::unordered_map layout.");
return llvm::createStringError("unsupported std::unordered_map layout");
ValueObjectSP num_elements_sp = GetFirstValueOfLibCXXCompressedPair(*size_sp);
@ -392,8 +393,7 @@ lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::
return 0;
if (name == "second")
return 1;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
SyntheticChildrenFrontEnd *

View File

@ -10,6 +10,7 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/ValueObject/ValueObject.h"
#include "llvm/Support/ErrorExtras.h"
#include <optional>
using namespace lldb;
@ -127,12 +128,10 @@ llvm::Expected<size_t>
lldb_private::formatters::LibcxxStdValarraySyntheticFrontEnd::
GetIndexOfChildWithName(ConstString name) {
if (!m_start || !m_finish)
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
if (!optional_idx) {
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
return *optional_idx;
}

View File

@ -13,6 +13,7 @@
#include "lldb/ValueObject/ValueObject.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
#include "llvm/Support/ErrorExtras.h"
#include <optional>
using namespace lldb;
@ -166,12 +167,10 @@ llvm::Expected<size_t>
lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
GetIndexOfChildWithName(ConstString name) {
if (!m_start || !m_finish)
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
if (!optional_idx) {
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
return *optional_idx;
}
@ -269,17 +268,14 @@ llvm::Expected<size_t>
lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
GetIndexOfChildWithName(ConstString name) {
if (!m_count || !m_base_data_address)
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
auto optional_idx = ExtractIndexFromString(name.AsCString());
if (!optional_idx) {
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
uint32_t idx = *optional_idx;
if (idx >= CalculateNumChildrenIgnoringErrors())
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
return idx;
}

View File

@ -12,6 +12,7 @@
#include "Plugins/Language/CPlusPlus/CxxStringTypes.h"
#include "Plugins/Language/CPlusPlus/Generic.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/VectorIterator.h"
@ -22,6 +23,7 @@
#include "lldb/Utility/Stream.h"
#include "lldb/ValueObject/ValueObject.h"
#include "lldb/ValueObject/ValueObjectConstResult.h"
#include "llvm/Support/ErrorExtras.h"
#include <optional>
using namespace lldb;
@ -156,8 +158,7 @@ LibstdcppMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName(
return 0;
if (name == "second")
return 1;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
SyntheticChildrenFrontEnd *
@ -233,8 +234,7 @@ llvm::Expected<size_t>
VectorIteratorSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
if (name == "item")
return 0;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
bool lldb_private::formatters::LibStdcppStringSummaryProvider(
@ -393,8 +393,7 @@ LibStdcppSharedPtrSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
if (name == "object" || name == "$$dereference$$")
return 1;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
SyntheticChildrenFrontEnd *

View File

@ -13,6 +13,7 @@
#include "lldb/ValueObject/ValueObject.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorExtras.h"
#include <cstddef>
#include <optional>
@ -80,13 +81,11 @@ public:
llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
if (!m_start)
return llvm::createStringError(
llvm::formatv("Type has no child named {0}", name.GetStringRef()));
return llvm::createStringErrorV("type has no child named '{0}'", name);
auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
if (!optional_idx) {
return llvm::createStringError(
llvm::formatv("Type has no child named {0}", name.GetStringRef()));
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
return *optional_idx;
}

View File

@ -12,6 +12,7 @@
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/ValueObject/ValueObject.h"
#include "llvm/Support/ErrorExtras.h"
#include <memory>
#include <vector>
@ -145,8 +146,7 @@ LibStdcppUniquePtrSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
return 1;
if (name == "obj" || name == "object" || name == "$$dereference$$")
return 2;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
bool LibStdcppUniquePtrSyntheticFrontEnd::GetSummary(

View File

@ -9,6 +9,7 @@
#include "MsvcStl.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "llvm/Support/ErrorExtras.h"
using namespace lldb;
@ -85,8 +86,7 @@ llvm::Expected<size_t> lldb_private::formatters::
MsvcStlAtomicSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
if (name == "Value")
return 0;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
lldb_private::SyntheticChildrenFrontEnd *

View File

@ -10,6 +10,7 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "llvm/Support/ErrorExtras.h"
using namespace lldb;
@ -55,7 +56,7 @@ lldb_private::formatters::MsvcStlDequeSyntheticFrontEnd::
llvm::Expected<uint32_t> lldb_private::formatters::
MsvcStlDequeSyntheticFrontEnd::CalculateNumChildren() {
if (!m_map)
return llvm::createStringError("Failed to read size");
return llvm::createStringError("failed to read size");
return m_size;
}
@ -158,13 +159,11 @@ lldb_private::formatters::MsvcStlDequeSyntheticFrontEnd::Update() {
llvm::Expected<size_t> lldb_private::formatters::MsvcStlDequeSyntheticFrontEnd::
GetIndexOfChildWithName(ConstString name) {
if (!m_map)
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
if (auto optional_idx = ExtractIndexFromString(name.GetCString()))
return *optional_idx;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
bool lldb_private::formatters::IsMsvcStlDeque(ValueObject &valobj) {

View File

@ -11,6 +11,7 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "llvm/Support/ErrorExtras.h"
using namespace lldb;
@ -169,8 +170,7 @@ lldb_private::formatters::MsvcStlSmartPointerSyntheticFrontEnd::
if (name == "object" || name == "$$dereference$$")
return 1;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
lldb_private::formatters::MsvcStlSmartPointerSyntheticFrontEnd::
@ -270,8 +270,7 @@ lldb_private::formatters::MsvcStlUniquePtrSyntheticFrontEnd::
return 1;
if (name == "obj" || name == "object" || name == "$$dereference$$")
return 2;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
lldb_private::SyntheticChildrenFrontEnd *

View File

@ -11,6 +11,7 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/ValueObject/ValueObject.h"
#include "llvm/Support/ErrorExtras.h"
#include <optional>
using namespace lldb;
@ -107,13 +108,11 @@ llvm::Expected<size_t>
lldb_private::formatters::MsvcStlSpanSyntheticFrontEnd::GetIndexOfChildWithName(
ConstString name) {
if (!m_start)
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
if (!optional_idx)
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
return *optional_idx;
}

View File

@ -227,7 +227,7 @@ public:
llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
if (!m_inner_sp)
return llvm::createStringError("There are no children.");
return llvm::createStringError("there are no children");
return m_inner_sp->GetIndexOfChildWithName(name);
}
@ -260,7 +260,7 @@ lldb_private::formatters::MsvcStlTreeSyntheticFrontEnd::CalculateNumChildren() {
return m_count;
}
return llvm::createStringError("Failed to read size.");
return llvm::createStringError("failed to read size");
}
ValueObjectSP

View File

@ -22,7 +22,7 @@ public:
llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
if (!m_list_sp)
return llvm::createStringError("Missing _List");
return llvm::createStringError("missing _List");
return m_list_sp->GetIndexOfChildWithName(name);
}
@ -30,7 +30,7 @@ public:
llvm::Expected<uint32_t> CalculateNumChildren() override {
if (!m_list_sp)
return llvm::createStringError("Missing _List");
return llvm::createStringError("missing _List");
return m_list_sp->GetNumChildren();
}

View File

@ -10,6 +10,7 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "llvm/Support/ErrorExtras.h"
using namespace lldb;
@ -138,12 +139,10 @@ lldb_private::formatters::MsvcStlVectorSyntheticFrontEnd::Update() {
llvm::Expected<size_t> lldb_private::formatters::
MsvcStlVectorSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
if (!m_start || !m_finish)
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
auto optional_idx = ExtractIndexFromString(name.GetCString());
if (!optional_idx) {
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
return *optional_idx;
}
@ -267,17 +266,14 @@ llvm::Expected<size_t>
lldb_private::formatters::MsvcStlVectorBoolSyntheticFrontEnd::
GetIndexOfChildWithName(ConstString name) {
if (!m_count || !m_base_data_address)
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
auto optional_idx = ExtractIndexFromString(name.AsCString());
if (!optional_idx) {
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
uint32_t idx = *optional_idx;
if (idx >= CalculateNumChildrenIgnoringErrors())
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
return idx;
}

View File

@ -30,6 +30,7 @@
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/bit.h"
#include "llvm/Support/ErrorExtras.h"
using namespace lldb;
using namespace lldb_private;
@ -1050,8 +1051,7 @@ public:
bool MightHaveChildren() override { return false; }
llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
};

View File

@ -16,6 +16,8 @@
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "llvm/Support/ErrorExtras.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/StackFrame.h"
@ -929,8 +931,7 @@ llvm::Expected<size_t> lldb_private::formatters::
static const ConstString g_zero("[0]");
if (name == g_zero)
return 0;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
llvm::Expected<uint32_t> lldb_private::formatters::

View File

@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
#include "clang/AST/DeclCXX.h"
#include "Cocoa.h"
#include "Plugins/Language/ObjC/NSString.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Target/Target.h"
@ -19,9 +19,7 @@
#include "lldb/Utility/Stream.h"
#include "lldb/ValueObject/ValueObject.h"
#include "lldb/ValueObject/ValueObjectConstResult.h"
#include "Plugins/Language/ObjC/NSString.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
#include "llvm/Support/ErrorExtras.h"
using namespace lldb;
using namespace lldb_private;
@ -169,8 +167,7 @@ public:
static ConstString g_userInfo("_userInfo");
if (name == g_userInfo)
return 0;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
private:

View File

@ -10,6 +10,8 @@
#include "Cocoa.h"
#include "llvm/Support/ErrorExtras.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@ -162,8 +164,7 @@ public:
if (name == g_reason) return 1;
if (name == g_userInfo) return 2;
if (name == g_reserved) return 3;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
private:

View File

@ -1107,11 +1107,11 @@ ResolveSDKPathFromDebugInfo(lldb_private::Target *target) {
ModuleSP exe_module_sp = target->GetExecutableModule();
if (!exe_module_sp)
return llvm::createStringError("Failed to get module from target");
return llvm::createStringError("failed to get module from target");
SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
if (!sym_file)
return llvm::createStringError("Failed to get symbol file from executable");
return llvm::createStringError("failed to get symbol file from executable");
if (sym_file->GetNumCompileUnits() == 0)
return llvm::createStringError(

View File

@ -80,7 +80,7 @@ NativeProcessAIX::Manager::Launch(ProcessLaunchInfo &launch_info,
if (!WIFSTOPPED(wstatus)) {
LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}",
WaitStatus::Decode(wstatus));
return llvm::createStringError("Could not sync with inferior process");
return llvm::createStringError("could not sync with inferior process");
}
LLDB_LOG(log, "inferior started, now in stopped state");

View File

@ -92,13 +92,13 @@ NativeProcessFreeBSD::Manager::Launch(ProcessLaunchInfo &launch_info,
if (!WIFSTOPPED(wstatus)) {
LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}",
WaitStatus::Decode(wstatus));
return llvm::createStringError("Could not sync with inferior process");
return llvm::createStringError("could not sync with inferior process");
}
LLDB_LOG(log, "inferior started, now in stopped state");
ProcessInstanceInfo Info;
if (!Host::GetProcessInfo(pid, Info)) {
return llvm::createStringError("Cannot get process architecture");
return llvm::createStringError("cannot get process architecture");
}
// Set the architecture to the exe architecture.
@ -129,7 +129,7 @@ NativeProcessFreeBSD::Manager::Attach(
// Retrieve the architecture for the running process.
ProcessInstanceInfo Info;
if (!Host::GetProcessInfo(pid, Info)) {
return llvm::createStringError("Cannot get process architecture");
return llvm::createStringError("cannot get process architecture");
}
std::unique_ptr<NativeProcessFreeBSD> process_up(new NativeProcessFreeBSD(
@ -1072,7 +1072,7 @@ NativeProcessFreeBSD::SaveCore(llvm::StringRef path_hint) {
openFile(path, pc.pc_fd, CD_CreateNew, FA_Write, OF_None)) {
if (std::error_code errc =
createTemporaryFile("lldb", "core", pc.pc_fd, path))
return llvm::createStringError(errc, "Unable to create a temporary file");
return llvm::createStringError(errc, "unable to create a temporary file");
}
error = PtraceWrapper(PT_COREDUMP, GetID(), &pc, sizeof(pc));

View File

@ -287,7 +287,7 @@ NativeProcessLinux::Manager::Launch(ProcessLaunchInfo &launch_info,
if (!WIFSTOPPED(wstatus)) {
LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}",
WaitStatus::Decode(wstatus));
return llvm::createStringError("Could not sync with inferior process");
return llvm::createStringError("could not sync with inferior process");
}
LLDB_LOG(log, "inferior started, now in stopped state");
@ -504,7 +504,7 @@ llvm::Expected<std::vector<::pid_t>> NativeProcessLinux::Attach(::pid_t pid) {
size_t tid_count = tids_to_attach.size();
if (tid_count == 0)
return llvm::createStringError("No such process");
return llvm::createStringError("no such process");
std::vector<::pid_t> tids;
tids.reserve(tid_count);

View File

@ -78,13 +78,13 @@ NativeProcessNetBSD::Manager::Launch(ProcessLaunchInfo &launch_info,
if (!WIFSTOPPED(wstatus)) {
LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}",
WaitStatus::Decode(wstatus));
return llvm::createStringError("Could not sync with inferior process");
return llvm::createStringError("could not sync with inferior process");
}
LLDB_LOG(log, "inferior started, now in stopped state");
ProcessInstanceInfo Info;
if (!Host::GetProcessInfo(pid, Info)) {
return llvm::createStringError("Cannot get process architecture");
return llvm::createStringError("cannot get process architecture");
}
// Set the architecture to the exe architecture.
@ -115,7 +115,7 @@ NativeProcessNetBSD::Manager::Attach(
// Retrieve the architecture for the running process.
ProcessInstanceInfo Info;
if (!Host::GetProcessInfo(pid, Info)) {
return llvm::createStringError("Cannot get process architecture");
return llvm::createStringError("cannot get process architecture");
}
std::unique_ptr<NativeProcessNetBSD> process_up(new NativeProcessNetBSD(
@ -1113,7 +1113,7 @@ NativeProcessNetBSD::SaveCore(llvm::StringRef path_hint) {
if (std::error_code errc =
llvm::sys::fs::createTemporaryFile("lldb", "core", path))
return llvm::createStringError(errc, "Unable to create a temporary file");
return llvm::createStringError(errc, "unable to create a temporary file");
error = PtraceWrapper(PT_DUMPCORE, GetID(), path.data(), path.size());
if (error.Fail())

View File

@ -1010,7 +1010,7 @@ public:
INPUT_RECORD inputRecord;
DWORD numRead = 0;
if (!PeekConsoleInput(hStdin, &inputRecord, 1, &numRead))
return llvm::createStringError("Failed to peek standard input.");
return llvm::createStringError("failed to peek standard input");
if (numRead == 0)
return false;
@ -1021,7 +1021,7 @@ public:
return true;
if (!ReadConsoleInput(hStdin, &inputRecord, 1, &numRead))
return llvm::createStringError("Failed to read standard input.");
return llvm::createStringError("failed to read standard input");
}
}

View File

@ -645,7 +645,7 @@ ProcessElfCore::parseSegment(const DataExtractor &segment) {
while (offset < segment.GetByteSize()) {
ELFNote note = ELFNote();
if (!note.Parse(segment, &offset))
return llvm::createStringError("Unable to parse note segment");
return llvm::createStringError("unable to parse note segment");
size_t note_start = offset;
size_t note_size = llvm::alignTo(note.n_descsz, 4);

View File

@ -2442,7 +2442,7 @@ GDBRemoteCommunicationServerLLGS::Handle_H(StringExtractorGDBRemote &packet) {
auto pid_tid = packet.GetPidTid(default_process ? default_process->GetID()
: LLDB_INVALID_PROCESS_ID);
if (!pid_tid)
return SendErrorResponse(llvm::createStringError("Malformed thread-id"));
return SendErrorResponse(llvm::createStringError("malformed thread-id"));
lldb::pid_t pid = pid_tid->first;
lldb::tid_t tid = pid_tid->second;
@ -2451,13 +2451,13 @@ GDBRemoteCommunicationServerLLGS::Handle_H(StringExtractorGDBRemote &packet) {
return SendUnimplementedResponse("Selecting all processes not supported");
if (pid == LLDB_INVALID_PROCESS_ID)
return SendErrorResponse(
llvm::createStringError("No current process and no PID provided"));
llvm::createStringError("no current process and no PID provided"));
// Check the process ID and find respective process instance.
auto new_process_it = m_debugged_processes.find(pid);
if (new_process_it == m_debugged_processes.end())
return SendErrorResponse(
llvm::createStringErrorV("No process with PID {0} debugged", pid));
llvm::createStringErrorV("no process with PID {0} debugged", pid));
// Ensure we have the given thread when not specifying -1 (all threads) or 0
// (any thread).
@ -4121,7 +4121,7 @@ GDBRemoteCommunicationServerLLGS::Handle_T(StringExtractorGDBRemote &packet) {
auto pid_tid = packet.GetPidTid(m_current_process ? m_current_process->GetID()
: LLDB_INVALID_PROCESS_ID);
if (!pid_tid)
return SendErrorResponse(llvm::createStringError("Malformed thread-id"));
return SendErrorResponse(llvm::createStringError("malformed thread-id"));
lldb::pid_t pid = pid_tid->first;
lldb::tid_t tid = pid_tid->second;
@ -4130,7 +4130,7 @@ GDBRemoteCommunicationServerLLGS::Handle_T(StringExtractorGDBRemote &packet) {
// explicit about the error.
if (pid == LLDB_INVALID_PROCESS_ID)
return SendErrorResponse(
llvm::createStringError("No current process and no PID provided"));
llvm::createStringError("no current process and no PID provided"));
// Check the process ID and find respective process instance.
auto new_process_it = m_debugged_processes.find(pid);

View File

@ -462,7 +462,7 @@ public:
// Call the static method.
llvm::Expected<PythonObject> expected_return_object =
llvm::createStringError("Not initialized.");
llvm::createStringError("not initialized");
std::apply(
[&method, &expected_return_object](auto &&...args) {
llvm::consumeError(expected_return_object.takeError());
@ -525,7 +525,7 @@ protected:
auto transformed_args = TransformArgs(original_args);
llvm::Expected<PythonObject> expected_return_object =
llvm::createStringError("Not initialized.");
llvm::createStringError("not initialized");
std::apply(
[&implementor, &method_name, &expected_return_object](auto &&...args) {
llvm::consumeError(expected_return_object.takeError());

View File

@ -43,6 +43,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorExtras.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatAdapters.h"
@ -1957,14 +1958,17 @@ lldb::ValueObjectSP ScriptInterpreterPythonImpl::GetChildAtIndex(
llvm::Expected<uint32_t> ScriptInterpreterPythonImpl::GetIndexOfChildWithName(
const StructuredData::ObjectSP &implementor_sp, const char *child_name) {
if (!implementor_sp)
return llvm::createStringError("Type has no child named '%s'", child_name);
return llvm::createStringErrorV("type has no child named '{0}'",
child_name);
StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
if (!generic)
return llvm::createStringError("Type has no child named '%s'", child_name);
return llvm::createStringErrorV("type has no child named '{0}'",
child_name);
auto *implementor = static_cast<PyObject *>(generic->GetValue());
if (!implementor)
return llvm::createStringError("Type has no child named '%s'", child_name);
return llvm::createStringErrorV("type has no child named '{0}'",
child_name);
uint32_t ret_val = UINT32_MAX;
@ -1976,7 +1980,8 @@ llvm::Expected<uint32_t> ScriptInterpreterPythonImpl::GetIndexOfChildWithName(
}
if (ret_val == UINT32_MAX)
return llvm::createStringError("Type has no child named '%s'", child_name);
return llvm::createStringErrorV("type has no child named '{0}'",
child_name);
return ret_val;
}

View File

@ -372,7 +372,7 @@ llvm::Expected<lldb::TypeSP>
SymbolFileCTF::CreateModifier(const CTFModifier &ctf_modifier) {
Type *ref_type = ResolveTypeUID(ctf_modifier.type);
if (!ref_type)
return llvm::createStringErrorV("Could not find modified type: {0}",
return llvm::createStringErrorV("could not find modified type: {0}",
ctf_modifier.type);
CompilerType compiler_type;
@ -406,7 +406,7 @@ SymbolFileCTF::CreateTypedef(const CTFTypedef &ctf_typedef) {
Type *underlying_type = ResolveTypeUID(ctf_typedef.type);
if (!underlying_type)
return llvm::createStringErrorV(
"Could not find typedef underlying type: {0}", ctf_typedef.type);
"could not find typedef underlying type: {0}", ctf_typedef.type);
CompilerType target_ast_type = underlying_type->GetFullCompilerType();
clang::DeclContext *decl_ctx = m_ast->GetTranslationUnitDecl();
@ -423,7 +423,7 @@ llvm::Expected<lldb::TypeSP>
SymbolFileCTF::CreateArray(const CTFArray &ctf_array) {
Type *element_type = ResolveTypeUID(ctf_array.type);
if (!element_type)
return llvm::createStringErrorV("Could not find array element type: {0}",
return llvm::createStringErrorV("could not find array element type: {0}",
ctf_array.type);
auto element_size_or_err = element_type->GetByteSize(nullptr);
@ -472,7 +472,7 @@ SymbolFileCTF::CreateFunction(const CTFFunction &ctf_function) {
Type *ret_type = ResolveTypeUID(ctf_function.return_type);
if (!ret_type)
return llvm::createStringErrorV("Could not find function return type: {0}",
return llvm::createStringErrorV("could not find function return type: {0}",
ctf_function.return_type);
CompilerType func_type = m_ast->CreateFunctionType(

View File

@ -3109,13 +3109,13 @@ SymbolFileNativePDB::ResolveUdtDeclaration(PdbTypeSymId type_id) {
auto it = m_udt_declarations.find(type_id.index);
if (it == m_udt_declarations.end())
return llvm::createStringError("No UDT declaration found");
return llvm::createStringError("no UDT declaration found");
llvm::StringRef file_name;
if (it->second.IsIpiIndex) {
CVType cvt = m_index->ipi().getType(it->second.FileNameIndex);
if (cvt.kind() != LF_STRING_ID)
return llvm::createStringError("File name was not a LF_STRING_ID");
return llvm::createStringError("file name was not a LF_STRING_ID");
StringIdRecord sid;
if (auto err = TypeDeserializer::deserializeAs(cvt, sid))

View File

@ -13,6 +13,7 @@
#include "clang/Frontend/ASTConsumers.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorExtras.h"
#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/FormatVariadic.h"
@ -7020,8 +7021,7 @@ TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
break;
}
}
return llvm::createStringError("Type has no child named '%s'",
name.str().c_str());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
CompilerType

View File

@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Target/ExecutionContext.h"
@ -21,6 +20,7 @@
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-enumerations.h"
#include "llvm/Support/ErrorExtras.h"
#include <iterator>
#include <mutex>
@ -769,7 +769,7 @@ CompilerType::GetBitSize(ExecutionContextScope *exe_scope) const {
if (IsValid())
if (auto type_system_sp = GetTypeSystem())
return type_system_sp->GetBitSize(m_type, exe_scope);
return llvm::createStringError("Invalid type: Cannot determine size");
return llvm::createStringError("invalid type: cannot determine size");
}
llvm::Expected<uint64_t>
@ -1036,8 +1036,7 @@ CompilerType::GetIndexOfChildWithName(llvm::StringRef name,
return type_system_sp->GetIndexOfChildWithName(m_type, name,
omit_empty_base_classes);
}
return llvm::createStringError("Type has no child named '%s'",
name.str().c_str());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
// Dumping types

View File

@ -685,7 +685,7 @@ llvm::Error
SymbolContext::GetAddressRangeFromHereToEndLine(uint32_t end_line,
AddressRange &range) {
if (!line_entry.IsValid()) {
return llvm::createStringError("Symbol context has no line table.");
return llvm::createStringError("symbol context has no line table");
}
range = line_entry.range;

View File

@ -2599,7 +2599,7 @@ Process::ReadModuleFromMemory(const FileSpec &file_spec,
file_spec.GetPath().c_str());
ModuleSP module_sp = std::make_shared<Module>(file_spec, ArchSpec());
if (!module_sp)
return llvm::createStringError("Failed to allocate Module");
return llvm::createStringError("failed to allocate module");
Status error;
std::unique_ptr<Progress> progress_up;

View File

@ -2601,7 +2601,7 @@ llvm::Expected<lldb::TypeSystemSP>
Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
bool create_on_demand) {
if (!m_valid)
return llvm::createStringError("Invalid Target");
return llvm::createStringError("invalid target");
if (language == eLanguageTypeMipsAssembler // GNU AS and LLVM use it for all
// assembly code
@ -2805,7 +2805,7 @@ void Target::SetDefaultArchitecture(const ArchSpec &arch) {
llvm::Error Target::SetLabel(llvm::StringRef label) {
size_t n = LLDB_INVALID_INDEX32;
if (llvm::to_integer(label, n))
return llvm::createStringError("Cannot use integer as target label.");
return llvm::createStringError("cannot use integer as target label");
TargetList &targets = GetDebugger().GetTargetList();
for (size_t i = 0; i < targets.GetNumTargets(); i++) {
TargetSP target_sp = targets.GetTargetAtIndex(i);

View File

@ -1624,7 +1624,7 @@ llvm::Error Thread::LoadScriptedFrameProvider(
auto [last_desc, last_id] = m_provider_chain_ids.back();
auto it = m_frame_providers.find(last_id);
if (it == m_frame_providers.end())
return llvm::createStringError("Previous frame provider not found");
return llvm::createStringError("previous frame provider not found");
SyntheticFrameProviderSP last_provider = it->second;
StackFrameListSP last_provider_frames = last_provider->GetInputFrames();
input_frames = std::make_shared<SyntheticStackFrameList>(

View File

@ -3044,7 +3044,7 @@ llvm::Expected<lldb::ValueObjectSP> ValueObject::CastDerivedToBaseType(
"Underlying start & target types should be different");
if (base_type_indices.empty())
return llvm::createStringError("Children sequence must be non-empty");
return llvm::createStringError("children sequence must be non-empty");
// Both the starting & target types are valid for the cast, and the list of
// base class indices is non-empty, so we can proceed with the cast.

View File

@ -25,6 +25,7 @@
#include "lldb/Utility/Stream.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ErrorExtras.h"
#include <cassert>
#include <memory>
@ -146,8 +147,7 @@ ValueObjectRegisterSet::GetIndexOfChildWithName(llvm::StringRef name) {
if (reg_info != nullptr)
return reg_info->kinds[eRegisterKindLLDB];
}
return llvm::createStringError("Type has no child named '%s'",
name.str().c_str());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
#pragma mark -

View File

@ -20,6 +20,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorExtras.h"
#include <optional>
namespace lldb_private {
@ -364,20 +365,18 @@ ValueObjectSynthetic::GetIndexOfChildWithName(llvm::StringRef name_ref) {
uint32_t max = index + 1;
auto num_children = GetNumChildrenIgnoringErrors(max);
if (index >= num_children)
return llvm::createStringError("Subscript index out of range: %zu",
index);
return llvm::createStringErrorV("subscript index out of range: {0}",
index);
}
std::lock_guard<std::mutex> guard(m_child_mutex);
m_name_toindex[name.GetCString()] = index;
return index;
} else if (!found_index && m_synth_filter_up == nullptr) {
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
} else if (found_index)
return *found_index;
return llvm::createStringError("Type has no child named '%s'",
name.AsCString());
return llvm::createStringErrorV("type has no child named '{0}'", name);
}
bool ValueObjectSynthetic::IsInScope() { return m_parent->IsInScope(); }

View File

@ -2,7 +2,7 @@
# RUN: %lldb %t -o "target variable var" -b | FileCheck %s
# CHECK: (lldb) target variable var
# CHECK: (long) var = <Unhandled opcode DW_OP_unknown_ff in DWARFExpression>
# CHECK: (long) var = <unhandled opcode DW_OP_unknown_ff in DWARFExpression>
.section .debug_abbrev,"",@progbits
.byte 1 # Abbreviation Code

View File

@ -4,7 +4,7 @@
# RUN: llvm-mc --triple x86_64-pc-linux %s --filetype=obj -o %t
# RUN: %lldb %t -o "target variable x" -o exit 2>&1 | FileCheck %s
# CHECK: Invalid type: Cannot determine size
# CHECK: invalid type: cannot determine size
# This tests a fix for a crash. If things are working we don't get a segfault.

View File

@ -4,7 +4,7 @@
# RUN: ld.lld %t.o -o %t
# RUN: %lldb %t -o "target variable e" -b | FileCheck %s
# CHECK: error: Invalid type: Cannot determine size
# CHECK: error: invalid type: cannot determine size
.type e,@object # @e
.section .rodata,"a",@progbits
@ -19,15 +19,15 @@ e:
.Linfo_string0:
.asciz "Hand-written DWARF"
.Linfo_string1:
.asciz "a.cpp"
.asciz "a.cpp"
.Linfo_string3:
.asciz "e"
.asciz "e"
.Linfo_string4:
.asciz "unsigned int"
.Linfo_string5:
.asciz "e1"
.asciz "e1"
.Linfo_string6:
.asciz "E"
.asciz "E"
.section .debug_abbrev,"",@progbits
.byte 1 # Abbreviation Code

View File

@ -19,7 +19,7 @@ target create -l "cat" /bin/cat
# CHECK: Cannot use label 'cat' since it's set in target #1.
target create -l 42 /bin/cat
# CHECK: error: Cannot use integer as target label.
# CHECK: error: cannot use integer as target label
target select 0
# CHECK: * target #0: [[LS_PATH]]

View File

@ -629,7 +629,7 @@ TEST(DWARFExpression, DW_OP_unknown) {
EXPECT_THAT_EXPECTED(
Evaluate({0xff}),
llvm::FailedWithMessage(
"Unhandled opcode DW_OP_unknown_ff in DWARFExpression"));
"unhandled opcode DW_OP_unknown_ff in DWARFExpression"));
}
TEST_F(DWARFExpressionMockProcessTest, DW_OP_deref) {

View File

@ -36,37 +36,37 @@ static LabelTestCase g_label_test_cases[] = {
{},
{"expected function call label prefix '$__lldb_func' but found "
"'$__lldb_funcc' instead."}},
{"", {}, {"malformed function call label."}},
{"foo", {}, {"malformed function call label."}},
{"$__lldb_func", {}, {"malformed function call label."}},
{"$__lldb_func:", {}, {"malformed function call label."}},
{"$__lldb_func:blah", {}, {"malformed function call label."}},
{"$__lldb_func:blah:0x0", {}, {"malformed function call label."}},
{"$__lldb_func:111:0x0:0x0", {}, {"malformed function call label."}},
{"", {}, {"malformed function call label"}},
{"foo", {}, {"malformed function call label"}},
{"$__lldb_func", {}, {"malformed function call label"}},
{"$__lldb_func:", {}, {"malformed function call label"}},
{"$__lldb_func:blah", {}, {"malformed function call label"}},
{"$__lldb_func:blah:0x0", {}, {"malformed function call label"}},
{"$__lldb_func:111:0x0:0x0", {}, {"malformed function call label"}},
{"$__lldb_func:111:abc:0x0:_Z3foov",
{},
{"failed to parse module ID from 'abc'."}},
{"failed to parse module ID from 'abc'"}},
{"$__lldb_func:111:-1:0x0:_Z3foov",
{},
{"failed to parse module ID from '-1'."}},
{"failed to parse module ID from '-1'"}},
{"$__lldb_func:111:0x0invalid:0x0:_Z3foov",
{},
{"failed to parse module ID from '0x0invalid'."}},
{"failed to parse module ID from '0x0invalid'"}},
{"$__lldb_func:111:0x0 :0x0:_Z3foov",
{},
{"failed to parse module ID from '0x0 '."}},
{"failed to parse module ID from '0x0 '"}},
{"$__lldb_func:blah:0x0:abc:_Z3foov",
{},
{"failed to parse symbol ID from 'abc'."}},
{"failed to parse symbol ID from 'abc'"}},
{"$__lldb_func:blah:0x5:-1:_Z3foov",
{},
{"failed to parse symbol ID from '-1'."}},
{"failed to parse symbol ID from '-1'"}},
{"$__lldb_func:blah:0x5:0x0invalid:_Z3foov",
{},
{"failed to parse symbol ID from '0x0invalid'."}},
{"failed to parse symbol ID from '0x0invalid'"}},
{"$__lldb_func:blah:0x5:0x0 :_Z3foov",
{},
{"failed to parse symbol ID from '0x0 '."}},
{"failed to parse symbol ID from '0x0 '"}},
{"$__lldb_func:blah:0x0:0x0:_Z3foov",
{
/*.discriminator=*/"blah",