#include <stdint.h>
// C++ Includes
+#include <initializer_list>
#include <string>
#include <vector>
+#include <utility>
// Other libraries and framework includes
#include "llvm/ADT/SmallVector.h"
return clang_type;
}
+
+ ClangASTType
+ GetOrCreateStructForIdentifier (const ConstString &type_name,
+ const std::initializer_list< std::pair < const char *, ClangASTType > >& type_fields);
//------------------------------------------------------------------
// Structure, Unions, Classes
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ProcessStructReader.h"
+
#include <algorithm>
using namespace lldb;
return true;
}
+static ClangASTType
+GetNSPathStore2Type (Target &target)
+{
+ static ConstString g_type_name("__lldb_autogen_nspathstore2");
+
+ ClangASTContext *ast_ctx = target.GetScratchClangASTContext();
+
+ if (!ast_ctx)
+ return ClangASTType();
+
+ ClangASTType voidstar = ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType();
+ ClangASTType uint32 = ast_ctx->GetIntTypeFromBitSize(32, false);
+
+ return ast_ctx->GetOrCreateStructForIdentifier(g_type_name, {
+ {"isa",voidstar},
+ {"lengthAndRef",uint32},
+ {"buffer",voidstar}
+ });
+}
+
bool
lldb_private::formatters::NSStringSummaryProvider (ValueObject& valobj, Stream& stream)
{
}
else if (is_special)
{
- uint64_t location = valobj_addr + (ptr_size == 8 ? 12 : 8);
+ ProcessStructReader reader(valobj.GetProcessSP().get(), valobj.GetValueAsUnsigned(0), GetNSPathStore2Type(*valobj.GetTargetSP()));
+ explicit_length = reader.GetField<uint32_t>(ConstString("lengthAndRef")) >> 20;
+ lldb::addr_t location = valobj.GetValueAsUnsigned(0) + ptr_size + 4;
+
ReadUTFBufferAndDumpToStreamOptions<UTF16> options;
options.SetConversionFunction(ConvertUTF16toUTF8);
options.SetLocation(location);
return ClangASTType();
}
-
+ClangASTType
+ClangASTContext::GetOrCreateStructForIdentifier (const ConstString &type_name,
+ const std::initializer_list< std::pair < const char *, ClangASTType > >& type_fields)
+{
+ ClangASTType type;
+ if ((type = GetTypeForIdentifier<clang::CXXRecordDecl>(type_name)).IsValid())
+ return type;
+ type = CreateRecordType(nullptr, lldb::eAccessPublic, type_name.GetCString(), clang::TTK_Struct, lldb::eLanguageTypeC);
+ type.StartTagDeclarationDefinition();
+ for (const auto& field : type_fields)
+ type.AddFieldToRecordType(field.first, field.second, lldb::eAccessPublic, 0);
+ type.CompleteTagDeclarationDefinition();
+ return type;
+}
#pragma mark Enumeration Types