19#include "llvm/ADT/StringRef.h"
33template <StringElementType element_type>
35 switch (element_type) {
36 case StringElementType::ASCII:
37 case StringElementType::UTF8:
39 case StringElementType::UTF16:
41 case StringElementType::UTF32:
53static std::optional<std::pair<uint64_t, ValueObjectSP>>
56 if (!valobj_pair_sp || !valobj_pair_sp->GetError().Success())
59 ValueObjectSP size_sp = valobj_pair_sp->GetChildMemberWithName(
"_Mysize");
60 ValueObjectSP capacity_sp = valobj_pair_sp->GetChildMemberWithName(
"_Myres");
61 ValueObjectSP bx_sp = valobj_pair_sp->GetChildMemberWithName(
"_Bx");
62 if (!size_sp || !capacity_sp || !bx_sp)
66 uint64_t size = size_sp->GetValueAsUnsigned(0, &success);
69 uint64_t capacity = capacity_sp->GetValueAsUnsigned(0, &success);
73 size_t bufSize = std::max<size_t>(16 / element_size, 1);
74 bool isShortString = capacity < bufSize;
79 return std::make_pair(size, buf_sp);
84 return std::make_pair(size, ptr_sp);
88template <StringPr
inter::StringElementType element_type>
92 std::string prefix_token) {
97 auto [size, location_sp] = *string_info;
100 stream, summary_options, location_sp, size, prefix_token);
102template <StringPr
inter::StringElementType element_type>
105 std::string prefix_token) {
108 valobj, scratch_stream, summary_options, prefix_token);
110 stream << scratch_stream.
GetData();
112 stream <<
"Summary Unavailable";
116template <StringPr
inter::StringElementType element_type>
119 std::string prefix_token) {
122 if (!data_sp || !size_sp)
125 bool success =
false;
126 uint64_t size = size_sp->GetValueAsUnsigned(0, &success);
128 stream <<
"Summary Unavailable";
134 scratch_stream, summary_options, data_sp, size, prefix_token);
137 stream << scratch_stream.
GetData();
139 stream <<
"Summary Unavailable";
144 std::vector<uint32_t> indexes;
150 std::vector<uint32_t> indexes;
159 summary_options,
"L");
167 valobj, stream, summary_options,
"");
174 valobj, stream, summary_options,
"u8");
181 valobj, stream, summary_options,
"u");
188 valobj, stream, summary_options,
"U");
195 summary_options,
"L");
203 summary_options,
"");
210 summary_options,
"u8");
217 summary_options,
"u");
224 summary_options,
"U");
228 std::vector<uint32_t> indexes;
238 int64_t value = value_sp->GetValueAsSigned(0, &success);
254 stream <<
"equivalent";
260 stream <<
"unordered";
278 stream <<
"equivalent";
312 return valobj_sp->GetChildMemberWithName(
"_File") !=
nullptr;
323 if (!file_sp || !function_sp || !line_sp || !column_sp)
326 bool success =
false;
327 uint64_t line = line_sp->GetValueAsUnsigned(0, &success);
331 uint64_t column = column_sp->GetValueAsUnsigned(0, &success);
335 const char *file = file_sp->GetSummaryAsCString();
337 if (line == 0 && column == 0 &&
338 (!file || file[0] ==
'\0' || llvm::StringRef(file) ==
"\"\""))
341 stream.
Format(
"{0}:{1}:{2}", file ? file :
"<unknown>", line, column);
343 if (
const char *function = function_sp->GetSummaryAsCString())
344 stream.
Printf(
" (%s)", function);
static std::optional< std::pair< uint64_t, ValueObjectSP > > ExtractMsvcStlStringInfo(ValueObject &valobj, uint64_t element_size)
Determine the size in bytes of valobj (a MSVC STL std::string object) and extract its data payload.
static bool formatStringImpl(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options, std::string prefix_token)
static constexpr uint64_t StringElementByteSize()
static bool MsvcStlStringSummaryProviderImpl(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options, std::string prefix_token)
static std::optional< int64_t > MsvcStlExtractOrderingValue(ValueObject &valobj)
static bool formatStringViewImpl(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options, std::string prefix_token)
static ValueObjectSP ExtractMsvcStlStringData(ValueObject &valobj)
StringPrinter::StringElementType StringElementType
size_t GetIndexOfChildMemberWithName(llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) const
Lookup a child member given a name.
const char * GetData() const
A stream class that can stream formatted output to a file.
void Format(const char *format, Args &&... args)
Forwards the arguments to llvm::formatv and writes to the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create=true)
lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef< llvm::StringRef > names)
CompilerType GetCompilerType()
virtual lldb::ValueObjectSP GetNonSyntheticValue()
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP