summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Core/ClangForward.h11
-rw-r--r--lldb/include/lldb/Expression/ClangExpressionDeclMap.h39
-rw-r--r--lldb/include/lldb/Expression/ClangFunction.h5
-rw-r--r--lldb/include/lldb/Expression/ClangResultSynthesizer.h5
-rw-r--r--lldb/include/lldb/Symbol/ASTType.h113
-rw-r--r--lldb/include/lldb/Symbol/ClangASTContext.h2
-rw-r--r--lldb/include/lldb/Symbol/ClangASTType.h219
-rw-r--r--lldb/include/lldb/Symbol/Type.h80
-rw-r--r--lldb/lldb.xcodeproj/project.pbxproj16
-rw-r--r--lldb/source/Commands/CommandObjectExpression.cpp42
-rw-r--r--lldb/source/Commands/CommandObjectVariable.cpp13
-rw-r--r--lldb/source/Core/Value.cpp7
-rw-r--r--lldb/source/Core/ValueObject.cpp23
-rw-r--r--lldb/source/Core/ValueObjectChild.cpp3
-rw-r--r--lldb/source/Core/ValueObjectRegister.cpp3
-rw-r--r--lldb/source/Expression/ClangExpression.cpp18
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp19
-rw-r--r--lldb/source/Expression/DWARFExpression.cpp21
-rw-r--r--lldb/source/Host/macosx/Symbols.cpp36
-rw-r--r--lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp38
-rw-r--r--lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h25
-rw-r--r--lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp16
-rw-r--r--lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h10
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp247
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h11
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp6
-rw-r--r--lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp2
-rw-r--r--lldb/source/Symbol/ASTType.cpp20
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp176
-rw-r--r--lldb/source/Symbol/ClangASTType.cpp1114
-rw-r--r--lldb/source/Symbol/Function.cpp7
-rw-r--r--lldb/source/Symbol/Type.cpp973
32 files changed, 1769 insertions, 1551 deletions
diff --git a/lldb/include/lldb/Core/ClangForward.h b/lldb/include/lldb/Core/ClangForward.h
index 3f4a2aee832..ab5166fc09d 100644
--- a/lldb/include/lldb/Core/ClangForward.h
+++ b/lldb/include/lldb/Core/ClangForward.h
@@ -24,9 +24,13 @@ namespace clang
class Context;
}
+ class Action;
class ASTContext;
+ class ASTRecordLayout;
class AddrLabelExpr;
+ class AnalyzerOptions;
class BinaryOperator;
+ class CodeGenOptions;
class CodeGenerator;
class CompilerInstance;
class CXXBaseSpecifier;
@@ -38,18 +42,23 @@ namespace clang
class CharacterLiteral;
class CompoundAssignOperator;
class Decl;
+ class DeclarationName;
class DeclaratorDecl;
class DeclContext;
class DeclRefExpr;
class DeclStmt;
+ class DependencyOutputOptions;
class Diagnostic;
+ class DiagnosticOptions;
class EnumDecl;
class Expr;
class ExtVectorElementExpr;
class FieldDecl;
class FloatingLiteral;
+ class FrontendOptions;
class FunctionDecl;
class GotoStmt;
+ class HeaderSearchOptions;
class IdentifierTable;
class IntegerLiteral;
class LabelStmt;
@@ -72,6 +81,8 @@ namespace clang
class ParenExpr;
class ParmVarDecl;
class PredefinedExpr;
+ class PreprocessorOptions;
+ class PreprocessorOutputOptions;
class QualType;
class QualifiedNameType;
class RecordDecl;
diff --git a/lldb/include/lldb/Expression/ClangExpressionDeclMap.h b/lldb/include/lldb/Expression/ClangExpressionDeclMap.h
index 7e1bdca1244..366067ff859 100644
--- a/lldb/include/lldb/Expression/ClangExpressionDeclMap.h
+++ b/lldb/include/lldb/Expression/ClangExpressionDeclMap.h
@@ -21,13 +21,7 @@
// Project includes
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/Value.h"
-#include "lldb/Symbol/ASTType.h"
-
-namespace clang {
- class DeclarationName;
- class DeclContext;
- class QualType;
-}
+#include "lldb/Symbol/ClangASTType.h"
namespace llvm {
class Value;
@@ -35,6 +29,33 @@ namespace llvm {
namespace lldb_private {
+//----------------------------------------------------------------------
+// For cases in which there are multiple classes of types that are not
+// interchangeable, to allow static type checking.
+//----------------------------------------------------------------------
+template <unsigned int C> class TaggedClangASTType : public ClangASTType
+{
+public:
+ TaggedClangASTType (void *type, clang::ASTContext *ast_context) :
+ ClangASTType(type, ast_context) { }
+
+ TaggedClangASTType (const TaggedClangASTType<C> &tw) :
+ ClangASTType(tw) { }
+
+ TaggedClangASTType () :
+ ClangASTType() { }
+
+ ~TaggedClangASTType() { }
+
+ const TaggedClangASTType<C> &
+ operator= (const TaggedClangASTType<C> &tw)
+ {
+ ClangASTType::operator= (tw);
+ return *this;
+ }
+};
+
+
class Error;
class Function;
class NameSearchContext;
@@ -83,8 +104,8 @@ public:
void GetDecls (NameSearchContext &context,
const char *name);
private:
- typedef TaggedASTType<0> TypeFromParser;
- typedef TaggedASTType<1> TypeFromUser;
+ typedef TaggedClangASTType<0> TypeFromParser;
+ typedef TaggedClangASTType<1> TypeFromUser;
struct Tuple
{
diff --git a/lldb/include/lldb/Expression/ClangFunction.h b/lldb/include/lldb/Expression/ClangFunction.h
index f76157a9c6d..f0555bc916a 100644
--- a/lldb/include/lldb/Expression/ClangFunction.h
+++ b/lldb/include/lldb/Expression/ClangFunction.h
@@ -26,11 +26,6 @@
// Right now, this is just a toy. It calls a set function, with fixed
// values.
-namespace clang
-{
- class ASTRecordLayout;
-}
-
namespace lldb_private
{
diff --git a/lldb/include/lldb/Expression/ClangResultSynthesizer.h b/lldb/include/lldb/Expression/ClangResultSynthesizer.h
index ed00401486a..4953bd4b707 100644
--- a/lldb/include/lldb/Expression/ClangResultSynthesizer.h
+++ b/lldb/include/lldb/Expression/ClangResultSynthesizer.h
@@ -11,10 +11,7 @@
#define liblldb_ClangResultSynthesizer_h_
#include "clang/Sema/SemaConsumer.h"
-
-namespace clang {
- class Action;
-}
+#include "lldb/Core/ClangForward.h"
namespace lldb_private {
diff --git a/lldb/include/lldb/Symbol/ASTType.h b/lldb/include/lldb/Symbol/ASTType.h
deleted file mode 100644
index 3ce0789ab47..00000000000
--- a/lldb/include/lldb/Symbol/ASTType.h
+++ /dev/null
@@ -1,113 +0,0 @@
-//===-- ASTType.h -----------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_ASTType_h_
-#define liblldb_ASTType_h_
-
-namespace clang
-{
- class ASTContext;
-}
-
-namespace lldb_private
-{
-
-class ASTTypeBase
-{
-protected:
- ASTTypeBase (void *type, clang::ASTContext *ast_context) :
- m_type(type),
- m_ast_context(ast_context)
- {
- }
-
- ASTTypeBase (const ASTTypeBase &tw) :
- m_type(tw.m_type),
- m_ast_context(tw.m_ast_context)
- {
- }
-
- ASTTypeBase () :
- m_type(0),
- m_ast_context(0)
- {
- }
-
- ~ASTTypeBase();
-
- ASTTypeBase &operator= (const ASTTypeBase &atb)
- {
- m_type = atb.m_type;
- m_ast_context = atb.m_ast_context;
- return *this;
- }
-
-public:
- void *GetType() const
- {
- return m_type;
- }
-
- clang::ASTContext *GetASTContext() const
- {
- return m_ast_context;
- }
-
-private:
- void *m_type;
- clang::ASTContext *m_ast_context;
-};
-
-class ASTType : public ASTTypeBase
-{
-public:
- ASTType (void *type, clang::ASTContext *ast_context) :
- ASTTypeBase(type, ast_context) { }
-
- ASTType (const ASTType &at) :
- ASTTypeBase(at) { }
-
- ASTType () :
- ASTTypeBase() { }
-
- ~ASTType();
-
- ASTType &operator= (const ASTType &at)
- {
- ASTTypeBase::operator= (at);
- return *this;
- }
-};
-
-// For cases in which there are multiple classes of types that are not
-// interchangeable, to allow static type checking.
-template <unsigned int C> class TaggedASTType : public ASTTypeBase
-{
-public:
- TaggedASTType (void *type, clang::ASTContext *ast_context) :
- ASTTypeBase(type, ast_context) { }
-
- TaggedASTType (const TaggedASTType<C> &tw) :
- ASTTypeBase(tw) { }
-
- TaggedASTType () :
- ASTTypeBase() { }
-
- ~TaggedASTType() { }
-
- TaggedASTType<C> &operator= (const TaggedASTType<C> &tw)
- {
- ASTTypeBase::operator= (tw);
- return *this;
- }
-};
-
-}
-
-#endif
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index faaf5872a60..565f3ce2e57 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -21,7 +21,7 @@
// Project includes
#include "lldb/lldb-enumerations.h"
#include "lldb/Core/ClangForward.h"
-#include "lldb/Symbol/ASTType.h"
+#include "lldb/Symbol/ClangASTType.h"
namespace lldb_private {
diff --git a/lldb/include/lldb/Symbol/ClangASTType.h b/lldb/include/lldb/Symbol/ClangASTType.h
new file mode 100644
index 00000000000..b463d13d563
--- /dev/null
+++ b/lldb/include/lldb/Symbol/ClangASTType.h
@@ -0,0 +1,219 @@
+//===-- ClangASTType.h ------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ClangASTType_h_
+#define liblldb_ClangASTType_h_
+
+#include "lldb/lldb-include.h"
+#include "lldb/Core/ClangForward.h"
+
+namespace lldb_private {
+
+//----------------------------------------------------------------------
+// A class that can carry around a clang ASTContext and a opaque clang
+// QualType. A clang::QualType can be easily reconstructed from an
+// opaque clang type and often the ASTContext is needed when doing
+// various type related tasks, so this class allows both items to travel
+// in a single very lightweight class that can be used. There are many
+// static equivalents of the member functions that allow the ASTContext
+// and the opaque clang QualType to be specified for ease of use and
+// to avoid code duplication.
+//----------------------------------------------------------------------
+class ClangASTType
+{
+protected:
+ ClangASTType (void *type, clang::ASTContext *ast_context) :
+ m_type (type),
+ m_ast (ast_context)
+ {
+ }
+
+ ClangASTType (const ClangASTType &tw) :
+ m_type (tw.m_type),
+ m_ast (tw.m_ast)
+ {
+ }
+
+ ClangASTType () :
+ m_type (0),
+ m_ast (0)
+ {
+ }
+
+ ~ClangASTType();
+
+ const ClangASTType &
+ operator= (const ClangASTType &atb)
+ {
+ m_type = atb.m_type;
+ m_ast = atb.m_ast;
+ return *this;
+ }
+
+public:
+ void *
+ GetOpaqueQualType() const
+ {
+ return m_type;
+ }
+
+ clang::ASTContext *
+ GetASTContext() const
+ {
+ return m_ast;
+ }
+
+ ConstString
+ GetClangTypeName ();
+
+ static ConstString
+ GetClangTypeName (void *clang_type);
+
+ void
+ DumpValue (ExecutionContext *exe_ctx,
+ Stream *s,
+ lldb::Format format,
+ const DataExtractor &data,
+ uint32_t data_offset,
+ size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset,
+ bool show_types,
+ bool show_summary,
+ bool verbose,
+ uint32_t depth);
+
+ static void
+ DumpValue (clang::ASTContext *ast_context,
+ void *opaque_clang_qual_type,
+ ExecutionContext *exe_ctx,
+ Stream *s,
+ lldb::Format format,
+ const DataExtractor &data,
+ uint32_t data_offset,
+ size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset,
+ bool show_types,
+ bool show_summary,
+ bool verbose,
+ uint32_t depth);
+
+ bool
+ DumpTypeValue (Stream *s,
+ lldb::Format format,
+ const DataExtractor &data,
+ uint32_t data_offset,
+ size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset);
+
+
+ static bool
+ DumpTypeValue (clang::ASTContext *ast_context,
+ void *opaque_clang_qual_type,
+ Stream *s,
+ lldb::Format format,
+ const DataExtractor &data,
+ uint32_t data_offset,
+ size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset);
+
+ void
+ DumpSummary (ExecutionContext *exe_ctx,
+ Stream *s,
+ const DataExtractor &data,
+ uint32_t data_offset,
+ size_t data_byte_size);
+
+
+ static void
+ DumpSummary (clang::ASTContext *ast_context,
+ void *opaque_clang_qual_type,
+ ExecutionContext *exe_ctx,
+ Stream *s,
+ const DataExtractor &data,
+ uint32_t data_offset,
+ size_t data_byte_size);
+
+
+ lldb::Encoding
+ GetEncoding (uint32_t &count);
+
+ static lldb::Encoding
+ GetEncoding (void *opaque_clang_qual_type, uint32_t &count);
+
+ lldb::Format
+ GetFormat ();
+
+ static lldb::Format
+ GetFormat (void *opaque_clang_qual_type);
+
+ bool
+ GetValueAsScalar (const DataExtractor &data,
+ uint32_t data_offset,
+ size_t data_byte_size,
+ Scalar &value);
+
+ static bool
+ GetValueAsScalar (clang::ASTContext *ast_context,
+ void *opaque_clang_qual_type,
+ const DataExtractor &data,
+ uint32_t data_offset,
+ size_t data_byte_size,
+ Scalar &value);
+
+ bool
+ SetValueFromScalar (const Scalar &value,
+ Stream &strm);
+
+ static bool
+ SetValueFromScalar (clang::ASTContext *ast_context,
+ void *opaque_clang_qual_type,
+ const Scalar &value,
+ Stream &strm);
+
+ bool
+ ReadFromMemory (ExecutionContext *exe_ctx,
+ lldb::addr_t addr,
+ lldb::AddressType address_type,
+ DataExtractor &data);
+
+ static bool
+ ReadFromMemory (clang::ASTContext *ast_context,
+ void *opaque_clang_qual_type,
+ ExecutionContext *exe_ctx,
+ lldb::addr_t addr,
+ lldb::AddressType address_type,
+ DataExtractor &data);
+
+ bool
+ WriteToMemory (ExecutionContext *exe_ctx,
+ lldb::addr_t addr,
+ lldb::AddressType address_type,
+ StreamString &new_value);
+
+ static bool
+ WriteToMemory (clang::ASTContext *ast_context,
+ void *opaque_clang_qual_type,
+ ExecutionContext *exe_ctx,
+ lldb::addr_t addr,
+ lldb::AddressType address_type,
+ StreamString &new_value);
+
+private:
+ void *m_type;
+ clang::ASTContext *m_ast;
+};
+
+
+} // namespace lldb_private
+
+#endif // #ifndef liblldb_ClangASTType_h_
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index c25675ee584..d2b14018045 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -103,35 +103,6 @@ public:
return m_name;
}
- static ConstString
- GetClangTypeName (void *clang_qual_type);
-
- static void
- DumpValue(ExecutionContext *exe_ctx,
- clang::ASTContext *ast_context,
- void *clang_qual_type,
- Stream *s,
- lldb::Format format,
- const DataExtractor &data,
- uint32_t data_offset,
- size_t data_byte_size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- bool show_types,
- bool show_summary,
- bool verbose,
- uint32_t depth);
-
- static void
- DumpSummary (ExecutionContext *exe_ctx,
- clang::ASTContext *ast_context,
- void *clang_qual_type,
- Stream *s,
- const DataExtractor &data,
- uint32_t data_offset,
- size_t data_byte_size);
-
-
void
DumpValue(ExecutionContext *exe_ctx,
Stream *s,
@@ -151,31 +122,6 @@ public:
bool show_summary,
bool verbose);
- static bool
- DumpTypeValue ( Stream *s,
- clang::ASTContext *ast_context,
- void *clang_qual_type,
- lldb::Format format,
- const DataExtractor &data,
- uint32_t data_offset,
- size_t data_byte_size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset);
-
- static bool
- GetValueAsScalar (clang::ASTContext *ast_context,
- void *clang_qual_type,
- const DataExtractor &data,
- uint32_t data_offset,
- size_t data_byte_size,
- Scalar &value);
-
- static bool
- SetValueFromScalar (clang::ASTContext *ast_context,
- void *clang_qual_type,
- const Scalar &value,
- Stream &strm);
-
bool
ReadFromMemory (ExecutionContext *exe_ctx,
lldb::addr_t address,
@@ -188,23 +134,6 @@ public:
lldb::AddressType address_type,
DataExtractor &data);
-
- static bool
- ReadFromMemory (ExecutionContext *exe_ctx,
- clang::ASTContext *ast_context,
- void *clang_qual_type,
- lldb::addr_t addr,
- lldb::AddressType address_type,
- DataExtractor &data);
-
- static bool
- WriteToMemory (ExecutionContext *exe_ctx,
- clang::ASTContext *ast_context,
- void *clang_qual_type,
- lldb::addr_t addr,
- lldb::AddressType address_type,
- StreamString &new_value);
-
bool
GetIsDeclaration() const;
@@ -223,9 +152,6 @@ public:
lldb::Encoding
GetEncoding (uint32_t &count);
- static lldb::Encoding
- GetEncoding (void *clang_qual_type, uint32_t &count);
-
SymbolContextScope *
GetSymbolContextScope()
{
@@ -265,12 +191,6 @@ public:
static int
Compare(const Type &a, const Type &b);
- static lldb::Format
- GetFormat (void *clang_qual_type);
-
- static int
- DumpClangTypeName(Stream *s, void *clang_qual_type);
-
protected:
ConstString m_name;
uint64_t m_byte_size;
diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj
index d14976fc0ee..6c8863448c2 100644
--- a/lldb/lldb.xcodeproj/project.pbxproj
+++ b/lldb/lldb.xcodeproj/project.pbxproj
@@ -335,8 +335,8 @@
49D7072911B5AD11001AD875 /* ClangASTSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49D7072811B5AD11001AD875 /* ClangASTSource.cpp */; settings = {COMPILER_FLAGS = "-fno-rtti"; }; };
49DA743011DE6A5A006AEF7E /* IRToDWARF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DA742F11DE6A5A006AEF7E /* IRToDWARF.cpp */; };
49DA743511DE6BB2006AEF7E /* IRToDWARF.h in Headers */ = {isa = PBXBuildFile; fileRef = 49DA743411DE6BB2006AEF7E /* IRToDWARF.h */; };
- 49E45FAA11F660DC008F7B28 /* ASTType.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E45FA911F660DC008F7B28 /* ASTType.h */; };
- 49E45FAF11F660FE008F7B28 /* ASTType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49E45FAD11F660FE008F7B28 /* ASTType.cpp */; };
+ 49E45FAA11F660DC008F7B28 /* ClangASTType.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E45FA911F660DC008F7B28 /* ClangASTType.h */; };
+ 49E45FAF11F660FE008F7B28 /* ClangASTType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49E45FAD11F660FE008F7B28 /* ClangASTType.cpp */; };
49F1A74611B3388F003ED505 /* ClangExpressionDeclMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49F1A74511B3388F003ED505 /* ClangExpressionDeclMap.cpp */; };
49F1A74A11B338AE003ED505 /* ClangExpressionDeclMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F1A74911B338AE003ED505 /* ClangExpressionDeclMap.h */; };
4C08CDE811C81EF8001610A8 /* ThreadSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C08CDE711C81EF8001610A8 /* ThreadSpec.cpp */; };
@@ -912,8 +912,8 @@
49D7072811B5AD11001AD875 /* ClangASTSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangASTSource.cpp; path = source/Expression/ClangASTSource.cpp; sourceTree = "<group>"; };
49DA742F11DE6A5A006AEF7E /* IRToDWARF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IRToDWARF.cpp; path = source/Expression/IRToDWARF.cpp; sourceTree = "<group>"; };
49DA743411DE6BB2006AEF7E /* IRToDWARF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IRToDWARF.h; path = include/lldb/Expression/IRToDWARF.h; sourceTree = "<group>"; };
- 49E45FA911F660DC008F7B28 /* ASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASTType.h; path = include/lldb/Symbol/ASTType.h; sourceTree = "<group>"; };
- 49E45FAD11F660FE008F7B28 /* ASTType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTType.cpp; path = source/Symbol/ASTType.cpp; sourceTree = "<group>"; };
+ 49E45FA911F660DC008F7B28 /* ClangASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangASTType.h; path = include/lldb/Symbol/ClangASTType.h; sourceTree = "<group>"; };
+ 49E45FAD11F660FE008F7B28 /* ClangASTType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangASTType.cpp; path = source/Symbol/ClangASTType.cpp; sourceTree = "<group>"; };
49EC3E98118F90AC00B1265E /* ThreadPlanCallFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanCallFunction.cpp; path = source/Target/ThreadPlanCallFunction.cpp; sourceTree = "<group>"; };
49EC3E9C118F90D400B1265E /* ThreadPlanCallFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanCallFunction.h; path = include/lldb/Target/ThreadPlanCallFunction.h; sourceTree = "<group>"; };
49F1A74511B3388F003ED505 /* ClangExpressionDeclMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExpressionDeclMap.cpp; path = source/Expression/ClangExpressionDeclMap.cpp; sourceTree = "<group>"; };
@@ -1669,12 +1669,12 @@
isa = PBXGroup;
children = (
AF94005711C03F6500085DB9 /* SymbolVendor.cpp */,
- 49E45FA911F660DC008F7B28 /* ASTType.h */,
- 49E45FAD11F660FE008F7B28 /* ASTType.cpp */,
26BC7C5510F1B6E900F91463 /* Block.h */,
26BC7F1310F1B8EC00F91463 /* Block.cpp */,
26BC7C5610F1B6E900F91463 /* ClangASTContext.h */,
26BC7F1410F1B8EC00F91463 /* ClangASTContext.cpp */,
+ 49E45FA911F660DC008F7B28 /* ClangASTType.h */,
+ 49E45FAD11F660FE008F7B28 /* ClangASTType.cpp */,
26BC7C5710F1B6E900F91463 /* CompileUnit.h */,
26BC7F1510F1B8EC00F91463 /* CompileUnit.cpp */,
26BC7C5810F1B6E900F91463 /* Declaration.h */,
@@ -2201,7 +2201,7 @@
49307AB211DEA4F20081F992 /* IRForTarget.h in Headers */,
4C5DBBC911E3FEC60035160F /* CommandObjectCommands.h in Headers */,
26D27CA011ED3A4E0024D721 /* ELFHeader.h in Headers */,
- 49E45FAA11F660DC008F7B28 /* ASTType.h in Headers */,
+ 49E45FAA11F660DC008F7B28 /* ClangASTType.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2655,7 +2655,7 @@
49307AAE11DEA4D90081F992 /* IRForTarget.cpp in Sources */,
4C5DBBC811E3FEC60035160F /* CommandObjectCommands.cpp in Sources */,
26D27C9F11ED3A4E0024D721 /* ELFHeader.cpp in Sources */,
- 49E45FAF11F660FE008F7B28 /* ASTType.cpp in Sources */,
+ 49E45FAF11F660FE008F7B28 /* ClangASTType.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp
index 637d3dcd52a..4135ed82cc0 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -12,8 +12,10 @@
// C Includes
// C++ Includes
// Other libraries and framework includes
+#include "llvm/ADT/StringRef.h"
+
// Project includes
-#include "lldb/Interpreter/Args.h"
+#include "lldb/Core/Debugger.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/InputReader.h"
#include "lldb/Expression/ClangExpression.h"
@@ -21,15 +23,15 @@
#include "lldb/Expression/ClangExpressionVariable.h"
#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Host/Host.h"
-#include "lldb/Core/Debugger.h"
+#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Variable.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
-#include "llvm/ADT/StringRef.h"
using namespace lldb;
using namespace lldb_private;
@@ -402,22 +404,26 @@ CommandObjectExpression::EvaluateExpression (const char *expr, bool bare, Stream
if (clang_type)
{
if (m_options.show_types)
- Type::DumpClangTypeName (&output_stream, clang_type);
+ {
+ ConstString type_name(ClangASTType::GetClangTypeName (clang_type));
+ if (type_name)
+ output_stream.Printf("(%s) ", type_name.AsCString("<invalid>"));
+ }
- Type::DumpValue (&m_exe_ctx, // The execution context for memory and variable access
- ast_context, // The ASTContext that the clang type belongs to
- clang_type, // The opaque clang type we want to dump that value of
- &output_stream, // Stream to dump to
- format, // Format to use when dumping
- data, // A buffer containing the bytes for the clang type
- 0, // Byte offset within "data" where value is
- data.GetByteSize (), // Size in bytes of the value we are dumping
- 0, // Bitfield bit size
- 0, // Bitfield bit offset
- m_options.show_types, // Show types?
- m_options.show_summary, // Show summary?
- m_options.debug, // Debug logging output?
- UINT32_MAX); // Depth to dump in case this is an aggregate type
+ ClangASTType::DumpValue (ast_context, // The ASTContext that the clang type belongs to
+ clang_type, // The opaque clang type we want to dump that value of
+ &m_exe_ctx, // The execution context for memory and variable access
+ &output_stream, // Stream to dump to
+ format, // Format to use when dumping
+ data, // A buffer containing the bytes for the clang type
+ 0, // Byte offset within "data" where value is
+ data.GetByteSize (), // Size in bytes of the value we are dumping
+ 0, // Bitfield bit size
+ 0, // Bitfield bit offset
+ m_options.show_types, // Show types?
+ m_options.show_summary, // Show summary?
+ m_options.debug, // Debug logging output?
+ UINT32_MAX); // Depth to dump in case this is an aggregate type
}
else
{
diff --git a/lldb/source/Commands/CommandObjectVariable.cpp b/lldb/source/Commands/CommandObjectVariable.cpp
index a14fa510d5c..7a6592b9b84 100644
--- a/lldb/source/Commands/CommandObjectVariable.cpp
+++ b/lldb/source/Commands/CommandObjectVariable.cpp
@@ -23,6 +23,7 @@
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -386,12 +387,12 @@ public:
Scalar scalar;
- if (!Type::GetValueAsScalar (valobj->GetClangAST(),
- valobj->GetOpaqueClangQualType(),
- valobj->GetDataExtractor(),
- 0,
- valobj->GetByteSize(),
- scalar))
+ if (!ClangASTType::GetValueAsScalar (valobj->GetClangAST(),
+ valobj->GetOpaqueClangQualType(),
+ valobj->GetDataExtractor(),
+ 0,
+ valobj->GetByteSize(),
+ scalar))
return;
ConstString po_output;
diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp
index 32c27496b8f..2399059b730 100644
--- a/lldb/source/Core/Value.cpp
+++ b/lldb/source/Core/Value.cpp
@@ -17,6 +17,7 @@
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Stream.h"
+#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -472,7 +473,7 @@ Value::GetValueDefaultFormat ()
break;
case eContextTypeOpaqueClangQualType:
- return Type::GetFormat (m_context);
+ return ClangASTType::GetFormat (m_context);
case eContextTypeDCRegisterInfo:
if (GetRegisterInfo())
@@ -692,9 +693,9 @@ Value::ResolveValue(ExecutionContext *exe_ctx, clang::ASTContext *ast_context)
lldb::AddressType address_type = m_value_type == eValueTypeLoadAddress ? eAddressTypeLoad : eAddressTypeHost;
lldb::addr_t addr = m_value.ULongLong(LLDB_INVALID_ADDRESS);
DataExtractor data;
- if (Type::ReadFromMemory (exe_ctx, ast_context, opaque_clang_qual_type, addr, address_type, data))
+ if (ClangASTType::ReadFromMemory (ast_context, opaque_clang_qual_type, exe_ctx, addr, address_type, data))
{
- if (Type::GetValueAsScalar (ast_context, opaque_clang_qual_type, data, 0, data.GetByteSize(), scalar))
+ if (ClangASTType::GetValueAsScalar (ast_context, opaque_clang_qual_type, data, 0, data.GetByteSize(), scalar))
{
m_value = scalar;
m_value_type = eValueTypeScalar;
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 72984c6c082..065b18d0553 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -20,6 +20,7 @@
#include "lldb/Core/ValueObjectChild.h"
#include "lldb/Core/ValueObjectList.h"
+#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/Type.h"
@@ -488,16 +489,16 @@ ValueObject::GetValueAsCString (ExecutionContextScope *exe_scope)
if (clang_type)
{
StreamString sstr;
- lldb::Format format = Type::GetFormat(clang_type);
- if (Type::DumpTypeValue(&sstr,
- GetClangAST(), // The clang AST
- clang_type, // The clang type to display
- format, // Format to display this type with
- m_data, // Data to extract from
- 0, // Byte offset into "m_data"
- GetByteSize(), // Byte size of item in "m_data"
- GetBitfieldBitSize(), // Bitfield bit size
- GetBitfieldBitOffset())) // Bitfield bit offset
+ lldb::Format format = ClangASTType::GetFormat(clang_type);
+ if (ClangASTType::DumpTypeValue(GetClangAST(), // The clang AST
+ clang_type, // The clang type to display
+ &sstr,
+ format, // Format to display this type with
+ m_data, // Data to extract from
+ 0, // Byte offset into "m_data"
+ GetByteSize(), // Byte size of item in "m_data"
+ GetBitfieldBitSize(), // Bitfield bit size
+ GetBitfieldBitOffset())) // Bitfield bit offset
m_value_str.swap(sstr.GetString());
else
m_value_str.clear();
@@ -537,7 +538,7 @@ ValueObject::SetValueFromCString (ExecutionContextScope *exe_scope, const char *
return false;
uint32_t count = 0;
- lldb::Encoding encoding = Type::GetEncoding (GetOpaqueClangQualType(), count);
+ lldb::Encoding encoding = ClangASTType::GetEncoding (GetOpaqueClangQualType(), count);
char *end = NULL;
const size_t byte_size = GetByteSize();
diff --git a/lldb/source/Core/ValueObjectChild.cpp b/lldb/source/Core/ValueObjectChild.cpp
index 9b9b8d9e849..3093582998c 100644
--- a/lldb/source/Core/ValueObjectChild.cpp
+++ b/lldb/source/Core/ValueObjectChild.cpp
@@ -12,6 +12,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ValueObjectList.h"
+#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Type.h"
@@ -103,7 +104,7 @@ ValueObjectChild::GetTypeName()
{
if (m_type_name.IsEmpty())
{
- m_type_name = Type::GetClangTypeName (GetOpaqueClangQualType());
+ m_type_name = ClangASTType::GetClangTypeName (GetOpaqueClangQualType());
if (m_type_name)
{
if (m_bitfield_bit_size > 0)
diff --git a/lldb/source/Core/ValueObjectRegister.cpp b/lldb/source/Core/ValueObjectRegister.cpp
index aae818eadd6..5d5215fe83d 100644
--- a/lldb/source/Core/ValueObjectRegister.cpp
+++ b/lldb/source/Core/ValueObjectRegister.cpp
@@ -15,6 +15,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Module.h"
+#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Target/ExecutionContext.h"
@@ -250,7 +251,7 @@ ConstString
ValueObjectRegister::GetTypeName()
{
if (m_type_name.IsEmpty())
- m_type_name = Type::GetClangTypeName (GetOpaqueClangQualType());
+ m_type_name = ClangASTType::GetClangTypeName (GetOpaqueClangQualType());
return m_type_name;
}
diff --git a/lldb/source/Expression/ClangExpression.cpp b/lldb/source/Expression/ClangExpression.cpp
index e996749de9e..9468a706c0b 100644
--- a/lldb/source/Expression/ClangExpression.cpp
+++ b/lldb/source/Expression/ClangExpression.cpp
@@ -55,6 +55,7 @@
// Project includes
#include "lldb/Core/Log.h"
+#include "lldb/Core/ClangForward.h"
#include "lldb/Expression/ClangExpression.h"
#include "lldb/Expression/ClangASTSource.h"
#include "lldb/Expression/ClangResultSynthesizer.h"
@@ -74,23 +75,6 @@ using namespace lldb_private;
using namespace clang;
using namespace llvm;
-namespace clang {
-
-class AnalyzerOptions;
-class CodeGenOptions;
-class DependencyOutputOptions;
-class DiagnosticOptions;
-class FrontendOptions;
-class HeaderSearchOptions;
-class LangOptions;
-class PreprocessorOptions;
-class PreprocessorOutputOptions;
-class TargetInfo;
-class TargetOptions;
-
-} // end namespace clang
-
-
//===----------------------------------------------------------------------===//
// Utility Methods
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index 5a6b6740750..54bfad5772a 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -292,10 +292,11 @@ ClangExpressionDeclMap::DoMaterialize (bool dematerialize,
TypeFromUser copied_type(ClangASTContext::CopyType(context,
iter->m_parser_type.GetASTContext(),
- iter->m_parser_type.GetType()),
+ iter->m_parser_type.GetOpaqueQualType()),
context);
- result_value->SetContext(Value::eContextTypeOpaqueClangQualType, copied_type.GetType());
+ result_value->SetContext(Value::eContextTypeOpaqueClangQualType,
+ copied_type.GetOpaqueQualType());
}
continue;
@@ -329,7 +330,10 @@ ClangExpressionDeclMap::DoMaterializeOneVariable(bool dematerialize,
return false;
}
- log->Printf("%s %s with type %p", (dematerialize ? "Dematerializing" : "Materializing"), name, type.GetType());
+ log->Printf("%s %s with type %p",
+ (dematerialize ? "Dematerializing" : "Materializing"),
+ name,
+ type.GetOpaqueQualType());
std::auto_ptr<lldb_private::Value> location_value(GetVariableValue(exe_ctx,
var,
@@ -345,7 +349,8 @@ ClangExpressionDeclMap::DoMaterializeOneVariable(bool dematerialize,
{
lldb::addr_t value_addr = location_value->GetScalar().ULongLong();
- size_t bit_size = ClangASTContext::GetTypeBitSize(type.GetASTContext(), type.GetType());
+ size_t bit_size = ClangASTContext::GetTypeBitSize (type.GetASTContext(),
+ type.GetOpaqueQualType());
size_t byte_size = bit_size % 8 ? ((bit_size + 8) / 8) : (bit_size / 8);
DataBufferHeap data;
@@ -488,7 +493,9 @@ ClangExpressionDeclMap::FindVariableInScope(const SymbolContext &sym_ctx,
if (type->GetASTContext() == var->GetType()->GetClangAST())
{
- if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetType(), var->GetType()->GetOpaqueClangQualType()))
+ if (!ClangASTContext::AreTypesSame(type->GetASTContext(),
+ type->GetOpaqueQualType(),
+ var->GetType()->GetOpaqueClangQualType()))
return NULL;
}
else
@@ -657,7 +664,7 @@ ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
&ut,
&pt);
- NamedDecl *var_decl = context.AddVarDecl(pt.GetType());
+ NamedDecl *var_decl = context.AddVarDecl(pt.GetOpaqueQualType());
Tuple tuple;
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 839cf2ef592..20c97b28e07 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -24,6 +24,7 @@
#include "lldb/lldb-private-log.h"
+#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/Type.h"
@@ -2273,10 +2274,10 @@ DWARFExpression::Evaluate
}
else
{
- if (!Type::SetValueFromScalar(ast_context,
- clang_type,
- tmp.ResolveValue(exe_ctx, ast_context),
- new_value))
+ if (!ClangASTType::SetValueFromScalar (ast_context,
+ clang_type,
+ tmp.ResolveValue(exe_ctx, ast_context),
+ new_value))
{
if (error_ptr)
error_ptr->SetErrorStringWithFormat ("Couldn't extract a value from an integral type.\n");
@@ -2292,12 +2293,12 @@ DWARFExpression::Evaluate
{
lldb::AddressType address_type = (value_type == Value::eValueTypeLoadAddress ? eAddressTypeLoad : eAddressTypeHost);
lldb::addr_t addr = stack.back().GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
- if (!Type::WriteToMemory (exe_ctx,
- ast_context,
- clang_type,
- addr,
- address_type,
- new_value))
+ if (!ClangASTType::WriteToMemory (ast_context,
+ clang_type,
+ exe_ctx,
+ addr,
+ address_type,
+ new_value))
{
if (error_ptr)
error_ptr->SetErrorStringWithFormat ("Failed to write value to memory at 0x%llx.\n", addr);
diff --git a/lldb/source/Host/macosx/Symbols.cpp b/lldb/source/Host/macosx/Symbols.cpp
index ccdde69bcbf..3502ff5d2b0 100644
--- a/lldb/source/Host/macosx/Symbols.cpp
+++ b/lldb/source/Host/macosx/Symbols.cpp
@@ -11,8 +11,7 @@
// C Includes
#include <dirent.h>
-#include <mach-o/loader.h>
-#include <mach-o/fat.h>
+#include "llvm/Support/MachO.h"
// C++ Includes
// Other libraries and framework includes
@@ -29,6 +28,7 @@
using namespace lldb;
using namespace lldb_private;
+using namespace llvm::MachO;
extern "C" {
@@ -49,8 +49,8 @@ SkinnyMachOFileContainsArchAndUUID
const uint32_t magic
)
{
- assert(magic == MH_CIGAM || magic == MH_MAGIC || magic == MH_CIGAM_64 || magic == MH_MAGIC_64);
- if (magic == MH_MAGIC || magic == MH_MAGIC_64)
+ assert(magic == HeaderMagic32 || magic == HeaderMagic32Swapped || magic == HeaderMagic64 || magic == HeaderMagic64Swapped);
+ if (magic == HeaderMagic32 || magic == HeaderMagic64)
data.SetByteOrder (eByteOrderHost);
else if (eByteOrderHost == eByteOrderBig)
data.SetByteOrder (eByteOrderLittle);
@@ -80,11 +80,11 @@ SkinnyMachOFileContainsArchAndUUID
if (uuid == NULL)
return true;
- if (magic == MH_CIGAM_64 || magic == MH_MAGIC_64)
+ if (magic == HeaderMagic64Swapped || magic == HeaderMagic64)
data_offset += 4; // Skip reserved field for in mach_header_64
// Make sure we have enough data for all the load commands
- if (magic == MH_CIGAM_64 || magic == MH_MAGIC_64)
+ if (magic == HeaderMagic64Swapped || magic == HeaderMagic64)
{
if (data.GetByteSize() < sizeof(struct mach_header_64) + sizeofcmds)
{
@@ -106,7 +106,7 @@ SkinnyMachOFileContainsArchAndUUID
const uint32_t cmd_offset = data_offset; // Save this data_offset in case parsing of the segment goes awry!
uint32_t cmd = data.GetU32(&data_offset);
uint32_t cmd_size = data.GetU32(&data_offset);
- if (cmd == LC_UUID)
+ if (cmd == LoadCommandUUID)
{
UUID file_uuid (data.GetData(&data_offset, 16), 16);
return file_uuid == *uuid;
@@ -128,7 +128,7 @@ UniversalMachOFileContainsArchAndUUID
const uint32_t magic
)
{
- assert(magic == FAT_CIGAM || magic == FAT_MAGIC);
+ assert(magic == UniversalMagic || magic == UniversalMagicSwapped);
// Universal mach-o files always have their headers encoded as BIG endian
data.SetByteOrder(eByteOrderBig);
@@ -167,10 +167,10 @@ UniversalMachOFileContainsArchAndUUID
switch (arch_magic)
{
- case MH_CIGAM: // 32 bit mach-o file
- case MH_MAGIC: // 32 bit mach-o file
- case MH_CIGAM_64: // 64 bit mach-o file
- case MH_MAGIC_64: // 64 bit mach-o file
+ case HeaderMagic32:
+ case HeaderMagic32Swapped:
+ case HeaderMagic64:
+ case HeaderMagic64Swapped:
if (SkinnyMachOFileContainsArchAndUUID (file_spec, arch, uuid, file_offset + arch_offset, arch_data, arch_data_offset, arch_magic))
return true;
break;
@@ -201,15 +201,15 @@ FileAtPathContainsArchAndUUID
switch (magic)
{
// 32 bit mach-o file
- case MH_CIGAM:
- case MH_MAGIC:
- case MH_CIGAM_64:
- case MH_MAGIC_64:
+ case HeaderMagic32:
+ case HeaderMagic32Swapped:
+ case HeaderMagic64:
+ case HeaderMagic64Swapped:
return SkinnyMachOFileContainsArchAndUUID (file_spec, arch, uuid, file_offset, data, data_offset, magic);
// fat mach-o file
- case FAT_CIGAM:
- case FAT_MAGIC:
+ case UniversalMagic:
+ case UniversalMagicSwapped:
return UniversalMachOFileContainsArchAndUUID (file_spec, arch, uuid, file_offset, data, data_offset, magic);
default:
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index a8489dae8fb..fea069e5fc3 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -34,7 +34,7 @@
using namespace lldb;
using namespace lldb_private;
-
+using namespace llvm::MachO;
/// FIXME - The ObjC Runtime trampoline handler doesn't really belong here.
/// I am putting it here so I can invoke it in the Trampoline code here, but
@@ -191,7 +191,7 @@ DynamicLoaderMacOSXDYLD::ReadDYLDInfoFromMemoryAndSetNotificationCallback(lldb::
DataExtractor data; // Load command data
if (ReadMachHeader (addr, &m_dyld.header, &data))
{
- if (m_dyld.header.filetype == MH_DYLINKER)
+ if (m_dyld.header.filetype == HeaderFileTypeDynamicLinkEditor)
{
m_dyld.address = addr;
ModuleSP dyld_module_sp;
@@ -670,15 +670,15 @@ DynamicLoaderMacOSXDYLD::UpdateAllImageInfos()
// Returns true if we succeed, false if we fail for any reason.
//----------------------------------------------------------------------
bool
-DynamicLoaderMacOSXDYLD::ReadMachHeader (lldb::addr_t addr, struct mach_header *header, DataExtractor *load_command_data)
+DynamicLoaderMacOSXDYLD::ReadMachHeader (lldb::addr_t addr, mach_header *header, DataExtractor *load_command_data)
{
- DataBufferHeap header_bytes(sizeof(struct mach_header), 0);
+ DataBufferHeap header_bytes(sizeof(mach_header), 0);
Error error;
size_t bytes_read = m_process->ReadMemory (addr,
header_bytes.GetBytes(),
header_bytes.GetByteSize(),
error);
- if (bytes_read == sizeof(struct mach_header))
+ if (bytes_read == sizeof(mach_header))
{
uint32_t offset = 0;
::memset (header, 0, sizeof(header));
@@ -690,16 +690,16 @@ DynamicLoaderMacOSXDYLD::ReadMachHeader (lldb::addr_t addr, struct mach_header *
data.SetByteOrder(DynamicLoaderMacOSXDYLD::GetByteOrderFromMagic(header->magic));
switch (header->magic)
{
- case MH_MAGIC:
- case MH_CIGAM:
+ case llvm::MachO::HeaderMagic32:
+ case llvm::MachO::HeaderMagic32Swapped:
data.SetAddressByteSize(4);
- load_cmd_addr += sizeof(struct mach_header);
+ load_cmd_addr += sizeof(mach_header);
break;
- case MH_MAGIC_64:
- case MH_CIGAM_64:
+ case llvm::MachO::HeaderMagic64:
+ case llvm::MachO::HeaderMagic64Swapped:
data.SetAddressByteSize(8);
- load_cmd_addr += sizeof(struct mach_header_64);
+ load_cmd_addr += sizeof(mach_header_64);
break;
default:
@@ -707,7 +707,7 @@ DynamicLoaderMacOSXDYLD::ReadMachHeader (lldb::addr_t addr, struct mach_header *
}
// Read the rest of dyld's mach header
- if (data.GetU32(&offset, &header->cputype, (sizeof(struct mach_header)/sizeof(uint32_t)) - 1))
+ if (data.GetU32(&offset, &header->cputype, (sizeof(mach_header)/sizeof(uint32_t)) - 1))
{
if (load_command_data == NULL)
return true; // We were able to read the mach_header and weren't asked to read the load command bytes
@@ -752,15 +752,15 @@ DynamicLoaderMacOSXDYLD::ParseLoadCommands (const DataExtractor& data, struct DY
// Clear out any load command specific data from DYLIB_INFO since
// we are about to read it.
- if (data.ValidOffsetForDataOfSize (offset, sizeof(struct load_command)))
+ if (data.ValidOffsetForDataOfSize (offset, sizeof(load_command)))
{
- struct load_command load_cmd;
+ load_command load_cmd;
uint32_t load_cmd_offset = offset;
load_cmd.cmd = data.GetU32 (&offset);
load_cmd.cmdsize = data.GetU32 (&offset);
switch (load_cmd.cmd)
{
- case LC_SEGMENT:
+ case LoadCommandSegment32:
{
segment.name.SetTrimmedCStringWithLength ((const char *)data.GetData(&offset, 16), 16);
segment.addr = data.GetU32 (&offset);
@@ -769,7 +769,7 @@ DynamicLoaderMacOSXDYLD::ParseLoadCommands (const DataExtractor& data, struct DY
}
break;
- case LC_SEGMENT_64:
+ case LoadCommandSegment64:
{
segment.name.SetTrimmedCStringWithLength ((const char *)data.GetData(&offset, 16), 16);
segment.addr = data.GetU64 (&offset);
@@ -778,7 +778,7 @@ DynamicLoaderMacOSXDYLD::ParseLoadCommands (const DataExtractor& data, struct DY
}
break;
- case LC_ID_DYLINKER:
+ case LoadCommandDynamicLinkerIdent:
if (lc_id_dylinker)
{
uint32_t name_offset = load_cmd_offset + data.GetU32 (&offset);
@@ -787,7 +787,7 @@ DynamicLoaderMacOSXDYLD::ParseLoadCommands (const DataExtractor& data, struct DY
}
break;
- case LC_UUID:
+ case LoadCommandUUID:
dylib_info.uuid.SetBytes(data.GetData (&offset, 16));
break;
@@ -820,7 +820,7 @@ DynamicLoaderMacOSXDYLD::UpdateAllImageInfosHeaderAndLoadCommands()
ParseLoadCommands (data, m_dyld_image_infos[i], NULL);
- if (m_dyld_image_infos[i].header.filetype == MH_EXECUTE)
+ if (m_dyld_image_infos[i].header.filetype == HeaderFileTypeExecutable)
exe_idx = i;
}
}
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
index 724a8b6bd6d..44fb329e35e 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
@@ -11,19 +11,20 @@
#define liblldb_DynamicLoaderMacOSXDYLD_h_
// C Includes
-#include <mach-o/loader.h>
-
// C++ Includes
#include <map>
#include <vector>
#include <string>
// Other libraries and framework includes
+#include "llvm/Support/MachO.h"
+
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Core/FileSpec.h"
#include "lldb/Core/UUID.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Target/Process.h"
+
#include "ObjCTrampolineHandler.h"
class DynamicLoaderMacOSXDYLD : public lldb_private::DynamicLoader
@@ -144,12 +145,12 @@ protected:
{
switch (m_dyld.header.magic)
{
- case MH_MAGIC:
- case MH_CIGAM:
+ case llvm::MachO::HeaderMagic32:
+ case llvm::MachO::HeaderMagic32Swapped:
return 4;
- case MH_MAGIC_64:
- case MH_CIGAM_64:
+ case llvm::MachO::HeaderMagic64:
+ case llvm::MachO::HeaderMagic64Swapped:
return 8;
default:
@@ -163,12 +164,12 @@ protected:
{
switch (magic)
{
- case MH_MAGIC:
- case MH_MAGIC_64:
+ case llvm::MachO::HeaderMagic32:
+ case llvm::MachO::HeaderMagic64:
return lldb::eByteOrderHost;
- case MH_CIGAM:
- case MH_CIGAM_64:
+ case llvm::MachO::HeaderMagic32Swapped:
+ case llvm::MachO::HeaderMagic64Swapped:
if (lldb::eByteOrderHost == lldb::eByteOrderBig)
return lldb::eByteOrderLittle;
else
@@ -182,7 +183,7 @@ protected:
bool
ReadMachHeader (lldb::addr_t addr,
- struct mach_header *header,
+ llvm::MachO::mach_header *header,
lldb_private::DataExtractor *load_command_data);
class Segment
{
@@ -218,7 +219,7 @@ protected:
lldb::addr_t mod_date; // Modification date for this dylib
lldb_private::FileSpec file_spec; // Resolved path for this dylib
lldb_private::UUID uuid; // UUID for this dylib if it has one, else all zeros
- struct mach_header header; // The mach header for this image
+ llvm::MachO::mach_header header; // The mach header for this image
std::vector<Segment> segments; // All segment vmaddr and vmsize pairs for this executable (from memory of inferior)
DYLDImageInfo() :
diff --git a/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp b/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
index 015e498a7cc..f9bf3eb8cb1 100644
--- a/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
+++ b/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
@@ -16,7 +16,7 @@
using namespace lldb;
using namespace lldb_private;
-
+using namespace llvm::MachO;
void
ObjectContainerUniversalMachO::Initialize()
@@ -75,7 +75,7 @@ ObjectContainerUniversalMachO::MagicBytesMatch (DataBufferSP& dataSP)
DataExtractor data(dataSP, eByteOrderHost, 4);
uint32_t offset = 0;
uint32_t magic = data.GetU32(&offset);
- return magic == FAT_MAGIC || magic == FAT_CIGAM;
+ return magic == UniversalMagic || magic == UniversalMagicSwapped;
}
ObjectContainerUniversalMachO::ObjectContainerUniversalMachO
@@ -108,20 +108,20 @@ ObjectContainerUniversalMachO::ParseHeader ()
m_data.SetByteOrder (eByteOrderBig);
m_header.magic = m_data.GetU32(&offset);
- if (m_header.magic == FAT_MAGIC)
+ if (m_header.magic == UniversalMagic)
{
m_data.SetAddressByteSize(4);
m_header.nfat_arch = m_data.GetU32(&offset);
- const size_t nfat_arch_size = sizeof(fat_arch_t) * m_header.nfat_arch;
+ const size_t nfat_arch_size = sizeof(fat_arch) * m_header.nfat_arch;
// See if the current data we have is enough for all of the fat headers?
if (!m_data.ValidOffsetForDataOfSize(offset, nfat_arch_size))
{
// The fat headers are larger than the number of bytes we have been
// given when this class was constructed. We will read the exact number
// of bytes that we need.
- DataBufferSP data_sp(m_file.ReadFileContents(m_offset, nfat_arch_size + sizeof(fat_header_t)));
+ DataBufferSP data_sp(m_file.ReadFileContents(m_offset, nfat_arch_size + sizeof(fat_header)));
m_data.SetData (data_sp);
}
@@ -130,10 +130,10 @@ ObjectContainerUniversalMachO::ParseHeader ()
uint32_t arch_idx = 0;
for (arch_idx = 0; arch_idx < m_header.nfat_arch; ++arch_idx)
{
- if (m_data.ValidOffsetForDataOfSize(offset, sizeof(fat_arch_t)))
+ if (m_data.ValidOffsetForDataOfSize(offset, sizeof(fat_arch)))
{
- fat_arch_t arch;
- if (m_data.GetU32(&offset, &arch, sizeof(fat_arch_t)/sizeof(uint32_t)))
+ fat_arch arch;
+ if (m_data.GetU32(&offset, &arch, sizeof(fat_arch)/sizeof(uint32_t)))
{
m_fat_archs.push_back(arch);
}
diff --git a/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h b/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h
index 8a7f975bc67..55a88278d8a 100644
--- a/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h
+++ b/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h
@@ -10,11 +10,11 @@
#ifndef liblldb_ObjectContainerUniversalMachO_h_
#define liblldb_ObjectContainerUniversalMachO_h_
-#include <mach-o/fat.h>
-
#include "lldb/Symbol/ObjectContainer.h"
#include "lldb/Core/FileSpec.h"
+#include "llvm/Support/MachO.h"
+
class ObjectContainerUniversalMachO :
public lldb_private::ObjectContainer
{
@@ -94,10 +94,8 @@ public:
protected:
- typedef struct fat_header fat_header_t;
- typedef struct fat_arch fat_arch_t;
- fat_header_t m_header;
- std::vector<fat_arch_t> m_fat_archs;
+ llvm::MachO::fat_header m_header;
+ std::vector<llvm::MachO::fat_arch> m_fat_archs;
};
#endif // liblldb_ObjectContainerUniversalMachO_h_
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index e4810a219a4..de5c73c84b4 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -9,9 +9,6 @@
#include "ObjectFileMachO.h"
-#include <mach-o/nlist.h>
-#include <mach-o/stab.h>
-
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/FileSpec.h"
@@ -25,18 +22,10 @@
#include "lldb/Core/UUID.h"
#include "lldb/Symbol/ObjectFile.h"
-#ifndef S_DTRACE_DOF
-// section contains DTrace Object Format
-#define S_DTRACE_DOF 0xf
-#endif
-
-#ifndef S_LAZY_DYLIB_SYMBOL_POINTERS
-// section with only lazy symbol pointers to lazy loaded dylibs
-#define S_LAZY_DYLIB_SYMBOL_POINTERS 0x10
-#endif
using namespace lldb;
using namespace lldb_private;
+using namespace llvm::MachO;
void
@@ -85,12 +74,12 @@ MachHeaderSizeFromMagic(uint32_t magic)
{
switch (magic)
{
- case MH_MAGIC:
- case MH_CIGAM:
+ case HeaderMagic32:
+ case HeaderMagic32Swapped:
return sizeof(struct mach_header);
- case MH_MAGIC_64:
- case MH_CIGAM_64:
+ case HeaderMagic64:
+ case HeaderMagic64Swapped:
return sizeof(struct mach_header_64);
break;
@@ -139,25 +128,25 @@ ObjectFileMachO::ParseHeader ()
m_header.magic = m_data.GetU32(&offset);
switch (m_header.magic)
{
- case MH_MAGIC:
+ case HeaderMagic32:
m_data.SetByteOrder (eByteOrderHost);
m_data.SetAddressByteSize(4);
can_parse = true;
break;
- case MH_MAGIC_64:
+ case HeaderMagic64:
m_data.SetByteOrder (eByteOrderHost);
m_data.SetAddressByteSize(8);
can_parse = true;
break;
- case MH_CIGAM:
+ case HeaderMagic32Swapped:
m_data.SetByteOrder(eByteOrderHost == eByteOrderBig ? eByteOrderLittle : eByteOrderBig);
m_data.SetAddressByteSize(4);
can_parse = true;
break;
- case MH_CIGAM_64:
+ case HeaderMagic64Swapped:
m_data.SetByteOrder(eByteOrderHost == eByteOrderBig ? eByteOrderLittle : eByteOrderBig);
m_data.SetAddressByteSize(8);
can_parse = true;
@@ -245,7 +234,7 @@ ObjectFileMachO::ParseSections ()
if (m_data.GetU32(&offset, &load_cmd, 2) == NULL)
break;
- if (load_cmd.cmd == LC_SEGMENT || load_cmd.cmd == LC_SEGMENT_64)
+ if (load_cmd.cmd == LoadCommandSegment32 || load_cmd.cmd == LoadCommandSegment64)
{
if (m_data.GetU8(&offset, (uint8_t*)load_cmd.segname, 16))
{
@@ -282,13 +271,13 @@ ObjectFileMachO::ParseSections ()
struct section_64 sect64;
::bzero (&sect64, sizeof(sect64));
// Push a section into our mach sections for the section at
- // index zero (NO_SECT)
+ // index zero (NListSectionNoSection)
m_mach_sections.push_back(sect64);
uint32_t segment_sect_idx;
const lldb::user_id_t first_segment_sectID = sectID + 1;
- const uint32_t num_u32s = load_cmd.cmd == LC_SEGMENT ? 7 : 8;
+ const uint32_t num_u32s = load_cmd.cmd == LoadCommandSegment32 ? 7 : 8;
for (segment_sect_idx=0; segment_sect_idx<load_cmd.nsects; ++segment_sect_idx)
{
if (m_data.GetU8(&offset, (uint8_t*)sect64.sectname, sizeof(sect64.sectname)) == NULL)
@@ -375,7 +364,7 @@ ObjectFileMachO::ParseSections ()
}
assert (segment_sp.get());
- uint32_t mach_sect_type = sect64.flags & SECTION_TYPE;
+ uint32_t mach_sect_type = sect64.flags & SectionFlagMaskSectionType;
static ConstString g_sect_name_objc_data ("__objc_data");
static ConstString g_sect_name_objc_msgrefs ("__objc_msgrefs");
static ConstString g_sect_name_objc_selrefs ("__objc_selrefs");
@@ -412,26 +401,23 @@ ObjectFileMachO::ParseSections ()
switch (mach_sect_type)
{
// TODO: categorize sections by other flags for regular sections
- case S_REGULAR:
-
- sect_type = eSectionTypeOther;
- break;
- case S_ZEROFILL: sect_type = eSectionTypeZeroFill; break;
- case S_CSTRING_LITERALS: sect_type = eSectionTypeDataCString; break; // section with only literal C strings
- case S_4BYTE_LITERALS: sect_type = eSectionTypeData4; break; // section with only 4 byte literals
- case S_8BYTE_LITERALS: sect_type = eSectionTypeData8; break; // section with only 8 byte literals
- case S_LITERAL_POINTERS: sect_type = eSectionTypeDataPointers; break; // section with only pointers to literals
- case S_NON_LAZY_SYMBOL_POINTERS: sect_type = eSectionTypeDataPointers; break; // section with only non-lazy symbol pointers
- case S_LAZY_SYMBOL_POINTERS: sect_type = eSectionTypeDataPointers; break; // section with only lazy symbol pointers
- case S_SYMBOL_STUBS: sect_type = eSectionTypeCode; break; // section with only symbol stubs, byte size of stub in the reserved2 field
- case S_MOD_INIT_FUNC_POINTERS: sect_type = eSectionTypeDataPointers; break; // section with only function pointers for initialization
- case S_MOD_TERM_FUNC_POINTERS: sect_type = eSectionTypeDataPointers; break; // section with only function pointers for termination
- case S_COALESCED: sect_type = eSectionTypeOther; break;
- case S_GB_ZEROFILL: sect_type = eSectionTypeZeroFill; break;
- case S_INTERPOSING: sect_type = eSectionTypeCode; break; // section with only pairs of function pointers for interposing
- case S_16BYTE_LITERALS: sect_type = eSectionTypeData16; break; // section with only 16 byte literals
- case S_DTRACE_DOF: sect_type = eSectionTypeDebug; break;
- case S_LAZY_DYLIB_SYMBOL_POINTERS: sect_type = eSectionTypeDataPointers; break;
+ case SectionTypeRegular: sect_type = eSectionTypeOther; break;
+ case SectionTypeZeroFill: sect_type = eSectionTypeZeroFill; break;
+ case SectionTypeCStringLiterals: sect_type = eSectionTypeDataCString; break; // section with only literal C strings
+ case SectionType4ByteLiterals: sect_type = eSectionTypeData4; break; // section with only 4 byte literals
+ case SectionType8ByteLiterals: sect_type = eSectionTypeData8; break; // section with only 8 byte literals
+ case SectionTypeLiteralPointers: sect_type = eSectionTypeDataPointers; break; // section with only pointers to literals
+ case SectionTypeNonLazySymbolPointers: sect_type = eSectionTypeDataPointers; break; // section with only non-lazy symbol pointers
+ case SectionTypeLazySymbolPointers: sect_type = eSectionTypeDataPointers; break; // section with only lazy symbol pointers
+ case SectionTypeSymbolStubs: sect_type = eSectionTypeCode; break; // section with only symbol stubs, byte size of stub in the reserved2 field
+ case SectionTypeModuleInitFunctionPointers: sect_type = eSectionTypeDataPointers; break; // section with only function pointers for initialization
+ case SectionTypeModuleTermFunctionPointers: sect_type = eSectionTypeDataPointers; break; // section with only function pointers for termination
+ case SectionTypeCoalesced: sect_type = eSectionTypeOther; break;
+ case SectionTypeZeroFillLarge: sect_type = eSectionTypeZeroFill; break;
+ case SectionTypeInterposing: sect_type = eSectionTypeCode; break; // section with only pairs of function pointers for interposing
+ case SectionType16ByteLiterals: sect_type = eSectionTypeData16; break; // section with only 16 byte literals
+ case SectionTypeDTraceObjectFormat: sect_type = eSectionTypeDebug; break;
+ case SectionTypeLazyDylibSymbolPointers: sect_type = eSectionTypeDataPointers; break;
default: break;
}
}
@@ -454,7 +440,7 @@ ObjectFileMachO::ParseSections ()
segment_name.Clear();
}
}
- if (m_header.filetype == MH_DSYM)
+ if (m_header.filetype == HeaderFileTypeDSYM)
{
if (first_segment_sectID <= sectID)
{
@@ -482,7 +468,7 @@ ObjectFileMachO::ParseSections ()
}
}
}
- else if (load_cmd.cmd == LC_DYSYMTAB)
+ else if (load_cmd.cmd == LoadCommandDynamicSymtabInfo)
{
m_dysymtab.cmd = load_cmd.cmd;
m_dysymtab.cmdsize = load_cmd.cmdsize;
@@ -569,7 +555,7 @@ ObjectFileMachO::ParseSymtab (bool minimize)
if (m_data.GetU32(&offset, &symtab_load_command, 2) == NULL)
break;
// Watch for the symbol table load command
- if (symtab_load_command.cmd == LC_SYMTAB)
+ if (symtab_load_command.cmd == LoadCommandSymtab)
{
// Read in the rest of the symtab load command
if (m_data.GetU32(&offset, &symtab_load_command.symoff, 4)) // fill in symoff, nsyms, stroff, strsize fields
@@ -602,7 +588,7 @@ ObjectFileMachO::ParseSymtab (bool minimize)
else
eh_frame_section_sp = section_list->FindSectionByName (g_section_name_eh_frame);
- uint8_t TEXT_eh_frame_sectID = eh_frame_section_sp.get() ? eh_frame_section_sp->GetID() : NO_SECT;
+ uint8_t TEXT_eh_frame_sectID = eh_frame_section_sp.get() ? eh_frame_section_sp->GetID() : NListSectionNoSection;
//uint32_t symtab_offset = 0;
const uint8_t* nlist_data = symtab_data_sp->GetBytes();
assert (symtab_data_sp->GetByteSize()/nlist_size >= symtab_load_command.nsyms);
@@ -635,7 +621,7 @@ ObjectFileMachO::ParseSymtab (bool minimize)
if (bit_width_32)
{
struct nlist* nlist32_ptr = (struct nlist*)(nlist_data + (nlist_idx * nlist_size));
- nlist.n_un.n_strx = nlist32_ptr->n_un.n_strx;
+ nlist.n_strx = nlist32_ptr->n_strx;
nlist.n_type = nlist32_ptr->n_type;
nlist.n_sect = nlist32_ptr->n_sect;
nlist.n_desc = nlist32_ptr->n_desc;
@@ -647,12 +633,12 @@ ObjectFileMachO::ParseSymtab (bool minimize)
}
SymbolType type = eSymbolTypeInvalid;
- const char* symbol_name = &strtab_data[nlist.n_un.n_strx];
+ const char* symbol_name = &strtab_data[nlist.n_strx];
if (symbol_name[0] == '\0')
symbol_name = NULL;
Section* symbol_section = NULL;
bool add_nlist = true;
- bool is_debug = ((nlist.n_type & N_STAB) != 0);
+ bool is_debug = ((nlist.n_type & NlistMaskStab) != 0);
assert (sym_idx < num_syms);
@@ -662,18 +648,21 @@ ObjectFileMachO::ParseSymtab (bool minimize)
{
switch (nlist.n_type)
{
- case N_GSYM: // global symbol: name,,NO_SECT,type,0
+ case StabGlobalSymbol:
+ // N_GSYM -- global symbol: name,,NO_SECT,type,0
// Sometimes the N_GSYM value contains the address.
if (nlist.n_value != 0)
symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value);
type = eSymbolTypeGlobal;
break;
- case N_FNAME: // procedure name (f77 kludge): name,,NO_SECT,0,0
+ case StabFunctionName:
+ // N_FNAME -- procedure name (f77 kludge): name,,NO_SECT,0,0
type = eSymbolTypeFunction;
break;
- case N_FUN: // procedure: name,,n_sect,linenumber,address
+ case StabFunction:
+ // N_FUN -- procedure: name,,n_sect,linenumber,address
if (symbol_name)
{
type = eSymbolTypeFunction;
@@ -701,17 +690,20 @@ ObjectFileMachO::ParseSymtab (bool minimize)
}
break;
- case N_STSYM: // static symbol: name,,n_sect,type,address
+ case StabStaticSymbol:
+ // N_STSYM -- static symbol: name,,n_sect,type,address
symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value);
type = eSymbolTypeStatic;
break;
- case N_LCSYM: // .lcomm symbol: name,,n_sect,type,address
+ case StabLocalCommon:
+ // N_LCSYM -- .lcomm symbol: name,,n_sect,type,address
symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value);
type = eSymbolTypeCommonBlock;
break;
- case N_BNSYM:
+ case StabBeginSymbol:
+ // N_BNSYM
// We use the current number of symbols in the symbol table in lieu of
// using nlist_idx in case we ever start trimming entries out
if (minimize)
@@ -727,7 +719,8 @@ ObjectFileMachO::ParseSymtab (bool minimize)
}
break;
- case N_ENSYM:
+ case StabEndSymbol:
+ // N_ENSYM
// Set the size of the N_BNSYM to the terminating index of this N_ENSYM
// so that we can always skip the entire symbol if we need to navigate
// more quickly at the source level when parsing STABS
@@ -750,24 +743,29 @@ ObjectFileMachO::ParseSymtab (bool minimize)
break;
- case N_OPT: // emitted with gcc2_compiled and in gcc source
+ case StabSourceFileOptions:
+ // N_OPT - emitted with gcc2_compiled and in gcc source
type = eSymbolTypeCompiler;
break;
- case N_RSYM: // register sym: name,,NO_SECT,type,register
+ case StabRegisterSymbol:
+ // N_RSYM - register sym: name,,NO_SECT,type,register
type = eSymbolTypeVariable;
break;
- case N_SLINE: // src line: 0,,n_sect,linenumber,address
+ case StabSourceLine:
+ // N_SLINE - src line: 0,,n_sect,linenumber,address
symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value);
type = eSymbolTypeLineEntry;
break;
- case N_SSYM: // structure elt: name,,NO_SECT,type,struct_offset
+ case StabStructureType:
+ // N_SSYM - structure elt: name,,NO_SECT,type,struct_offset
type = eSymbolTypeVariableType;
break;
- case N_SO:
+ case StabSourceFileName:
+ // N_SO - source file name
type = eSymbolTypeSourceFile;
if (symbol_name == NULL)
{
@@ -802,25 +800,29 @@ ObjectFileMachO::ParseSymtab (bool minimize)
}
break;
- case N_OSO: // object file name: name,,0,0,st_mtime
+ case StabObjectFileName:
+ // N_OSO - object file name: name,,0,0,st_mtime
type = eSymbolTypeObjectFile;
break;
- case N_LSYM: // local sym: name,,NO_SECT,type,offset
+ case StabLocalSymbol:
+ // N_LSYM - local sym: name,,NO_SECT,type,offset
type = eSymbolTypeLocal;
break;
//----------------------------------------------------------------------
// INCL scopes
//----------------------------------------------------------------------
- case N_BINCL: // include file beginning: name,,NO_SECT,0,sum
+ case StabBeginIncludeFileName:
+ // N_BINCL - include file beginning: name,,NO_SECT,0,sum
// We use the current number of symbols in the symbol table in lieu of
// using nlist_idx in case we ever start trimming entries out
N_INCL_indexes.push_back(sym_idx);
type = eSymbolTypeScopeBegin;
break;
- case N_EINCL: // include file end: name,,NO_SECT,0,0
+ case StabEndIncludeFile:
+ // N_EINCL - include file end: name,,NO_SECT,0,0
// Set the size of the N_BINCL to the terminating index of this N_EINCL
// so that we can always skip the entire symbol if we need to navigate
// more quickly at the source level when parsing STABS
@@ -834,27 +836,33 @@ ObjectFileMachO::ParseSymtab (bool minimize)
type = eSymbolTypeScopeEnd;
break;
- case N_SOL: // #included file name: name,,n_sect,0,address
+ case StabIncludeFileName:
+ // N_SOL - #included file name: name,,n_sect,0,address
type = eSymbolTypeHeaderFile;
break;
- case N_PARAMS: // compiler parameters: name,,NO_SECT,0,0
+ case StabCompilerParameters:
+ // N_PARAMS - compiler parameters: name,,NO_SECT,0,0
type = eSymbolTypeCompiler;
break;
- case N_VERSION: // compiler version: name,,NO_SECT,0,0
+ case StabCompilerVersion:
+ // N_VERSION - compiler version: name,,NO_SECT,0,0
type = eSymbolTypeCompiler;
break;
- case N_OLEVEL: // compiler -O level: name,,NO_SECT,0,0
+ case StabCompilerOptLevel:
+ // N_OLEVEL - compiler -O level: name,,NO_SECT,0,0
type = eSymbolTypeCompiler;
break;
- case N_PSYM: // parameter: name,,NO_SECT,type,offset
+ case StabParameter:
+ // N_PSYM - parameter: name,,NO_SECT,type,offset
type = eSymbolTypeVariable;
break;
- case N_ENTRY: // alternate entry: name,,n_sect,linenumber,address
+ case StabAlternateEntry:
+ // N_ENTRY - alternate entry: name,,n_sect,linenumber,address
symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value);
type = eSymbolTypeLineEntry;
break;
@@ -862,7 +870,8 @@ ObjectFileMachO::ParseSymtab (bool minimize)
//----------------------------------------------------------------------
// Left and Right Braces
//----------------------------------------------------------------------
- case N_LBRAC: // left bracket: 0,,NO_SECT,nesting level,address
+ case StabLeftBracket:
+ // N_LBRAC - left bracket: 0,,NO_SECT,nesting level,address
// We use the current number of symbols in the symbol table in lieu of
// using nlist_idx in case we ever start trimming entries out
symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value);
@@ -870,7 +879,8 @@ ObjectFileMachO::ParseSymtab (bool minimize)
type = eSymbolTypeScopeBegin;
break;
- case N_RBRAC: // right bracket: 0,,NO_SECT,nesting level,address
+ case StabRightBracket:
+ // N_RBRAC - right bracket: 0,,NO_SECT,nesting level,address
// Set the size of the N_LBRAC to the terminating index of this N_RBRAC
// so that we can always skip the entire symbol if we need to navigate
// more quickly at the source level when parsing STABS
@@ -885,25 +895,29 @@ ObjectFileMachO::ParseSymtab (bool minimize)
type = eSymbolTypeScopeEnd;
break;
- case N_EXCL: // deleted include file: name,,NO_SECT,0,sum
+ case StabDeletedIncludeFile:
+ // N_EXCL - deleted include file: name,,NO_SECT,0,sum
type = eSymbolTypeHeaderFile;
break;
//----------------------------------------------------------------------
// COMM scopes
//----------------------------------------------------------------------
- case N_BCOMM: // begin common: name,,NO_SECT,0,0
+ case StabBeginCommon:
+ // N_BCOMM - begin common: name,,NO_SECT,0,0
// We use the current number of symbols in the symbol table in lieu of
// using nlist_idx in case we ever start trimming entries out
type = eSymbolTypeScopeBegin;
N_COMM_indexes.push_back(sym_idx);
break;
- case N_ECOML: // end common (local name): 0,,n_sect,0,address
+ case StabEndCommonLocal:
+ // N_ECOML - end common (local name): 0,,n_sect,0,address
symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value);
// Fall through
- case N_ECOMM: // end common: name,,n_sect,0,0
+ case StabEndCommon:
+ // N_ECOMM - end common: name,,n_sect,0,0
// Set the size of the N_BCOMM to the terminating index of this N_ECOMM/N_ECOML
// so that we can always skip the entire symbol if we need to navigate
// more quickly at the source level when parsing STABS
@@ -917,7 +931,8 @@ ObjectFileMachO::ParseSymtab (bool minimize)
type = eSymbolTypeScopeEnd;
break;
- case N_LENG: // second stab entry with length information
+ case StabLength:
+ // N_LENG - second stab entry with length information
type = eSymbolTypeAdditional;
break;
@@ -926,9 +941,9 @@ ObjectFileMachO::ParseSymtab (bool minimize)
}
else
{
- //uint8_t n_pext = N_PEXT & nlist.n_type;
- uint8_t n_type = N_TYPE & nlist.n_type;
- sym[sym_idx].SetExternal((N_EXT & nlist.n_type) != 0);
+ //uint8_t n_pext = NlistMaskPrivateExternal & nlist.n_type;
+ uint8_t n_type = NlistMaskType & nlist.n_type;
+ sym[sym_idx].SetExternal((NlistMaskExternal & nlist.n_type) != 0);
if (symbol_name && ::strstr (symbol_name, ".objc") == symbol_name)
{
@@ -938,17 +953,17 @@ ObjectFileMachO::ParseSymtab (bool minimize)
{
switch (n_type)
{
- case N_INDR: // Fall through
- case N_PBUD: // Fall through
- case N_UNDF:
+ case NListTypeIndirect: // N_INDR - Fall through
+ case NListTypePreboundUndefined:// N_PBUD - Fall through
+ case NListTypeUndefined: // N_UNDF
type = eSymbolTypeExtern;
break;
- case N_ABS:
+ case NListTypeAbsolute: // N_ABS
type = eSymbolTypeAbsolute;
break;
- case N_SECT:
+ case NListTypeSection: // N_SECT
symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value);
assert(symbol_section != NULL);
@@ -958,27 +973,27 @@ ObjectFileMachO::ParseSymtab (bool minimize)
}
else
{
- uint32_t section_type = symbol_section->GetAllFlagBits() & SECTION_TYPE;
+ uint32_t section_type = symbol_section->GetAllFlagBits() & SectionFlagMaskSectionType;
switch (section_type)
{
- case S_REGULAR: break; // regular section
- //case S_ZEROFILL: type = eSymbolTypeData; break; // zero fill on demand section
- case S_CSTRING_LITERALS: type = eSymbolTypeData; break; // section with only literal C strings
- case S_4BYTE_LITERALS: type = eSymbolTypeData; break; // section with only 4 byte literals
- case S_8BYTE_LITERALS: type = eSymbolTypeData; break; // section with only 8 byte literals
- case S_LITERAL_POINTERS: type = eSymbolTypeTrampoline; break; // section with only pointers to literals
- case S_NON_LAZY_SYMBOL_POINTERS: type = eSymbolTypeTrampoline; break; // section with only non-lazy symbol pointers
- case S_LAZY_SYMBOL_POINTERS: type = eSymbolTypeTrampoline; break; // section with only lazy symbol pointers
- case S_SYMBOL_STUBS: type = eSymbolTypeTrampoline; break; // section with only symbol stubs, byte size of stub in the reserved2 field
- case S_MOD_INIT_FUNC_POINTERS: type = eSymbolTypeCode; break; // section with only function pointers for initialization
- case S_MOD_TERM_FUNC_POINTERS: type = eSymbolTypeCode; break; // section with only function pointers for termination
- //case S_COALESCED: type = eSymbolType; break; // section contains symbols that are to be coalesced
- //case S_GB_ZEROFILL: type = eSymbolTypeData; break; // zero fill on demand section (that can be larger than 4 gigabytes)
- case S_INTERPOSING: type = eSymbolTypeTrampoline; break; // section with only pairs of function pointers for interposing
- case S_16BYTE_LITERALS: type = eSymbolTypeData; break; // section with only 16 byte literals
- case S_DTRACE_DOF: type = eSymbolTypeInstrumentation; break;
- case S_LAZY_DYLIB_SYMBOL_POINTERS: type = eSymbolTypeTrampoline; break;
+ case SectionTypeRegular: break; // regular section
+ //case SectionTypeZeroFill: type = eSymbolTypeData; break; // zero fill on demand section
+ case SectionTypeCStringLiterals: type = eSymbolTypeData; break; // section with only literal C strings
+ case SectionType4ByteLiterals: type = eSymbolTypeData; break; // section with only 4 byte literals
+ case SectionType8ByteLiterals: type = eSymbolTypeData; break; // section with only 8 byte literals
+ case SectionTypeLiteralPointers: type = eSymbolTypeTrampoline; break; // section with only pointers to literals
+ case SectionTypeNonLazySymbolPointers: type = eSymbolTypeTrampoline; break; // section with only non-lazy symbol pointers
+ case SectionTypeLazySymbolPointers: type = eSymbolTypeTrampoline; break; // section with only lazy symbol pointers
+ case SectionTypeSymbolStubs: type = eSymbolTypeTrampoline; break; // section with only symbol stubs, byte size of stub in the reserved2 field
+ case SectionTypeModuleInitFunctionPointers: type = eSymbolTypeCode; break; // section with only function pointers for initialization
+ case SectionTypeModuleTermFunctionPointers: type = eSymbolTypeCode; break; // section with only function pointers for termination
+ //case SectionTypeCoalesced: type = eSymbolType; break; // section contains symbols that are to be coalesced
+ //case SectionTypeZeroFillLarge: type = eSymbolTypeData; break; // zero fill on demand section (that can be larger than 4 gigabytes)
+ case SectionTypeInterposing: type = eSymbolTypeTrampoline; break; // section with only pairs of function pointers for interposing
+ case SectionType16ByteLiterals: type = eSymbolTypeData; break; // section with only 16 byte literals
+ case SectionTypeDTraceObjectFormat: type = eSymbolTypeInstrumentation; break;
+ case SectionTypeLazyDylibSymbolPointers: type = eSymbolTypeTrampoline; break;
default: break;
}
@@ -987,7 +1002,9 @@ ObjectFileMachO::ParseSymtab (bool minimize)
const char *symbol_sect_name = symbol_section->GetName().AsCString();
if (symbol_section->IsDescendant (text_section_sp.get()))
{
- if (symbol_section->IsClear(S_ATTR_PURE_INSTRUCTIONS | S_ATTR_SELF_MODIFYING_CODE | S_ATTR_SOME_INSTRUCTIONS))
+ if (symbol_section->IsClear(SectionAttrUserPureInstructions |
+ SectionAttrUserSelfModifyingCode |
+ SectionAttrSytemSomeInstructions))
type = eSymbolTypeData;
else
type = eSymbolTypeCode;
@@ -1097,7 +1114,7 @@ ObjectFileMachO::ParseSymtab (bool minimize)
for (uint32_t sect_idx = 1; sect_idx < m_mach_sections.size(); ++sect_idx)
{
- if ((m_mach_sections[sect_idx].flags & SECTION_TYPE) == S_SYMBOL_STUBS)
+ if ((m_mach_sections[sect_idx].flags & SectionFlagMaskSectionType) == SectionTypeSymbolStubs)
{
uint32_t symbol_stub_byte_size = m_mach_sections[sect_idx].reserved2;
if (symbol_stub_byte_size == 0)
@@ -1177,7 +1194,7 @@ ObjectFileMachO::Dump (Stream *s)
lldb_private::Mutex::Locker locker(m_mutex);
s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
s->Indent();
- if (m_header.magic == MH_MAGIC_64 || m_header.magic == MH_CIGAM_64)
+ if (m_header.magic == HeaderMagic64 || m_header.magic == HeaderMagic64Swapped)
s->PutCString("ObjectFileMachO64");
else
s->PutCString("ObjectFileMachO32");
@@ -1207,7 +1224,7 @@ ObjectFileMachO::GetUUID (UUID* uuid)
if (m_data.GetU32(&offset, &load_cmd, 2) == NULL)
break;
- if (load_cmd.cmd == LC_UUID)
+ if (load_cmd.cmd == LoadCommandUUID)
{
const uint8_t *uuid_bytes = m_data.PeekData(offset, 16);
if (uuid_bytes)
@@ -1239,11 +1256,11 @@ ObjectFileMachO::GetDependentModules (FileSpecList& files)
switch (load_cmd.cmd)
{
- case LC_LOAD_DYLIB:
- case LC_LOAD_WEAK_DYLIB:
- case LC_REEXPORT_DYLIB:
- case LC_LOAD_DYLINKER:
- case LC_LOADFVMLIB:
+ case LoadCommandDylibLoad:
+ case LoadCommandDylibLoadWeak:
+ case LoadCommandDylibReexport:
+ case LoadCommandDynamicLinkerLoad:
+ case LoadCommandFixedVMShlibLoad:
{
uint32_t name_offset = cmd_offset + m_data.GetU32(&offset);
const char *path = m_data.PeekCStr(name_offset);
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
index 3ffeb242b7c..d00ae0d73c0 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
@@ -10,7 +10,8 @@
#ifndef liblldb_ObjectFileMachO_h_
#define liblldb_ObjectFileMachO_h_
-#include <mach-o/loader.h>
+#include "llvm/Support/MachO.h"
+
#include "lldb/Core/FileSpec.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -112,13 +113,13 @@ public:
protected:
mutable lldb_private::Mutex m_mutex;
- struct mach_header m_header;
+ llvm::MachO::mach_header m_header;
mutable std::auto_ptr<lldb_private::SectionList> m_sections_ap;
mutable std::auto_ptr<lldb_private::Symtab> m_symtab_ap;
- struct dysymtab_command m_dysymtab;
- std::vector<struct segment_command_64> m_mach_segments;
- std::vector<struct section_64> m_mach_sections;
+ llvm::MachO::dysymtab_command m_dysymtab;
+ std::vector<llvm::MachO::segment_command_64> m_mach_segments;
+ std::vector<llvm::MachO::section_64> m_mach_sections;
size_t
ParseSections ();
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index ea5ac5cd14f..268e08ae29c 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -9,15 +9,9 @@
// C Includes
#include <errno.h>
-#include <mach/mach.h>
-#include <mach-o/dyld.h>
#include <spawn.h>
-#include <sys/fcntl.h>
#include <sys/types.h>
-#include <sys/ptrace.h>
#include <sys/stat.h>
-#include <sys/sysctl.h>
-#include <unistd.h>
// C++ Includes
#include <algorithm>
diff --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
index 270d7ed0f5d..14a62198fdb 100644
--- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -9,8 +9,6 @@
#include "SymbolVendorMacOSX.h"
-#include <mach/machine.h> // DebugSymbols needs this on Leopard...
-
#include <AvailabilityMacros.h>
#include "lldb/Core/Module.h"
diff --git a/lldb/source/Symbol/ASTType.cpp b/lldb/source/Symbol/ASTType.cpp
deleted file mode 100644
index 8ca19db4569..00000000000
--- a/lldb/source/Symbol/ASTType.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//===-- ASTType.cpp ---------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Symbol/ASTType.h"
-
-using namespace lldb_private;
-
-ASTTypeBase::~ASTTypeBase()
-{
-}
-
-ASTType::~ASTType()
-{
-} \ No newline at end of file
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 754ab195930..721656532cf 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -316,11 +316,11 @@ ClangASTContext::getSelectorTable()
return m_selector_table_ap.get();
}
-SourceManager *
+clang::SourceManager *
ClangASTContext::getSourceManager()
{
if (m_source_manager_ap.get() == NULL)
- m_source_manager_ap.reset(new SourceManager(*getDiagnostic()));
+ m_source_manager_ap.reset(new clang::SourceManager(*getDiagnostic()));
return m_source_manager_ap.get();
}
@@ -758,7 +758,7 @@ ClangASTContext::AddFieldToRecordType (void * record_clang_type, const char *nam
QualType record_qual_type(QualType::getFromOpaquePtr(record_clang_type));
- Type *clang_type = record_qual_type.getTypePtr();
+ clang::Type *clang_type = record_qual_type.getTypePtr();
if (clang_type)
{
const RecordType *record_type = dyn_cast<RecordType>(clang_type);
@@ -863,7 +863,7 @@ ClangASTContext::SetDefaultAccessForRecordFields (void *clang_qual_type, int def
if (clang_qual_type)
{
QualType qual_type(QualType::getFromOpaquePtr(clang_qual_type));
- Type *clang_type = qual_type.getTypePtr();
+ clang::Type *clang_type = qual_type.getTypePtr();
if (clang_type)
{
RecordType *record_type = dyn_cast<RecordType>(clang_type);
@@ -913,7 +913,7 @@ ClangASTContext::SetBaseClassesForClassType (void *class_clang_type, CXXBaseSpec
{
if (class_clang_type)
{
- Type *clang_type = QualType::getFromOpaquePtr(class_clang_type).getTypePtr();
+ clang::Type *clang_type = QualType::getFromOpaquePtr(class_clang_type).getTypePtr();
if (clang_type)
{
RecordType *record_type = dyn_cast<RecordType>(clang_type);
@@ -948,15 +948,15 @@ ClangASTContext::IsAggregateType (void *clang_type)
switch (qual_type->getTypeClass())
{
- case Type::IncompleteArray:
- case Type::VariableArray:
- case Type::ConstantArray:
- case Type::ExtVector:
- case Type::Vector:
- case Type::Record:
+ case clang::Type::IncompleteArray:
+ case clang::Type::VariableArray:
+ case clang::Type::ConstantArray:
+ case clang::Type::ExtVector:
+ case clang::Type::Vector:
+ case clang::Type::Record:
return true;
- case Type::Typedef:
+ case clang::Type::Typedef:
return ClangASTContext::IsAggregateType (cast<TypedefType>(qual_type)->LookThroughTypedefs().getAsOpaquePtr());
default:
@@ -976,7 +976,7 @@ ClangASTContext::GetNumChildren (void *clang_qual_type, bool omit_empty_base_cla
QualType qual_type(QualType::getFromOpaquePtr(clang_qual_type));
switch (qual_type->getTypeClass())
{
- case Type::Record:
+ case clang::Type::Record:
{
const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr());
const RecordDecl *record_decl = record_type->getDecl();
@@ -1017,11 +1017,11 @@ ClangASTContext::GetNumChildren (void *clang_qual_type, bool omit_empty_base_cla
}
break;
- case Type::ConstantArray:
+ case clang::Type::ConstantArray:
num_children = cast<ConstantArrayType>(qual_type.getTypePtr())->getSize().getLimitedValue();
break;
- case Type::Pointer:
+ case clang::Type::Pointer:
{
PointerType *pointer_type = cast<PointerType>(qual_type.getTypePtr());
QualType pointee_type = pointer_type->getPointeeType();
@@ -1034,7 +1034,7 @@ ClangASTContext::GetNumChildren (void *clang_qual_type, bool omit_empty_base_cla
}
break;
- case Type::Typedef:
+ case clang::Type::Typedef:
num_children = ClangASTContext::GetNumChildren (cast<TypedefType>(qual_type)->LookThroughTypedefs().getAsOpaquePtr(), omit_empty_base_classes);
break;
@@ -1103,7 +1103,7 @@ ClangASTContext::GetChildClangTypeAtIndex
QualType parent_qual_type(QualType::getFromOpaquePtr(parent_clang_type));
switch (parent_qual_type->getTypeClass())
{
- case Type::Record:
+ case clang::Type::Record:
{
const RecordType *record_type = cast<RecordType>(parent_qual_type.getTypePtr());
const RecordDecl *record_decl = record_type->getDecl();
@@ -1190,7 +1190,7 @@ ClangASTContext::GetChildClangTypeAtIndex
}
break;
- case Type::ConstantArray:
+ case clang::Type::ConstantArray:
{
const ConstantArrayType *array = cast<ConstantArrayType>(parent_qual_type.getTypePtr());
const uint64_t element_count = array->getSize().getLimitedValue();
@@ -1211,7 +1211,7 @@ ClangASTContext::GetChildClangTypeAtIndex
}
break;
- case Type::Pointer:
+ case clang::Type::Pointer:
{
PointerType *pointer_type = cast<PointerType>(parent_qual_type.getTypePtr());
QualType pointee_type = pointer_type->getPointeeType();
@@ -1251,7 +1251,7 @@ ClangASTContext::GetChildClangTypeAtIndex
}
break;
- case Type::Typedef:
+ case clang::Type::Typedef:
return GetChildClangTypeAtIndex (ast_context,
parent_name,
cast<TypedefType>(parent_qual_type)->LookThroughTypedefs().getAsOpaquePtr(),
@@ -1461,7 +1461,7 @@ ClangASTContext::GetIndexOfChildMemberWithName
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
switch (qual_type->getTypeClass())
{
- case Type::Record:
+ case clang::Type::Record:
{
const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr());
const RecordDecl *record_decl = record_type->getDecl();
@@ -1548,7 +1548,7 @@ ClangASTContext::GetIndexOfChildMemberWithName
}
break;
- case Type::ConstantArray:
+ case clang::Type::ConstantArray:
{
// const ConstantArrayType *array = cast<ConstantArrayType>(parent_qual_type.getTypePtr());
// const uint64_t element_count = array->getSize().getLimitedValue();
@@ -1569,7 +1569,7 @@ ClangASTContext::GetIndexOfChildMemberWithName
}
break;
-// case Type::MemberPointerType:
+// case clang::Type::MemberPointerType:
// {
// MemberPointerType *mem_ptr_type = cast<MemberPointerType>(qual_type.getTypePtr());
// QualType pointee_type = mem_ptr_type->getPointeeType();
@@ -1583,8 +1583,8 @@ ClangASTContext::GetIndexOfChildMemberWithName
// }
// break;
//
- case Type::LValueReference:
- case Type::RValueReference:
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference:
{
ReferenceType *reference_type = cast<ReferenceType>(qual_type.getTypePtr());
QualType pointee_type = reference_type->getPointeeType();
@@ -1600,7 +1600,7 @@ ClangASTContext::GetIndexOfChildMemberWithName
}
break;
- case Type::Pointer:
+ case clang::Type::Pointer:
{
PointerType *pointer_type = cast<PointerType>(qual_type.getTypePtr());
QualType pointee_type = pointer_type->getPointeeType();
@@ -1634,7 +1634,7 @@ ClangASTContext::GetIndexOfChildMemberWithName
}
break;
- case Type::Typedef:
+ case clang::Type::Typedef:
return GetIndexOfChildMemberWithName (ast_context,
cast<TypedefType>(qual_type)->LookThroughTypedefs().getAsOpaquePtr(),
name,
@@ -1667,7 +1667,7 @@ ClangASTContext::GetIndexOfChildWithName
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
switch (qual_type->getTypeClass())
{
- case Type::Record:
+ case clang::Type::Record:
{
const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr());
const RecordDecl *record_decl = record_type->getDecl();
@@ -1709,7 +1709,7 @@ ClangASTContext::GetIndexOfChildWithName
}
break;
- case Type::ConstantArray:
+ case clang::Type::ConstantArray:
{
// const ConstantArrayType *array = cast<ConstantArrayType>(parent_qual_type.getTypePtr());
// const uint64_t element_count = array->getSize().getLimitedValue();
@@ -1730,7 +1730,7 @@ ClangASTContext::GetIndexOfChildWithName
}
break;
-// case Type::MemberPointerType:
+// case clang::Type::MemberPointerType:
// {
// MemberPointerType *mem_ptr_type = cast<MemberPointerType>(qual_type.getTypePtr());
// QualType pointee_type = mem_ptr_type->getPointeeType();
@@ -1744,8 +1744,8 @@ ClangASTContext::GetIndexOfChildWithName
// }
// break;
//
- case Type::LValueReference:
- case Type::RValueReference:
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference:
{
ReferenceType *reference_type = cast<ReferenceType>(qual_type.getTypePtr());
QualType pointee_type = reference_type->getPointeeType();
@@ -1760,7 +1760,7 @@ ClangASTContext::GetIndexOfChildWithName
}
break;
- case Type::Pointer:
+ case clang::Type::Pointer:
{
PointerType *pointer_type = cast<PointerType>(qual_type.getTypePtr());
QualType pointee_type = pointer_type->getPointeeType();
@@ -1793,7 +1793,7 @@ ClangASTContext::GetIndexOfChildWithName
}
break;
- case Type::Typedef:
+ case clang::Type::Typedef:
return GetIndexOfChildWithName (ast_context,
cast<TypedefType>(qual_type)->LookThroughTypedefs().getAsOpaquePtr(),
name,
@@ -1814,7 +1814,7 @@ ClangASTContext::SetTagTypeKind (void *tag_clang_type, int kind)
if (tag_clang_type)
{
QualType tag_qual_type(QualType::getFromOpaquePtr(tag_clang_type));
- Type *clang_type = tag_qual_type.getTypePtr();
+ clang::Type *clang_type = tag_qual_type.getTypePtr();
if (clang_type)
{
TagType *tag_type = dyn_cast<TagType>(clang_type);
@@ -1844,34 +1844,34 @@ ClangASTContext::GetDeclContextForType (void *clang_type)
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
switch (qual_type->getTypeClass())
{
- case Type::FunctionNoProto: break;
- case Type::FunctionProto: break;
- case Type::IncompleteArray: break;
- case Type::VariableArray: break;
- case Type::ConstantArray: break;
- case Type::ExtVector: break;
- case Type::Vector: break;
- case Type::Builtin: break;
- case Type::ObjCObjectPointer: break;
- case Type::BlockPointer: break;
- case Type::Pointer: break;
- case Type::LValueReference: break;
- case Type::RValueReference: break;
- case Type::MemberPointer: break;
- case Type::Complex: break;
- case Type::ObjCInterface: break;
- case Type::Record:
+ case clang::Type::FunctionNoProto: break;
+ case clang::Type::FunctionProto: break;
+ case clang::Type::IncompleteArray: break;
+ case clang::Type::VariableArray: break;
+ case clang::Type::ConstantArray: break;
+ case clang::Type::ExtVector: break;
+ case clang::Type::Vector: break;
+ case clang::Type::Builtin: break;
+ case clang::Type::ObjCObjectPointer: break;
+ case clang::Type::BlockPointer: break;
+ case clang::Type::Pointer: break;
+ case clang::Type::LValueReference: break;
+ case clang::Type::RValueReference: break;
+ case clang::Type::MemberPointer: break;
+ case clang::Type::Complex: break;
+ case clang::Type::ObjCInterface: break;
+ case clang::Type::Record:
return cast<RecordType>(qual_type)->getDecl();
- case Type::Enum:
+ case clang::Type::Enum:
return cast<EnumType>(qual_type)->getDecl();
- case Type::Typedef:
+ case clang::Type::Typedef:
return ClangASTContext::GetDeclContextForType (cast<TypedefType>(qual_type)->LookThroughTypedefs().getAsOpaquePtr());
- case Type::TypeOfExpr: break;
- case Type::TypeOf: break;
- case Type::Decltype: break;
- //case Type::QualifiedName: break;
- case Type::TemplateSpecialization: break;
+ case clang::Type::TypeOfExpr: break;
+ case clang::Type::TypeOf: break;
+ case clang::Type::Decltype: break;
+ //case clang::Type::QualifiedName: break;
+ case clang::Type::TemplateSpecialization: break;
}
// No DeclContext in this type...
return NULL;
@@ -2006,7 +2006,7 @@ ClangASTContext::StartTagDeclarationDefinition (void *clang_type)
if (clang_type)
{
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
- Type *t = qual_type.getTypePtr();
+ clang::Type *t = qual_type.getTypePtr();
if (t)
{
TagType *tag_type = dyn_cast<TagType>(t);
@@ -2030,7 +2030,7 @@ ClangASTContext::CompleteTagDeclarationDefinition (void *clang_type)
if (clang_type)
{
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
- Type *t = qual_type.getTypePtr();
+ clang::Type *t = qual_type.getTypePtr();
if (t)
{
TagType *tag_type = dyn_cast<TagType>(t);
@@ -2091,7 +2091,7 @@ ClangASTContext::AddEnumerationValueToEnumerationType
assert (identifier_table != NULL);
QualType enum_qual_type (QualType::getFromOpaquePtr(enum_clang_type));
- Type *clang_type = enum_qual_type.getTypePtr();
+ clang::Type *clang_type = enum_qual_type.getTypePtr();
if (clang_type)
{
const EnumType *enum_type = dyn_cast<EnumType>(clang_type);
@@ -2171,31 +2171,31 @@ ClangASTContext::IsPointerOrReferenceType (void *clang_type, void **target_type)
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
switch (qual_type->getTypeClass())
{
- case Type::ObjCObjectPointer:
+ case clang::Type::ObjCObjectPointer:
if (target_type)
*target_type = cast<ObjCObjectPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
return true;
- case Type::BlockPointer:
+ case clang::Type::BlockPointer:
if (target_type)
*target_type = cast<BlockPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
return true;
- case Type::Pointer:
+ case clang::Type::Pointer:
if (target_type)
*target_type = cast<PointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
return true;
- case Type::MemberPointer:
+ case clang::Type::MemberPointer:
if (target_type)
*target_type = cast<MemberPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
return true;
- case Type::LValueReference:
+ case clang::Type::LValueReference:
if (target_type)
*target_type = cast<LValueReferenceType>(qual_type)->desugar().getAsOpaquePtr();
return true;
- case Type::RValueReference:
+ case clang::Type::RValueReference:
if (target_type)
*target_type = cast<LValueReferenceType>(qual_type)->desugar().getAsOpaquePtr();
return true;
- case Type::Typedef:
+ case clang::Type::Typedef:
return ClangASTContext::IsPointerOrReferenceType (cast<TypedefType>(qual_type)->LookThroughTypedefs().getAsOpaquePtr());
default:
break;
@@ -2247,23 +2247,23 @@ ClangASTContext::IsPointerType (void *clang_type, void **target_type)
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
switch (qual_type->getTypeClass())
{
- case Type::ObjCObjectPointer:
+ case clang::Type::ObjCObjectPointer:
if (target_type)
*target_type = cast<ObjCObjectPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
return true;
- case Type::BlockPointer:
+ case clang::Type::BlockPointer:
if (target_type)
*target_type = cast<BlockPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
return true;
- case Type::Pointer:
+ case clang::Type::Pointer:
if (target_type)
*target_type = cast<PointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
return true;
- case Type::MemberPointer:
+ case clang::Type::MemberPointer:
if (target_type)
*target_type = cast<MemberPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
return true;
- case Type::Typedef:
+ case clang::Type::Typedef:
return ClangASTContext::IsPointerOrReferenceType (cast<TypedefType>(qual_type)->LookThroughTypedefs().getAsOpaquePtr(), target_type);
default:
break;
@@ -2320,11 +2320,11 @@ ClangASTContext::IsCStringType (void *clang_type, uint32_t &length)
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
switch (qual_type->getTypeClass())
{
- case Type::ConstantArray:
+ case clang::Type::ConstantArray:
{
ConstantArrayType *array = cast<ConstantArrayType>(qual_type.getTypePtr());
QualType element_qual_type = array->getElementType();
- Type *canonical_type = element_qual_type->getCanonicalTypeInternal().getTypePtr();
+ clang::Type *canonical_type = element_qual_type->getCanonicalTypeInternal().getTypePtr();
if (canonical_type && canonical_type->isCharType())
{
// We know the size of the array and it could be a C string
@@ -2335,13 +2335,13 @@ ClangASTContext::IsCStringType (void *clang_type, uint32_t &length)
}
break;
- case Type::Pointer:
+ case clang::Type::Pointer:
{
PointerType *pointer_type = cast<PointerType>(qual_type.getTypePtr());
- Type *pointee_type_ptr = pointer_type->getPointeeType().getTypePtr();
+ clang::Type *pointee_type_ptr = pointer_type->getPointeeType().getTypePtr();
if (pointee_type_ptr)
{
- Type *canonical_type_ptr = pointee_type_ptr->getCanonicalTypeInternal().getTypePtr();
+ clang::Type *canonical_type_ptr = pointee_type_ptr->getCanonicalTypeInternal().getTypePtr();
length = 0; // No length info, read until a NULL terminator is received
if (canonical_type_ptr)
return canonical_type_ptr->isCharType();
@@ -2351,17 +2351,17 @@ ClangASTContext::IsCStringType (void *clang_type, uint32_t &length)
}
break;
- case Type::Typedef:
+ case clang::Type::Typedef:
return ClangASTContext::IsCStringType (cast<TypedefType>(qual_type)->LookThroughTypedefs().getAsOpaquePtr(), length);
- case Type::LValueReference:
- case Type::RValueReference:
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference:
{
ReferenceType *reference_type = cast<ReferenceType>(qual_type.getTypePtr());
- Type *pointee_type_ptr = reference_type->getPointeeType().getTypePtr();
+ clang::Type *pointee_type_ptr = reference_type->getPointeeType().getTypePtr();
if (pointee_type_ptr)
{
- Type *canonical_type_ptr = pointee_type_ptr->getCanonicalTypeInternal().getTypePtr();
+ clang::Type *canonical_type_ptr = pointee_type_ptr->getCanonicalTypeInternal().getTypePtr();
length = 0; // No length info, read until a NULL terminator is received
if (canonical_type_ptr)
return canonical_type_ptr->isCharType();
@@ -2385,24 +2385,24 @@ ClangASTContext::IsArrayType (void * clang_type, void **member_type, uint64_t *s
switch (qual_type->getTypeClass())
{
- case Type::ConstantArray:
+ case clang::Type::ConstantArray:
if (member_type)
*member_type = cast<ConstantArrayType>(qual_type)->getElementType().getAsOpaquePtr();
if (size)
*size = cast<ConstantArrayType>(qual_type)->getSize().getLimitedValue(ULONG_LONG_MAX);
return true;
- case Type::IncompleteArray:
+ case clang::Type::IncompleteArray:
if (member_type)
*member_type = cast<IncompleteArrayType>(qual_type)->getElementType().getAsOpaquePtr();
if (size)
*size = 0;
return true;
- case Type::VariableArray:
+ case clang::Type::VariableArray:
if (member_type)
*member_type = cast<VariableArrayType>(qual_type)->getElementType().getAsOpaquePtr();
if (size)
*size = 0;
- case Type::DependentSizedArray:
+ case clang::Type::DependentSizedArray:
if (member_type)
*member_type = cast<DependentSizedArrayType>(qual_type)->getElementType().getAsOpaquePtr();
if (size)
diff --git a/lldb/source/Symbol/ClangASTType.cpp b/lldb/source/Symbol/ClangASTType.cpp
new file mode 100644
index 00000000000..6c831db5e35
--- /dev/null
+++ b/lldb/source/Symbol/ClangASTType.cpp
@@ -0,0 +1,1114 @@
+//===-- ClangASTType.cpp ---------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Symbol/ClangASTType.h"
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclGroup.h"
+#include "clang/AST/RecordLayout.h"
+
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TargetInfo.h"
+
+#include "llvm/Support/FormattedStream.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Scalar.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Process.h"
+
+using namespace lldb_private;
+
+ClangASTType::~ClangASTType()
+{
+}
+
+ConstString
+ClangASTType::GetClangTypeName ()
+{
+ return GetClangTypeName (m_type);
+}
+
+ConstString
+ClangASTType::GetClangTypeName (void *opaque_clang_qual_type)
+{
+ ConstString clang_type_name;
+ if (opaque_clang_qual_type)
+ {
+ clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+
+ const clang::TypedefType *typedef_type = qual_type->getAs<clang::TypedefType>();
+ if (typedef_type)
+ {
+ const clang::TypedefDecl *typedef_decl = typedef_type->getDecl();
+ std::string clang_typedef_name (typedef_decl->getQualifiedNameAsString());
+ if (!clang_typedef_name.empty())
+ clang_type_name.SetCString (clang_typedef_name.c_str());
+ }
+ else
+ {
+ std::string type_name(qual_type.getAsString());
+ if (!type_name.empty())
+ clang_type_name.SetCString (type_name.c_str());
+ }
+ }
+ else
+ {
+ clang_type_name.SetCString ("<invalid>");
+ }
+
+ return clang_type_name;
+}
+
+lldb::Encoding
+ClangASTType::GetEncoding (uint32_t &count)
+{
+ return GetEncoding(m_type, count);
+}
+
+
+lldb::Encoding
+ClangASTType::GetEncoding (void *opaque_clang_qual_type, uint32_t &count)
+{
+ count = 1;
+ clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+
+ switch (qual_type->getTypeClass())
+ {
+ case clang::Type::FunctionNoProto:
+ case clang::Type::FunctionProto:
+ break;
+
+ case clang::Type::IncompleteArray:
+ case clang::Type::VariableArray:
+ break;
+
+ case clang::Type::ConstantArray:
+ break;
+
+ case clang::Type::ExtVector:
+ case clang::Type::Vector:
+ // TODO: Set this to more than one???
+ break;
+
+ case clang::Type::Builtin:
+ switch (cast<clang::BuiltinType>(qual_type)->getKind())
+ {
+ default: assert(0 && "Unknown builtin type!");
+ case clang::BuiltinType::Void:
+ break;
+
+ case clang::BuiltinType::Bool:
+ case clang::BuiltinType::Char_S:
+ case clang::BuiltinType::SChar:
+ case clang::BuiltinType::WChar:
+ case clang::BuiltinType::Char16:
+ case clang::BuiltinType::Char32:
+ case clang::BuiltinType::Short:
+ case clang::BuiltinType::Int:
+ case clang::BuiltinType::Long:
+ case clang::BuiltinType::LongLong:
+ case clang::BuiltinType::Int128: return lldb::eEncodingSint;
+
+ case clang::BuiltinType::Char_U:
+ case clang::BuiltinType::UChar:
+ case clang::BuiltinType::UShort:
+ case clang::BuiltinType::UInt:
+ case clang::BuiltinType::ULong:
+ case clang::BuiltinType::ULongLong:
+ case clang::BuiltinType::UInt128: return lldb::eEncodingUint;
+
+ case clang::BuiltinType::Float:
+ case clang::BuiltinType::Double:
+ case clang::BuiltinType::LongDouble: return lldb::eEncodingIEEE754;
+
+ case clang::BuiltinType::NullPtr: return lldb::eEncodingUint;
+ }
+ break;
+ // All pointer types are represented as unsigned integer encodings.
+ // We may nee to add a eEncodingPointer if we ever need to know the
+ // difference
+ case clang::Type::ObjCObjectPointer:
+ case clang::Type::BlockPointer:
+ case clang::Type::Pointer:
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference:
+ case clang::Type::MemberPointer: return lldb::eEncodingUint;
+ // Complex numbers are made up of floats
+ case clang::Type::Complex:
+ count = 2;
+ return lldb::eEncodingIEEE754;
+
+ case clang::Type::ObjCInterface: break;
+ case clang::Type::Record: break;
+ case clang::Type::Enum: return lldb::eEncodingSint;
+ case clang::Type::Typedef:
+ return GetEncoding(cast<clang::TypedefType>(qual_type)->LookThroughTypedefs().getAsOpaquePtr(), count);
+ break;
+
+ case clang::Type::TypeOfExpr:
+ case clang::Type::TypeOf:
+ case clang::Type::Decltype:
+// case clang::Type::QualifiedName:
+ case clang::Type::TemplateSpecialization: break;
+ }
+ count = 0;
+ return lldb::eEncodingInvalid;
+}
+
+lldb::Format
+ClangASTType::GetFormat ()
+{
+ return GetFormat (m_type);
+}
+
+lldb::Format
+ClangASTType::GetFormat (void *opaque_clang_qual_type)
+{
+ clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+
+ switch (qual_type->getTypeClass())
+ {
+ case clang::Type::FunctionNoProto:
+ case clang::Type::FunctionProto:
+ break;
+
+ case clang::Type::IncompleteArray:
+ case clang::Type::VariableArray:
+ break;
+
+ case clang::Type::ConstantArray:
+ break;
+
+ case clang::Type::ExtVector:
+ case clang::Type::Vector:
+ break;
+
+ case clang::Type::Builtin:
+ switch (cast<clang::BuiltinType>(qual_type)->getKind())
+ {
+ default: assert(0 && "Unknown builtin type!");
+ case clang::BuiltinType::Void:
+ break;
+
+ case clang::BuiltinType::Bool: return lldb::eFormatBoolean;
+ case clang::BuiltinType::Char_S:
+ case clang::BuiltinType::SChar:
+ case clang::BuiltinType::Char_U:
+ case clang::BuiltinType::UChar:
+ case clang::BuiltinType::WChar: return lldb::eFormatChar;
+ case clang::BuiltinType::Char16: return lldb::eFormatUnicode16;
+ case clang::BuiltinType::Char32: return lldb::eFormatUnicode32;
+ case clang::BuiltinType::UShort: return lldb::eFormatHex;
+ case clang::BuiltinType::Short: return lldb::eFormatDecimal;
+ case clang::BuiltinType::UInt: return lldb::eFormatHex;
+ case clang::BuiltinType::Int: return lldb::eFormatDecimal;
+ case clang::BuiltinType::ULong: return lldb::eFormatHex;
+ case clang::BuiltinType::Long: return lldb::eFormatDecimal;
+ case clang::BuiltinType::ULongLong: return lldb::eFormatHex;
+ case clang::BuiltinType::LongLong: return lldb::eFormatDecimal;
+ case clang::BuiltinType::UInt128: return lldb::eFormatHex;
+ case clang::BuiltinType::Int128: return lldb::eFormatDecimal;
+ case clang::BuiltinType::Float: return lldb::eFormatFloat;
+ case clang::BuiltinType::Double: return lldb::eFormatFloat;
+ case clang::BuiltinType::LongDouble: return lldb::eFormatFloat;
+ case clang::BuiltinType::NullPtr: return lldb::eFormatHex;
+ }
+ break;
+ case clang::Type::ObjCObjectPointer: return lldb::eFormatHex;
+ case clang::Type::BlockPointer: return lldb::eFormatHex;
+ case clang::Type::Pointer: return lldb::eFormatHex;
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference: return lldb::eFormatHex;
+ case clang::Type::MemberPointer: break;
+ case clang::Type::Complex: return lldb::eFormatComplex;
+ case clang::Type::ObjCInterface: break;
+ case clang::Type::Record: break;
+ case clang::Type::Enum: return lldb::eFormatEnum;
+ case clang::Type::Typedef:
+ return ClangASTType::GetFormat(cast<clang::TypedefType>(qual_type)->LookThroughTypedefs().getAsOpaquePtr());
+
+ case clang::Type::TypeOfExpr:
+ case clang::Type::TypeOf:
+ case clang::Type::Decltype:
+// case clang::Type::QualifiedName:
+ case clang::Type::TemplateSpecialization: break;
+ }
+ // We don't know hot to display this type...
+ return lldb::eFormatBytes;
+}
+
+
+void
+ClangASTType::DumpValue
+(
+ ExecutionContext *exe_ctx,
+ Stream *s,
+ lldb::Format format,
+ const lldb_private::DataExtractor &data,
+ uint32_t data_byte_offset,
+ size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset,
+ bool show_types,
+ bool show_summary,
+ bool verbose,
+ uint32_t depth
+)
+{
+ return DumpValue (m_ast,
+ m_type,
+ exe_ctx,
+ s,
+ format,
+ data,
+ data_byte_offset,
+ data_byte_size,
+ bitfield_bit_size,
+ bitfield_bit_offset,
+ show_types,
+ show_summary,
+ verbose,
+ depth);
+}
+
+#define DEPTH_INCREMENT 2
+void
+ClangASTType::DumpValue
+(
+ clang::ASTContext *ast_context,
+ void *opaque_clang_qual_type,
+ ExecutionContext *exe_ctx,
+ Stream *s,
+ lldb::Format format,
+ const lldb_private::DataExtractor &data,
+ uint32_t data_byte_offset,
+ size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset,
+ bool show_types,
+ bool show_summary,
+ bool verbose,
+ uint32_t depth
+)
+{
+ clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+ switch (qual_type->getTypeClass())
+ {
+ case clang::Type::Record:
+ {
+ const clang::RecordType *record_type = cast<clang::RecordType>(qual_type.getTypePtr());
+ const clang::RecordDecl *record_decl = record_type->getDecl();
+ assert(record_decl);
+ uint32_t field_bit_offset = 0;
+ uint32_t field_byte_offset = 0;
+ const clang::ASTRecordLayout &record_layout = ast_context->getASTRecordLayout(record_decl);
+ uint32_t child_idx = 0;
+
+
+ const clang::CXXRecordDecl *cxx_record_decl = dyn_cast<clang::CXXRecordDecl>(record_decl);
+ if (cxx_record_decl)
+ {
+ // We might have base classes to print out first
+ clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
+ for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
+ base_class != base_class_end;
+ ++base_class)
+ {
+ const clang::CXXRecordDecl *base_class_decl = cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
+
+ // Skip empty base classes
+ if (verbose == false && ClangASTContext::RecordHasFields(base_class_decl) == false)
+ continue;
+
+ if (base_class->isVirtual())
+ field_bit_offset = record_layout.getVBaseClassOffset(base_class_decl);
+ else
+ field_bit_offset = record_layout.getBaseClassOffset(base_class_decl);
+ field_byte_offset = field_bit_offset / 8;
+ assert (field_bit_offset % 8 == 0);
+ if (child_idx == 0)
+ s->PutChar('{');
+ else
+ s->PutChar(',');
+
+ clang::QualType base_class_qual_type = base_class->getType();
+ std::string base_class_type_name(base_class_qual_type.getAsString());
+
+ // Indent and print the base class type name
+ s->Printf("\n%*s%s ", depth + DEPTH_INCREMENT, "", base_class_type_name.c_str());
+
+ std::pair<uint64_t, unsigned> base_class_type_info = ast_context->getTypeInfo(base_class_qual_type);
+
+ // Dump the value of the member
+ DumpValue (ast_context, // The clang AST context for this type
+ base_class_qual_type.getAsOpaquePtr(),// The clang type we want to dump
+ exe_ctx,
+ s, // Stream to dump to
+ ClangASTType::GetFormat(base_class_qual_type.getAsOpaquePtr()), // The format with which to display the member
+ data, // Data buffer containing all bytes for this type
+ data_byte_offset + field_byte_offset,// Offset into "data" where to grab value from
+ base_class_type_info.first / 8, // Size of this type in bytes
+ 0, // Bitfield bit size
+ 0, // Bitfield bit offset
+ show_types, // Boolean indicating if we should show the variable types
+ show_summary, // Boolean indicating if we should show a summary for the current type
+ verbose, // Verbose output?
+ depth + DEPTH_INCREMENT); // Scope depth for any types that have children
+
+ ++child_idx;
+ }
+ }
+ uint32_t field_idx = 0;
+ clang::RecordDecl::field_iterator field, field_end;
+ for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx, ++child_idx)
+ {
+ // Print the starting squiggly bracket (if this is the
+ // first member) or comman (for member 2 and beyong) for
+ // the struct/union/class member.
+ if (child_idx == 0)
+ s->PutChar('{');
+ else
+ s->PutChar(',');
+
+ // Indent
+ s->Printf("\n%*s", depth + DEPTH_INCREMENT, "");
+
+ clang::QualType field_type = field->getType();
+ // Print the member type if requested
+ // Figure out the type byte size (field_type_info.first) and
+ // alignment (field_type_info.second) from the AST context.
+ std::pair<uint64_t, unsigned> field_type_info = ast_context->getTypeInfo(field_type);
+ assert(field_idx < record_layout.getFieldCount());
+ // Figure out the field offset within the current struct/union/class type
+ field_bit_offset = record_layout.getFieldOffset (field_idx);
+ field_byte_offset = field_bit_offset / 8;
+ uint32_t field_bitfield_bit_size = 0;
+ uint32_t field_bitfield_bit_offset = 0;
+ if (ClangASTContext::FieldIsBitfield (ast_context, *field, field_bitfield_bit_size))
+ field_bitfield_bit_offset = field_bit_offset % 8;
+
+ if (show_types)
+ {
+ std::string field_type_name(field_type.getAsString());
+ if (field_bitfield_bit_size > 0)
+ s->Printf("(%s:%u) ", field_type_name.c_str(), field_bitfield_bit_size);
+ else
+ s->Printf("(%s) ", field_type_name.c_str());
+ }
+ // Print the member name and equal sign
+ s->Printf("%s = ", field->getNameAsString().c_str());
+
+
+ // Dump the value of the member
+ DumpValue (ast_context, // The clang AST context for this type
+ field_type.getAsOpaquePtr(), // The clang type we want to dump
+ exe_ctx,
+ s, // Stream to dump to
+ ClangASTType::GetFormat(field_type.getAsOpaquePtr()), // The format with which to display the member
+ data, // Data buffer containing all bytes for this type
+ data_byte_offset + field_byte_offset,// Offset into "data" where to grab value from
+ field_type_info.first / 8, // Size of this type in bytes
+ field_bitfield_bit_size, // Bitfield bit size
+ field_bitfield_bit_offset, // Bitfield bit offset
+ show_types, // Boolean indicating if we should show the variable types
+ show_summary, // Boolean indicating if we should show a summary for the current type
+ verbose, // Verbose output?
+ depth + DEPTH_INCREMENT); // Scope depth for any types that have children
+ }
+
+ // Indent the trailing squiggly bracket
+ if (child_idx > 0)
+ s->Printf("\n%*s}", depth, "");
+ }
+ return;
+
+ case clang::Type::Enum:
+ {
+ const clang::EnumType *enum_type = cast<clang::EnumType>(qual_type.getTypePtr());
+ const clang::EnumDecl *enum_decl = enum_type->getDecl();
+ assert(enum_decl);
+ clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
+ uint32_t offset = data_byte_offset;
+ const int64_t enum_value = data.GetMaxU64Bitfield(&offset, data_byte_size, bitfield_bit_size, bitfield_bit_offset);
+ for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos)
+ {
+ if (enum_pos->getInitVal() == enum_value)
+ {
+ s->Printf("%s", enum_pos->getNameAsCString());
+ return;
+ }
+ }
+ // If we have gotten here we didn't get find the enumerator in the
+ // enum decl, so just print the integer.
+ s->Printf("%lli", enum_value);
+ }
+ return;
+
+ case clang::Type::ConstantArray:
+ {
+ const clang::ConstantArrayType *array = cast<clang::ConstantArrayType>(qual_type.getTypePtr());
+ bool is_array_of_characters = false;
+ clang::QualType element_qual_type = array->getElementType();
+
+ clang::Type *canonical_type = element_qual_type->getCanonicalTypeInternal().getTypePtr();
+ if (canonical_type)
+ is_array_of_characters = canonical_type->isCharType();
+
+ const uint64_t element_count = array->getSize().getLimitedValue();
+
+ std::pair<uint64_t, unsigned> field_type_info = ast_context->getTypeInfo(element_qual_type);
+
+ uint32_t element_idx = 0;
+ uint32_t element_offset = 0;
+ uint64_t element_byte_size = field_type_info.first / 8;
+ uint32_t element_stride = element_byte_size;
+
+ if (is_array_of_characters)
+ {
+ s->PutChar('"');
+ data.Dump(s, data_byte_offset, lldb::eFormatChar, element_byte_size, element_count, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('"');
+ return;
+ }
+ else
+ {
+ lldb::Format element_format = ClangASTType::GetFormat(element_qual_type.getAsOpaquePtr());
+
+ for (element_idx = 0; element_idx < element_count; ++element_idx)
+ {
+ // Print the starting squiggly bracket (if this is the
+ // first member) or comman (for member 2 and beyong) for
+ // the struct/union/class member.
+ if (element_idx == 0)
+ s->PutChar('{');
+ else
+ s->PutChar(',');
+
+ // Indent and print the index
+ s->Printf("\n%*s[%u] ", depth + DEPTH_INCREMENT, "", element_idx);
+
+ // Figure out the field offset within the current struct/union/class type
+ element_offset = element_idx * element_stride;
+
+ // Dump the value of the member
+ DumpValue (ast_context, // The clang AST context for this type
+ element_qual_type.getAsOpaquePtr(), // The clang type we want to dump
+ exe_ctx,
+ s, // Stream to dump to
+ element_format, // The format with which to display the element
+ data, // Data buffer containing all bytes for this type
+ data_byte_offset + element_offset,// Offset into "data" where to grab value from
+ element_byte_size, // Size of this type in bytes
+ 0, // Bitfield bit size
+ 0, // Bitfield bit offset
+ show_types, // Boolean indicating if we should show the variable types
+ show_summary, // Boolean indicating if we should show a summary for the current type
+ verbose, // Verbose output?
+ depth + DEPTH_INCREMENT); // Scope depth for any types that have children
+ }
+
+ // Indent the trailing squiggly bracket
+ if (element_idx > 0)
+ s->Printf("\n%*s}", depth, "");
+ }
+ }
+ return;
+
+ case clang::Type::Typedef:
+ {
+ clang::QualType typedef_qual_type = cast<clang::TypedefType>(qual_type)->LookThroughTypedefs();
+ lldb::Format typedef_format = ClangASTType::GetFormat(typedef_qual_type.getAsOpaquePtr());
+ std::pair<uint64_t, unsigned> typedef_type_info = ast_context->getTypeInfo(typedef_qual_type);
+ uint64_t typedef_byte_size = typedef_type_info.first / 8;
+
+ return DumpValue (ast_context, // The clang AST context for this type
+ typedef_qual_type.getAsOpaquePtr(), // The clang type we want to dump
+ exe_ctx,
+ s, // Stream to dump to
+ typedef_format, // The format with which to display the element
+ data, // Data buffer containing all bytes for this type
+ data_byte_offset, // Offset into "data" where to grab value from
+ typedef_byte_size, // Size of this type in bytes
+ bitfield_bit_size, // Bitfield bit size
+ bitfield_bit_offset,// Bitfield bit offset
+ show_types, // Boolean indicating if we should show the variable types
+ show_summary, // Boolean indicating if we should show a summary for the current type
+ verbose, // Verbose output?
+ depth); // Scope depth for any types that have children
+ }
+ break;
+
+ default:
+ // We are down the a scalar type that we just need to display.
+ data.Dump(s, data_byte_offset, format, data_byte_size, 1, UINT32_MAX, LLDB_INVALID_ADDRESS, bitfield_bit_size, bitfield_bit_offset);
+
+ if (show_summary)
+ DumpSummary (ast_context, opaque_clang_qual_type, exe_ctx, s, data, data_byte_offset, data_byte_size);
+ break;
+ }
+}
+
+
+
+bool
+ClangASTType::DumpTypeValue
+(
+ Stream *s,
+ lldb::Format format,
+ const lldb_private::DataExtractor &data,
+ uint32_t byte_offset,
+ size_t byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset
+)
+{
+ return DumpTypeValue (m_ast,
+ m_type,
+ s,
+ format,
+ data,
+ byte_offset,
+ byte_size,
+ bitfield_bit_size,
+ bitfield_bit_offset);
+}
+
+
+bool
+ClangASTType::DumpTypeValue
+(
+ clang::ASTContext *ast_context,
+ void *opaque_clang_qual_type,
+ Stream *s,
+ lldb::Format format,
+ const lldb_private::DataExtractor &data,
+ uint32_t byte_offset,
+ size_t byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset
+)
+{
+ clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+ if (ClangASTContext::IsAggregateType (opaque_clang_qual_type))
+ {
+ return 0;
+ }
+ else
+ {
+ switch (qual_type->getTypeClass())
+ {
+ case clang::Type::Enum:
+ {
+ const clang::EnumType *enum_type = cast<clang::EnumType>(qual_type.getTypePtr());
+ const clang::EnumDecl *enum_decl = enum_type->getDecl();
+ assert(enum_decl);
+ clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
+ uint32_t offset = byte_offset;
+ const int64_t enum_value = data.GetMaxU64Bitfield (&offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
+ for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos)
+ {
+ if (enum_pos->getInitVal() == enum_value)
+ {
+ s->PutCString (enum_pos->getNameAsCString());
+ return true;
+ }
+ }
+ // If we have gotten here we didn't get find the enumerator in the
+ // enum decl, so just print the integer.
+
+ s->Printf("%lli", enum_value);
+ return true;
+ }
+ break;
+
+ case clang::Type::Typedef:
+ {
+ clang::QualType typedef_qual_type = cast<clang::TypedefType>(qual_type)->LookThroughTypedefs();
+ lldb::Format typedef_format = ClangASTType::GetFormat(typedef_qual_type.getAsOpaquePtr());
+ std::pair<uint64_t, unsigned> typedef_type_info = ast_context->getTypeInfo(typedef_qual_type);
+ uint64_t typedef_byte_size = typedef_type_info.first / 8;
+
+ return ClangASTType::DumpTypeValue(
+ ast_context, // The clang AST context for this type
+ typedef_qual_type.getAsOpaquePtr(), // The clang type we want to dump
+ s,
+ typedef_format, // The format with which to display the element
+ data, // Data buffer containing all bytes for this type
+ byte_offset, // Offset into "data" where to grab value from
+ typedef_byte_size, // Size of this type in bytes
+ bitfield_bit_size, // Size in bits of a bitfield value, if zero don't treat as a bitfield
+ bitfield_bit_offset); // Offset in bits of a bitfield value if bitfield_bit_size != 0
+ }
+ break;
+
+ default:
+ // We are down the a scalar type that we just need to display.
+ return data.Dump(s,
+ byte_offset,
+ format,
+ byte_size,
+ 1,
+ UINT32_MAX,
+ LLDB_INVALID_ADDRESS,
+ bitfield_bit_size,
+ bitfield_bit_offset);
+ break;
+ }
+ }
+ return 0;
+}
+
+
+
+void
+ClangASTType::DumpSummary
+(
+ ExecutionContext *exe_ctx,
+ Stream *s,
+ const lldb_private::DataExtractor &data,
+ uint32_t data_byte_offset,
+ size_t data_byte_size
+)
+{
+ return DumpSummary (m_ast,
+ m_type,
+ exe_ctx,
+ s,
+ data,
+ data_byte_offset,
+ data_byte_size);
+}
+
+void
+ClangASTType::DumpSummary
+(
+ clang::ASTContext *ast_context,
+ void *opaque_clang_qual_type,
+ ExecutionContext *exe_ctx,
+ Stream *s,
+ const lldb_private::DataExtractor &data,
+ uint32_t data_byte_offset,
+ size_t data_byte_size
+)
+{
+ uint32_t length = 0;
+ clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+ if (ClangASTContext::IsCStringType (opaque_clang_qual_type, length))
+ {
+
+ if (exe_ctx && exe_ctx->process)
+ {
+ uint32_t offset = data_byte_offset;
+ lldb::addr_t pointer_addresss = data.GetMaxU64(&offset, data_byte_size);
+ std::vector<uint8_t> buf;
+ if (length > 0)
+ buf.resize (length);
+ else
+ buf.resize (256);
+
+ lldb_private::DataExtractor cstr_data(&buf.front(), buf.size(), exe_ctx->process->GetByteOrder(), 4);
+ buf.back() = '\0';
+ size_t bytes_read;
+ size_t total_cstr_len = 0;
+ Error error;
+ while ((bytes_read = exe_ctx->process->ReadMemory (pointer_addresss, &buf.front(), buf.size(), error)) > 0)
+ {
+ const size_t len = strlen((const char *)&buf.front());
+ if (len == 0)
+ break;
+ if (total_cstr_len == 0)
+ s->PutCString (" \"");
+ cstr_data.Dump(s, 0, lldb::eFormatChar, 1, len, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
+ total_cstr_len += len;
+ if (len < buf.size())
+ break;
+ pointer_addresss += total_cstr_len;
+ }
+ if (total_cstr_len > 0)
+ s->PutChar ('"');
+ }
+ }
+}
+
+bool
+ClangASTType::GetValueAsScalar
+(
+ const lldb_private::DataExtractor &data,
+ uint32_t data_byte_offset,
+ size_t data_byte_size,
+ Scalar &value
+)
+{
+ return GetValueAsScalar (m_ast,
+ m_type,
+ data,
+ data_byte_offset,
+ data_byte_size,
+ value);
+}
+
+bool
+ClangASTType::GetValueAsScalar
+(
+ clang::ASTContext *ast_context,
+ void *opaque_clang_qual_type,
+ const lldb_private::DataExtractor &data,
+ uint32_t data_byte_offset,
+ size_t data_byte_size,
+ Scalar &value
+)
+{
+ clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+
+ if (ClangASTContext::IsAggregateType (opaque_clang_qual_type))
+ {
+ return false; // Aggregate types don't have scalar values
+ }
+ else
+ {
+ uint32_t count = 0;
+ lldb::Encoding encoding = GetEncoding (opaque_clang_qual_type, count);
+
+ if (encoding == lldb::eEncodingInvalid || count != 1)
+ return false;
+
+ uint64_t bit_width = ast_context->getTypeSize(qual_type);
+ uint32_t byte_size = (bit_width + 7 ) / 8;
+ uint32_t offset = data_byte_offset;
+ switch (encoding)
+ {
+ case lldb::eEncodingUint:
+ if (byte_size <= sizeof(unsigned long long))
+ {
+ uint64_t uval64 = data.GetMaxU64 (&offset, byte_size);
+ if (byte_size <= sizeof(unsigned int))
+ {
+ value = (unsigned int)uval64;
+ return true;
+ }
+ else if (byte_size <= sizeof(unsigned long))
+ {
+ value = (unsigned long)uval64;
+ return true;
+ }
+ else if (byte_size <= sizeof(unsigned long long))
+ {
+ value = (unsigned long long )uval64;
+ return true;
+ }
+ else
+ value.Clear();
+ }
+ break;
+
+ case lldb::eEncodingSint:
+ if (byte_size <= sizeof(long long))
+ {
+ int64_t sval64 = (int64_t)data.GetMaxU64 (&offset, byte_size);
+ if (byte_size <= sizeof(int))
+ {
+ value = (int)sval64;
+ return true;
+ }
+ else if (byte_size <= sizeof(long))
+ {
+ value = (long)sval64;
+ return true;
+ }
+ else if (byte_size <= sizeof(long long))
+ {
+ value = (long long )sval64;
+ return true;
+ }
+ else
+ value.Clear();
+ }
+ break;
+
+ case lldb::eEncodingIEEE754:
+ if (byte_size <= sizeof(long double))
+ {
+ uint32_t u32;
+ uint64_t u64;
+ if (byte_size == sizeof(float))
+ {
+ if (sizeof(float) == sizeof(uint32_t))
+ {
+ u32 = data.GetU32(&offset);
+ value = *((float *)&u32);
+ return true;
+ }
+ else if (sizeof(float) == sizeof(uint64_t))
+ {
+ u64 = data.GetU64(&offset);
+ value = *((float *)&u64);
+ return true;
+ }
+ }
+ else
+ if (byte_size == sizeof(double))
+ {
+ if (sizeof(double) == sizeof(uint32_t))
+ {
+ u32 = data.GetU32(&offset);
+ value = *((double *)&u32);
+ return true;
+ }
+ else if (sizeof(double) == sizeof(uint64_t))
+ {
+ u64 = data.GetU64(&offset);
+ value = *((double *)&u64);
+ return true;
+ }
+ }
+ else
+ if (byte_size == sizeof(long double))
+ {
+ if (sizeof(long double) == sizeof(uint32_t))
+ {
+ u32 = data.GetU32(&offset);
+ value = *((long double *)&u32);
+ return true;
+ }
+ else if (sizeof(long double) == sizeof(uint64_t))
+ {
+ u64 = data.GetU64(&offset);
+ value = *((long double *)&u64);
+ return true;
+ }
+ }
+ }
+ break;
+ }
+ }
+ return false;
+}
+
+bool
+ClangASTType::SetValueFromScalar (const Scalar &value, Stream &strm)
+{
+ return SetValueFromScalar (m_ast, m_type, value, strm);
+}
+
+bool
+ClangASTType::SetValueFromScalar
+(
+ clang::ASTContext *ast_context,
+ void *opaque_clang_qual_type,
+ const Scalar &value,
+ Stream &strm
+)
+{
+ clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+
+ // Aggregate types don't have scalar values
+ if (!ClangASTContext::IsAggregateType (opaque_clang_qual_type))
+ {
+ strm.GetFlags().Set(Stream::eBinary);
+ uint32_t count = 0;
+ lldb::Encoding encoding = GetEncoding (opaque_clang_qual_type, count);
+
+ if (encoding == lldb::eEncodingInvalid || count != 1)
+ return false;
+
+ uint64_t bit_width = ast_context->getTypeSize(qual_type);
+ // This function doesn't currently handle non-byte aligned assignments
+ if ((bit_width % 8) != 0)
+ return false;
+
+ uint32_t byte_size = (bit_width + 7 ) / 8;
+ switch (encoding)
+ {
+ case lldb::eEncodingUint:
+ switch (byte_size)
+ {
+ case 1: strm.PutHex8(value.UInt()); return true;
+ case 2: strm.PutHex16(value.UInt()); return true;
+ case 4: strm.PutHex32(value.UInt()); return true;
+ case 8: strm.PutHex64(value.ULongLong()); return true;
+ default:
+ break;
+ }
+ break;
+
+ case lldb::eEncodingSint:
+ switch (byte_size)
+ {
+ case 1: strm.PutHex8(value.SInt()); return true;
+ case 2: strm.PutHex16(value.SInt()); return true;
+ case 4: strm.PutHex32(value.SInt()); return true;
+ case 8: strm.PutHex64(value.SLongLong()); return true;
+ default:
+ break;
+ }
+ break;
+
+ case lldb::eEncodingIEEE754:
+ if (byte_size <= sizeof(long double))
+ {
+ if (byte_size == sizeof(float))
+ {
+ strm.PutFloat(value.Float());
+ return true;
+ }
+ else
+ if (byte_size == sizeof(double))
+ {
+ strm.PutDouble(value.Double());
+ return true;
+ }
+ else
+ if (byte_size == sizeof(long double))
+ {
+ strm.PutDouble(value.LongDouble());
+ return true;
+ }
+ }
+ break;
+ }
+ }
+ return false;
+}
+
+bool
+ClangASTType::ReadFromMemory
+(
+ lldb_private::ExecutionContext *exe_ctx,
+ lldb::addr_t addr,
+ lldb::AddressType address_type,
+ lldb_private::DataExtractor &data
+)
+{
+ return ReadFromMemory (m_ast,
+ m_type,
+ exe_ctx,
+ addr,
+ address_type,
+ data);
+}
+
+
+bool
+ClangASTType::ReadFromMemory
+(
+ clang::ASTContext *ast_context,
+ void *opaque_clang_qual_type,
+ lldb_private::ExecutionContext *exe_ctx,
+ lldb::addr_t addr,
+ lldb::AddressType address_type,
+ lldb_private::DataExtractor &data
+)
+{
+ if (address_type == lldb::eAddressTypeFile)
+ {
+ // Can't convert a file address to anything valid without more
+ // context (which Module it came from)
+ return false;
+ }
+ clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+
+ const uint32_t byte_size = (ast_context->getTypeSize (qual_type) + 7) / 8;
+ if (data.GetByteSize() < byte_size)
+ {
+ lldb::DataBufferSP data_sp(new DataBufferHeap (byte_size, '\0'));
+ data.SetData(data_sp);
+ }
+
+ uint8_t* dst = (uint8_t*)data.PeekData(0, byte_size);
+ if (dst != NULL)
+ {
+ if (address_type == lldb::eAddressTypeHost)
+ {
+ // The address is an address in this process, so just copy it
+ memcpy (dst, (uint8_t*)NULL + addr, byte_size);
+ return true;
+ }
+ else
+ {
+ if (exe_ctx && exe_ctx->process)
+ {
+ Error error;
+ return exe_ctx->process->ReadMemory(addr, dst, byte_size, error) == byte_size;
+ }
+ }
+ }
+ return false;
+}
+
+bool
+ClangASTType::WriteToMemory
+(
+ lldb_private::ExecutionContext *exe_ctx,
+ lldb::addr_t addr,
+ lldb::AddressType address_type,
+ StreamString &new_value
+)
+{
+ return WriteToMemory (m_ast,
+ m_type,
+ exe_ctx,
+ addr,
+ address_type,
+ new_value);
+}
+
+bool
+ClangASTType::WriteToMemory
+(
+ clang::ASTContext *ast_context,
+ void *opaque_clang_qual_type,
+ lldb_private::ExecutionContext *exe_ctx,
+ lldb::addr_t addr,
+ lldb::AddressType address_type,
+ StreamString &new_value
+)
+{
+ if (address_type == lldb::eAddressTypeFile)
+ {
+ // Can't convert a file address to anything valid without more
+ // context (which Module it came from)
+ return false;
+ }
+ clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+ const uint32_t byte_size = (ast_context->getTypeSize (qual_type) + 7) / 8;
+
+ if (byte_size > 0)
+ {
+ if (address_type == lldb::eAddressTypeHost)
+ {
+ // The address is an address in this process, so just copy it
+ memcpy ((void *)addr, new_value.GetData(), byte_size);
+ return true;
+ }
+ else
+ {
+ if (exe_ctx && exe_ctx->process)
+ {
+ Error error;
+ return exe_ctx->process->WriteMemory(addr, new_value.GetData(), byte_size, error) == byte_size;
+ }
+ }
+ }
+ return false;
+}
+
+
diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index 57f6cb4cd55..94eec1e7478 100644
--- a/lldb/source/Symbol/Function.cpp
+++ b/lldb/source/Symbol/Function.cpp
@@ -10,10 +10,11 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
+#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/SymbolVendor.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "clang/AST/Type.h"
#include "clang/AST/CanonicalType.h"
@@ -339,7 +340,7 @@ Function::GetReturnType ()
clang::FunctionType *function_type = dyn_cast<clang::FunctionType> (clang_type);
clang::QualType fun_return_qualtype = function_type->getResultType();
- const ConstString fun_return_name(Type::GetClangTypeName(fun_return_qualtype.getAsOpaquePtr()));
+ const ConstString fun_return_name(ClangASTType::GetClangTypeName(fun_return_qualtype.getAsOpaquePtr()));
SymbolContext sc;
CalculateSymbolContext (&sc);
@@ -381,7 +382,7 @@ Function::GetArgumentTypeAtIndex (size_t idx)
return Type();
clang::QualType arg_qualtype = (function_proto_type->arg_type_begin())[idx];
- const ConstString arg_return_name(Type::GetClangTypeName(arg_qualtype.getAsOpaquePtr()));
+ const ConstString arg_return_name(ClangASTType::GetClangTypeName(arg_qualtype.getAsOpaquePtr()));
SymbolContext sc;
CalculateSymbolContext (&sc);
// Null out everything below the CompUnit 'cause we don't actually know these.
diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp
index 31a5bac7d51..e58d0d4f40b 100644
--- a/lldb/source/Symbol/Type.cpp
+++ b/lldb/source/Symbol/Type.cpp
@@ -30,6 +30,7 @@
#include "lldb/Core/Scalar.h"
#include "lldb/Core/StreamString.h"
+#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContextScope.h"
@@ -270,59 +271,6 @@ lldb_private::Type::GetName()
return m_name;
}
-int
-lldb_private::Type::DumpClangTypeName(Stream *s, void *clang_type)
-{
- clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
- std::string type_name;
- const clang::TypedefType *typedef_type = qual_type->getAs<clang::TypedefType>();
- if (typedef_type)
- {
- const clang::TypedefDecl *typedef_decl = typedef_type->getDecl();
- type_name = typedef_decl->getQualifiedNameAsString();
- }
- else
- {
- type_name = qual_type.getAsString();
- }
- if (!type_name.empty())
- return s->Printf("(%s) ", type_name.c_str());
- return 0;
-}
-
-lldb_private::ConstString
-lldb_private::Type::GetClangTypeName (void *clang_type)
-{
- ConstString clang_type_name;
- if (clang_type)
- {
- clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
-
- const clang::TypedefType *typedef_type = qual_type->getAs<clang::TypedefType>();
- if (typedef_type)
- {
- const clang::TypedefDecl *typedef_decl = typedef_type->getDecl();
- std::string clang_typedef_name (typedef_decl->getQualifiedNameAsString());
- if (!clang_typedef_name.empty())
- clang_type_name.SetCString (clang_typedef_name.c_str());
- }
- else
- {
- std::string type_name(qual_type.getAsString());
- if (!type_name.empty())
- clang_type_name.SetCString (type_name.c_str());
- }
- }
- else
- {
- clang_type_name.SetCString ("<invalid>");
- }
-
- return clang_type_name;
-}
-
-
-
void
lldb_private::Type::DumpTypeName(Stream *s)
{
@@ -354,658 +302,23 @@ lldb_private::Type::DumpValue
s->PutCString(") ");
}
- lldb_private::Type::DumpValue (exe_ctx,
- GetClangAST (),
- m_clang_qual_type,
- s,
- format == lldb::eFormatDefault ? GetFormat() : format,
- data,
- data_byte_offset,
- GetByteSize(),
- 0, // Bitfield bit size
- 0, // Bitfield bit offset
- show_types,
- show_summary,
- verbose,
- 0);
- }
-}
-
-
-void
-lldb_private::Type::DumpSummary
-(
- ExecutionContext *exe_ctx,
- clang::ASTContext *ast_context,
- void *clang_type,
- Stream *s,
- const lldb_private::DataExtractor &data,
- uint32_t data_byte_offset,
- size_t data_byte_size
-)
-{
- uint32_t length = 0;
- clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
- if (ClangASTContext::IsCStringType (clang_type, length))
- {
-
- if (exe_ctx && exe_ctx->process)
- {
- uint32_t offset = data_byte_offset;
- lldb::addr_t pointer_addresss = data.GetMaxU64(&offset, data_byte_size);
- std::vector<uint8_t> buf;
- if (length > 0)
- buf.resize (length);
- else
- buf.resize (256);
-
- lldb_private::DataExtractor cstr_data(&buf.front(), buf.size(), exe_ctx->process->GetByteOrder(), 4);
- buf.back() = '\0';
- size_t bytes_read;
- size_t total_cstr_len = 0;
- Error error;
- while ((bytes_read = exe_ctx->process->ReadMemory (pointer_addresss, &buf.front(), buf.size(), error)) > 0)
- {
- const size_t len = strlen((const char *)&buf.front());
- if (len == 0)
- break;
- if (total_cstr_len == 0)
- s->PutCString (" \"");
- cstr_data.Dump(s, 0, lldb::eFormatChar, 1, len, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
- total_cstr_len += len;
- if (len < buf.size())
- break;
- pointer_addresss += total_cstr_len;
- }
- if (total_cstr_len > 0)
- s->PutChar ('"');
- }
- }
-}
-
-#define DEPTH_INCREMENT 2
-void
-lldb_private::Type::DumpValue
-(
- ExecutionContext *exe_ctx,
- clang::ASTContext *ast_context,
- void *clang_type,
- Stream *s,
- lldb::Format format,
- const lldb_private::DataExtractor &data,
- uint32_t data_byte_offset,
- size_t data_byte_size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- bool show_types,
- bool show_summary,
- bool verbose,
- uint32_t depth
-)
-{
- clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
- switch (qual_type->getTypeClass())
- {
- case clang::Type::Record:
- {
- const clang::RecordType *record_type = cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- assert(record_decl);
- uint32_t field_bit_offset = 0;
- uint32_t field_byte_offset = 0;
- const clang::ASTRecordLayout &record_layout = ast_context->getASTRecordLayout(record_decl);
- uint32_t child_idx = 0;
-
-
- const clang::CXXRecordDecl *cxx_record_decl = dyn_cast<clang::CXXRecordDecl>(record_decl);
- if (cxx_record_decl)
- {
- // We might have base classes to print out first
- clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
- for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
- base_class != base_class_end;
- ++base_class)
- {
- const clang::CXXRecordDecl *base_class_decl = cast<clang::CXXRecordDecl>(base_class->getType()->getAs<clang::RecordType>()->getDecl());
-
- // Skip empty base classes
- if (verbose == false && ClangASTContext::RecordHasFields(base_class_decl) == false)
- continue;
-
- if (base_class->isVirtual())
- field_bit_offset = record_layout.getVBaseClassOffset(base_class_decl);
- else
- field_bit_offset = record_layout.getBaseClassOffset(base_class_decl);
- field_byte_offset = field_bit_offset / 8;
- assert (field_bit_offset % 8 == 0);
- if (child_idx == 0)
- s->PutChar('{');
- else
- s->PutChar(',');
-
- clang::QualType base_class_qual_type = base_class->getType();
- std::string base_class_type_name(base_class_qual_type.getAsString());
-
- // Indent and print the base class type name
- s->Printf("\n%*s%s ", depth + DEPTH_INCREMENT, "", base_class_type_name.c_str());
-
- std::pair<uint64_t, unsigned> base_class_type_info = ast_context->getTypeInfo(base_class_qual_type);
-
- // Dump the value of the member
- Type::DumpValue (
- exe_ctx,
- ast_context, // The clang AST context for this type
- base_class_qual_type.getAsOpaquePtr(),// The clang type we want to dump
- s, // Stream to dump to
- Type::GetFormat(base_class_qual_type.getAsOpaquePtr()), // The format with which to display the member
- data, // Data buffer containing all bytes for this type
- data_byte_offset + field_byte_offset,// Offset into "data" where to grab value from
- base_class_type_info.first / 8, // Size of this type in bytes
- 0, // Bitfield bit size
- 0, // Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable types
- show_summary, // Boolean indicating if we should show a summary for the current type
- verbose, // Verbose output?
- depth + DEPTH_INCREMENT); // Scope depth for any types that have children
-
- ++child_idx;
- }
- }
- uint32_t field_idx = 0;
- clang::RecordDecl::field_iterator field, field_end;
- for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx, ++child_idx)
- {
- // Print the starting squiggly bracket (if this is the
- // first member) or comman (for member 2 and beyong) for
- // the struct/union/class member.
- if (child_idx == 0)
- s->PutChar('{');
- else
- s->PutChar(',');
-
- // Indent
- s->Printf("\n%*s", depth + DEPTH_INCREMENT, "");
-
- clang::QualType field_type = field->getType();
- // Print the member type if requested
- // Figure out the type byte size (field_type_info.first) and
- // alignment (field_type_info.second) from the AST context.
- std::pair<uint64_t, unsigned> field_type_info = ast_context->getTypeInfo(field_type);
- assert(field_idx < record_layout.getFieldCount());
- // Figure out the field offset within the current struct/union/class type
- field_bit_offset = record_layout.getFieldOffset (field_idx);
- field_byte_offset = field_bit_offset / 8;
- uint32_t field_bitfield_bit_size = 0;
- uint32_t field_bitfield_bit_offset = 0;
- if (ClangASTContext::FieldIsBitfield (ast_context, *field, field_bitfield_bit_size))
- field_bitfield_bit_offset = field_bit_offset % 8;
-
- if (show_types)
- {
- std::string field_type_name(field_type.getAsString());
- if (field_bitfield_bit_size > 0)
- s->Printf("(%s:%u) ", field_type_name.c_str(), field_bitfield_bit_size);
- else
- s->Printf("(%s) ", field_type_name.c_str());
- }
- // Print the member name and equal sign
- s->Printf("%s = ", field->getNameAsString().c_str());
-
-
- // Dump the value of the member
- Type::DumpValue (
- exe_ctx,
- ast_context, // The clang AST context for this type
- field_type.getAsOpaquePtr(), // The clang type we want to dump
- s, // Stream to dump to
- Type::GetFormat(field_type.getAsOpaquePtr()), // The format with which to display the member
- data, // Data buffer containing all bytes for this type
- data_byte_offset + field_byte_offset,// Offset into "data" where to grab value from
- field_type_info.first / 8, // Size of this type in bytes
- field_bitfield_bit_size, // Bitfield bit size
- field_bitfield_bit_offset, // Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable types
- show_summary, // Boolean indicating if we should show a summary for the current type
- verbose, // Verbose output?
- depth + DEPTH_INCREMENT); // Scope depth for any types that have children
- }
-
- // Indent the trailing squiggly bracket
- if (child_idx > 0)
- s->Printf("\n%*s}", depth, "");
- }
- return;
-
- case clang::Type::Enum:
- {
- const clang::EnumType *enum_type = cast<clang::EnumType>(qual_type.getTypePtr());
- const clang::EnumDecl *enum_decl = enum_type->getDecl();
- assert(enum_decl);
- clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
- uint32_t offset = data_byte_offset;
- const int64_t enum_value = data.GetMaxU64Bitfield(&offset, data_byte_size, bitfield_bit_size, bitfield_bit_offset);
- for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos)
- {
- if (enum_pos->getInitVal() == enum_value)
- {
- s->Printf("%s", enum_pos->getNameAsCString());
- return;
- }
- }
- // If we have gotten here we didn't get find the enumerator in the
- // enum decl, so just print the integer.
- s->Printf("%lli", enum_value);
- }
- return;
-
- case clang::Type::ConstantArray:
- {
- const clang::ConstantArrayType *array = cast<clang::ConstantArrayType>(qual_type.getTypePtr());
- bool is_array_of_characters = false;
- clang::QualType element_qual_type = array->getElementType();
-
- clang::Type *canonical_type = element_qual_type->getCanonicalTypeInternal().getTypePtr();
- if (canonical_type)
- is_array_of_characters = canonical_type->isCharType();
-
- const uint64_t element_count = array->getSize().getLimitedValue();
-
- std::pair<uint64_t, unsigned> field_type_info = ast_context->getTypeInfo(element_qual_type);
-
- uint32_t element_idx = 0;
- uint32_t element_offset = 0;
- uint64_t element_byte_size = field_type_info.first / 8;
- uint32_t element_stride = element_byte_size;
-
- if (is_array_of_characters)
- {
- s->PutChar('"');
- data.Dump(s, data_byte_offset, lldb::eFormatChar, element_byte_size, element_count, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('"');
- return;
- }
- else
- {
- lldb::Format element_format = Type::GetFormat(element_qual_type.getAsOpaquePtr());
-
- for (element_idx = 0; element_idx < element_count; ++element_idx)
- {
- // Print the starting squiggly bracket (if this is the
- // first member) or comman (for member 2 and beyong) for
- // the struct/union/class member.
- if (element_idx == 0)
- s->PutChar('{');
- else
- s->PutChar(',');
-
- // Indent and print the index
- s->Printf("\n%*s[%u] ", depth + DEPTH_INCREMENT, "", element_idx);
-
- // Figure out the field offset within the current struct/union/class type
- element_offset = element_idx * element_stride;
-
- // Dump the value of the member
- Type::DumpValue (
- exe_ctx,
- ast_context, // The clang AST context for this type
- element_qual_type.getAsOpaquePtr(), // The clang type we want to dump
- s, // Stream to dump to
- element_format, // The format with which to display the element
- data, // Data buffer containing all bytes for this type
- data_byte_offset + element_offset,// Offset into "data" where to grab value from
- element_byte_size, // Size of this type in bytes
- 0, // Bitfield bit size
- 0, // Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable types
- show_summary, // Boolean indicating if we should show a summary for the current type
- verbose, // Verbose output?
- depth + DEPTH_INCREMENT); // Scope depth for any types that have children
- }
-
- // Indent the trailing squiggly bracket
- if (element_idx > 0)
- s->Printf("\n%*s}", depth, "");
- }
- }
- return;
-
- case clang::Type::Typedef:
- {
- clang::QualType typedef_qual_type = cast<clang::TypedefType>(qual_type)->LookThroughTypedefs();
- lldb::Format typedef_format = lldb_private::Type::GetFormat(typedef_qual_type.getAsOpaquePtr());
- std::pair<uint64_t, unsigned> typedef_type_info = ast_context->getTypeInfo(typedef_qual_type);
- uint64_t typedef_byte_size = typedef_type_info.first / 8;
-
- return Type::DumpValue(
- exe_ctx,
- ast_context, // The clang AST context for this type
- typedef_qual_type.getAsOpaquePtr(), // The clang type we want to dump
- s, // Stream to dump to
- typedef_format, // The format with which to display the element
- data, // Data buffer containing all bytes for this type
- data_byte_offset, // Offset into "data" where to grab value from
- typedef_byte_size, // Size of this type in bytes
- bitfield_bit_size, // Bitfield bit size
- bitfield_bit_offset,// Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable types
- show_summary, // Boolean indicating if we should show a summary for the current type
- verbose, // Verbose output?
- depth); // Scope depth for any types that have children
- }
- break;
-
- default:
- // We are down the a scalar type that we just need to display.
- data.Dump(s, data_byte_offset, format, data_byte_size, 1, UINT32_MAX, LLDB_INVALID_ADDRESS, bitfield_bit_size, bitfield_bit_offset);
-
- if (show_summary)
- Type::DumpSummary (exe_ctx, ast_context, clang_type, s, data, data_byte_offset, data_byte_size);
- break;
- }
-}
-
-bool
-lldb_private::Type::DumpTypeValue
-(
- Stream *s,
- clang::ASTContext *ast_context,
- void *clang_type,
- lldb::Format format,
- const lldb_private::DataExtractor &data,
- uint32_t byte_offset,
- size_t byte_size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset
-)
-{
- clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
- if (ClangASTContext::IsAggregateType (clang_type))
- {
- return 0;
- }
- else
- {
- switch (qual_type->getTypeClass())
- {
- case clang::Type::Enum:
- {
- const clang::EnumType *enum_type = cast<clang::EnumType>(qual_type.getTypePtr());
- const clang::EnumDecl *enum_decl = enum_type->getDecl();
- assert(enum_decl);
- clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
- uint32_t offset = byte_offset;
- const int64_t enum_value = data.GetMaxU64Bitfield (&offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
- for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos)
- {
- if (enum_pos->getInitVal() == enum_value)
- {
- s->PutCString (enum_pos->getNameAsCString());
- return true;
- }
- }
- // If we have gotten here we didn't get find the enumerator in the
- // enum decl, so just print the integer.
-
- s->Printf("%lli", enum_value);
- return true;
- }
- break;
-
- case clang::Type::Typedef:
- {
- clang::QualType typedef_qual_type = cast<clang::TypedefType>(qual_type)->LookThroughTypedefs();
- lldb::Format typedef_format = Type::GetFormat(typedef_qual_type.getAsOpaquePtr());
- std::pair<uint64_t, unsigned> typedef_type_info = ast_context->getTypeInfo(typedef_qual_type);
- uint64_t typedef_byte_size = typedef_type_info.first / 8;
-
- return Type::DumpTypeValue(
- s,
- ast_context, // The clang AST context for this type
- typedef_qual_type.getAsOpaquePtr(), // The clang type we want to dump
- typedef_format, // The format with which to display the element
- data, // Data buffer containing all bytes for this type
- byte_offset, // Offset into "data" where to grab value from
- typedef_byte_size, // Size of this type in bytes
- bitfield_bit_size, // Size in bits of a bitfield value, if zero don't treat as a bitfield
- bitfield_bit_offset); // Offset in bits of a bitfield value if bitfield_bit_size != 0
- }
- break;
-
- default:
- // We are down the a scalar type that we just need to display.
- return data.Dump(s,
- byte_offset,
- format,
- byte_size,
- 1,
- UINT32_MAX,
- LLDB_INVALID_ADDRESS,
- bitfield_bit_size,
- bitfield_bit_offset);
- break;
- }
- }
- return 0;
-}
-
-bool
-lldb_private::Type::GetValueAsScalar
-(
- clang::ASTContext *ast_context,
- void *clang_type,
- const lldb_private::DataExtractor &data,
- uint32_t data_byte_offset,
- size_t data_byte_size,
- Scalar &value
-)
-{
- clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
-
- if (ClangASTContext::IsAggregateType (clang_type))
- {
- return false; // Aggregate types don't have scalar values
- }
- else
- {
- uint32_t count = 0;
- lldb::Encoding encoding = Type::GetEncoding (clang_type, count);
-
- if (encoding == lldb::eEncodingInvalid || count != 1)
- return false;
-
- uint64_t bit_width = ast_context->getTypeSize(qual_type);
- uint32_t byte_size = (bit_width + 7 ) / 8;
- uint32_t offset = data_byte_offset;
- switch (encoding)
- {
- case lldb::eEncodingUint:
- if (byte_size <= sizeof(unsigned long long))
- {
- uint64_t uval64 = data.GetMaxU64 (&offset, byte_size);
- if (byte_size <= sizeof(unsigned int))
- {
- value = (unsigned int)uval64;
- return true;
- }
- else if (byte_size <= sizeof(unsigned long))
- {
- value = (unsigned long)uval64;
- return true;
- }
- else if (byte_size <= sizeof(unsigned long long))
- {
- value = (unsigned long long )uval64;
- return true;
- }
- else
- value.Clear();
- }
- break;
-
- case lldb::eEncodingSint:
- if (byte_size <= sizeof(long long))
- {
- int64_t sval64 = (int64_t)data.GetMaxU64 (&offset, byte_size);
- if (byte_size <= sizeof(int))
- {
- value = (int)sval64;
- return true;
- }
- else if (byte_size <= sizeof(long))
- {
- value = (long)sval64;
- return true;
- }
- else if (byte_size <= sizeof(long long))
- {
- value = (long long )sval64;
- return true;
- }
- else
- value.Clear();
- }
- break;
-
- case lldb::eEncodingIEEE754:
- if (byte_size <= sizeof(long double))
- {
- uint32_t u32;
- uint64_t u64;
- if (byte_size == sizeof(float))
- {
- if (sizeof(float) == sizeof(uint32_t))
- {
- u32 = data.GetU32(&offset);
- value = *((float *)&u32);
- return true;
- }
- else if (sizeof(float) == sizeof(uint64_t))
- {
- u64 = data.GetU64(&offset);
- value = *((float *)&u64);
- return true;
- }
- }
- else
- if (byte_size == sizeof(double))
- {
- if (sizeof(double) == sizeof(uint32_t))
- {
- u32 = data.GetU32(&offset);
- value = *((double *)&u32);
- return true;
- }
- else if (sizeof(double) == sizeof(uint64_t))
- {
- u64 = data.GetU64(&offset);
- value = *((double *)&u64);
- return true;
- }
- }
- else
- if (byte_size == sizeof(long double))
- {
- if (sizeof(long double) == sizeof(uint32_t))
- {
- u32 = data.GetU32(&offset);
- value = *((long double *)&u32);
- return true;
- }
- else if (sizeof(long double) == sizeof(uint64_t))
- {
- u64 = data.GetU64(&offset);
- value = *((long double *)&u64);
- return true;
- }
- }
- }
- break;
- }
- }
- return false;
-}
-
-bool
-lldb_private::Type::SetValueFromScalar
-(
- clang::ASTContext *ast_context,
- void *clang_type,
- const Scalar &value,
- Stream &strm
-)
-{
- clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
-
- // Aggregate types don't have scalar values
- if (!ClangASTContext::IsAggregateType (clang_type))
- {
- strm.GetFlags().Set(Stream::eBinary);
- uint32_t count = 0;
- lldb::Encoding encoding = Type::GetEncoding (clang_type, count);
-
- if (encoding == lldb::eEncodingInvalid || count != 1)
- return false;
-
- uint64_t bit_width = ast_context->getTypeSize(qual_type);
- // This function doesn't currently handle non-byte aligned assignments
- if ((bit_width % 8) != 0)
- return false;
-
- uint32_t byte_size = (bit_width + 7 ) / 8;
- switch (encoding)
- {
- case lldb::eEncodingUint:
- switch (byte_size)
- {
- case 1: strm.PutHex8(value.UInt()); return true;
- case 2: strm.PutHex16(value.UInt()); return true;
- case 4: strm.PutHex32(value.UInt()); return true;
- case 8: strm.PutHex64(value.ULongLong()); return true;
- default:
- break;
- }
- break;
-
- case lldb::eEncodingSint:
- switch (byte_size)
- {
- case 1: strm.PutHex8(value.SInt()); return true;
- case 2: strm.PutHex16(value.SInt()); return true;
- case 4: strm.PutHex32(value.SInt()); return true;
- case 8: strm.PutHex64(value.SLongLong()); return true;
- default:
- break;
- }
- break;
-
- case lldb::eEncodingIEEE754:
- if (byte_size <= sizeof(long double))
- {
- if (byte_size == sizeof(float))
- {
- strm.PutFloat(value.Float());
- return true;
- }
- else
- if (byte_size == sizeof(double))
- {
- strm.PutDouble(value.Double());
- return true;
- }
- else
- if (byte_size == sizeof(long double))
- {
- strm.PutDouble(value.LongDouble());
- return true;
- }
- }
- break;
- }
+ lldb_private::ClangASTType::DumpValue (GetClangAST (),
+ m_clang_qual_type,
+ exe_ctx,
+ s,
+ format == lldb::eFormatDefault ? GetFormat() : format,
+ data,
+ data_byte_offset,
+ GetByteSize(),
+ 0, // Bitfield bit size
+ 0, // Bitfield bit offset
+ show_types,
+ show_summary,
+ verbose,
+ 0);
}
- return false;
}
-
uint64_t
lldb_private::Type::GetByteSize()
{
@@ -1066,86 +379,10 @@ lldb_private::Type::GetFormat ()
// Make sure we resolve our type if it already hasn't been.
if (!ResolveClangType())
return lldb::eFormatInvalid;
- return lldb_private::Type::GetFormat (m_clang_qual_type);
+ return lldb_private::ClangASTType::GetFormat (m_clang_qual_type);
}
-lldb::Format
-lldb_private::Type::GetFormat (void *clang_type)
-{
- clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
-
- switch (qual_type->getTypeClass())
- {
- case clang::Type::FunctionNoProto:
- case clang::Type::FunctionProto:
- break;
-
- case clang::Type::IncompleteArray:
- case clang::Type::VariableArray:
- break;
-
- case clang::Type::ConstantArray:
- break;
-
- case clang::Type::ExtVector:
- case clang::Type::Vector:
- break;
-
- case clang::Type::Builtin:
- switch (cast<clang::BuiltinType>(qual_type)->getKind())
- {
- default: assert(0 && "Unknown builtin type!");
- case clang::BuiltinType::Void:
- break;
-
- case clang::BuiltinType::Bool: return lldb::eFormatBoolean;
- case clang::BuiltinType::Char_S:
- case clang::BuiltinType::SChar:
- case clang::BuiltinType::Char_U:
- case clang::BuiltinType::UChar:
- case clang::BuiltinType::WChar: return lldb::eFormatChar;
- case clang::BuiltinType::Char16: return lldb::eFormatUnicode16;
- case clang::BuiltinType::Char32: return lldb::eFormatUnicode32;
- case clang::BuiltinType::UShort: return lldb::eFormatHex;
- case clang::BuiltinType::Short: return lldb::eFormatDecimal;
- case clang::BuiltinType::UInt: return lldb::eFormatHex;
- case clang::BuiltinType::Int: return lldb::eFormatDecimal;
- case clang::BuiltinType::ULong: return lldb::eFormatHex;
- case clang::BuiltinType::Long: return lldb::eFormatDecimal;
- case clang::BuiltinType::ULongLong: return lldb::eFormatHex;
- case clang::BuiltinType::LongLong: return lldb::eFormatDecimal;
- case clang::BuiltinType::UInt128: return lldb::eFormatHex;
- case clang::BuiltinType::Int128: return lldb::eFormatDecimal;
- case clang::BuiltinType::Float: return lldb::eFormatFloat;
- case clang::BuiltinType::Double: return lldb::eFormatFloat;
- case clang::BuiltinType::LongDouble: return lldb::eFormatFloat;
- case clang::BuiltinType::NullPtr: return lldb::eFormatHex;
- }
- break;
- case clang::Type::ObjCObjectPointer: return lldb::eFormatHex;
- case clang::Type::BlockPointer: return lldb::eFormatHex;
- case clang::Type::Pointer: return lldb::eFormatHex;
- case clang::Type::LValueReference:
- case clang::Type::RValueReference: return lldb::eFormatHex;
- case clang::Type::MemberPointer: break;
- case clang::Type::Complex: return lldb::eFormatComplex;
- case clang::Type::ObjCInterface: break;
- case clang::Type::Record: break;
- case clang::Type::Enum: return lldb::eFormatEnum;
- case clang::Type::Typedef:
- return lldb_private::Type::GetFormat(cast<clang::TypedefType>(qual_type)->LookThroughTypedefs().getAsOpaquePtr());
-
- case clang::Type::TypeOfExpr:
- case clang::Type::TypeOf:
- case clang::Type::Decltype:
-// case clang::Type::QualifiedName:
- case clang::Type::TemplateSpecialization: break;
- }
- // We don't know hot to display this type...
- return lldb::eFormatBytes;
-}
-
lldb::Encoding
lldb_private::Type::GetEncoding (uint32_t &count)
@@ -1154,99 +391,10 @@ lldb_private::Type::GetEncoding (uint32_t &count)
if (!ResolveClangType())
return lldb::eEncodingInvalid;
- return Type::GetEncoding (m_clang_qual_type, count);
+ return lldb_private::ClangASTType::GetEncoding (m_clang_qual_type, count);
}
-lldb::Encoding
-lldb_private::Type::GetEncoding (void *clang_type, uint32_t &count)
-{
- count = 1;
- clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
-
- switch (qual_type->getTypeClass())
- {
- case clang::Type::FunctionNoProto:
- case clang::Type::FunctionProto:
- break;
-
- case clang::Type::IncompleteArray:
- case clang::Type::VariableArray:
- break;
-
- case clang::Type::ConstantArray:
- break;
-
- case clang::Type::ExtVector:
- case clang::Type::Vector:
- // TODO: Set this to more than one???
- break;
-
- case clang::Type::Builtin:
- switch (cast<clang::BuiltinType>(qual_type)->getKind())
- {
- default: assert(0 && "Unknown builtin type!");
- case clang::BuiltinType::Void:
- break;
-
- case clang::BuiltinType::Bool:
- case clang::BuiltinType::Char_S:
- case clang::BuiltinType::SChar:
- case clang::BuiltinType::WChar:
- case clang::BuiltinType::Char16:
- case clang::BuiltinType::Char32:
- case clang::BuiltinType::Short:
- case clang::BuiltinType::Int:
- case clang::BuiltinType::Long:
- case clang::BuiltinType::LongLong:
- case clang::BuiltinType::Int128: return lldb::eEncodingSint;
-
- case clang::BuiltinType::Char_U:
- case clang::BuiltinType::UChar:
- case clang::BuiltinType::UShort:
- case clang::BuiltinType::UInt:
- case clang::BuiltinType::ULong:
- case clang::BuiltinType::ULongLong:
- case clang::BuiltinType::UInt128: return lldb::eEncodingUint;
-
- case clang::BuiltinType::Float:
- case clang::BuiltinType::Double:
- case clang::BuiltinType::LongDouble: return lldb::eEncodingIEEE754;
-
- case clang::BuiltinType::NullPtr: return lldb::eEncodingUint;
- }
- break;
- // All pointer types are represented as unsigned integer encodings.
- // We may nee to add a eEncodingPointer if we ever need to know the
- // difference
- case clang::Type::ObjCObjectPointer:
- case clang::Type::BlockPointer:
- case clang::Type::Pointer:
- case clang::Type::LValueReference:
- case clang::Type::RValueReference:
- case clang::Type::MemberPointer: return lldb::eEncodingUint;
- // Complex numbers are made up of floats
- case clang::Type::Complex:
- count = 2;
- return lldb::eEncodingIEEE754;
-
- case clang::Type::ObjCInterface: break;
- case clang::Type::Record: break;
- case clang::Type::Enum: return lldb::eEncodingSint;
- case clang::Type::Typedef:
- return Type::GetEncoding(cast<clang::TypedefType>(qual_type)->LookThroughTypedefs().getAsOpaquePtr(), count);
- break;
-
- case clang::Type::TypeOfExpr:
- case clang::Type::TypeOf:
- case clang::Type::Decltype:
-// case clang::Type::QualifiedName:
- case clang::Type::TemplateSpecialization: break;
- }
- count = 0;
- return lldb::eEncodingInvalid;
-}
-
bool
lldb_private::Type::DumpValueInMemory
@@ -1273,93 +421,6 @@ lldb_private::Type::DumpValueInMemory
return false;
}
-bool
-lldb_private::Type::ReadFromMemory
-(
- lldb_private::ExecutionContext *exe_ctx,
- clang::ASTContext *ast_context,
- void *clang_type,
- lldb::addr_t addr,
- lldb::AddressType address_type,
- lldb_private::DataExtractor &data
-)
-{
- if (address_type == lldb::eAddressTypeFile)
- {
- // Can't convert a file address to anything valid without more
- // context (which Module it came from)
- return false;
- }
- clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
-
- const uint32_t byte_size = (ast_context->getTypeSize (qual_type) + 7) / 8;
- if (data.GetByteSize() < byte_size)
- {
- lldb::DataBufferSP data_sp(new DataBufferHeap (byte_size, '\0'));
- data.SetData(data_sp);
- }
-
- uint8_t* dst = (uint8_t*)data.PeekData(0, byte_size);
- if (dst != NULL)
- {
- if (address_type == lldb::eAddressTypeHost)
- {
- // The address is an address in this process, so just copy it
- memcpy (dst, (uint8_t*)NULL + addr, byte_size);
- return true;
- }
- else
- {
- if (exe_ctx && exe_ctx->process)
- {
- Error error;
- return exe_ctx->process->ReadMemory(addr, dst, byte_size, error) == byte_size;
- }
- }
- }
- return false;
-}
-
-bool
-lldb_private::Type::WriteToMemory
-(
- lldb_private::ExecutionContext *exe_ctx,
- clang::ASTContext *ast_context,
- void *clang_type,
- lldb::addr_t addr,
- lldb::AddressType address_type,
- StreamString &new_value
-)
-{
- if (address_type == lldb::eAddressTypeFile)
- {
- // Can't convert a file address to anything valid without more
- // context (which Module it came from)
- return false;
- }
- clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
- const uint32_t byte_size = (ast_context->getTypeSize (qual_type) + 7) / 8;
-
- if (byte_size > 0)
- {
- if (address_type == lldb::eAddressTypeHost)
- {
- // The address is an address in this process, so just copy it
- memcpy ((void *)addr, new_value.GetData(), byte_size);
- return true;
- }
- else
- {
- if (exe_ctx && exe_ctx->process)
- {
- Error error;
- return exe_ctx->process->WriteMemory(addr, new_value.GetData(), byte_size, error) == byte_size;
- }
- }
- }
- return false;
-}
-
bool
lldb_private::Type::ReadFromMemory (lldb_private::ExecutionContext *exe_ctx, lldb::addr_t addr, lldb::AddressType address_type, lldb_private::DataExtractor &data)
OpenPOWER on IntegriCloud