Public API changes:
- Completely new implementation of SBType
- Various enhancements in several other classes
Python synthetic children providers for std::vector<T>, std::list<T> and std::map<K,V>:
- these return the actual elements into the container as the children of the container
- basic template name parsing that works (hopefully) on both Clang and GCC
- find them in examples/synthetic and in the test suite in functionalities/data-formatter/data-formatter-python-synth
New summary string token ${svar :
- the syntax is just the same as in ${var but this new token lets you read the values
coming from the synthetic children provider instead of the actual children
- Python providers above provide a synthetic child len that returns the number of elements
into the container
Full bug fix for the issue in which getting byte size for a non-complete type would crash LLDB
Several other fixes, including:
- inverted the order of arguments in the ClangASTType constructor
- EvaluationPoint now only returns SharedPointer's to Target and Process
- the help text for several type subcommands now correctly indicates argument-less options as such
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@136504 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBCommandInterpreter.cpp b/source/API/SBCommandInterpreter.cpp
index 1124d56..30fc171 100644
--- a/source/API/SBCommandInterpreter.cpp
+++ b/source/API/SBCommandInterpreter.cpp
@@ -331,10 +331,11 @@
);
-extern "C" uint32_t LLDBSwigPython_CalculateNumChildren (void *implementor);
-extern "C" void* LLDBSwigPython_GetChildAtIndex (void *implementor, uint32_t idx);
-extern "C" int LLDBSwigPython_GetIndexOfChildWithName (void *implementor, const char* child_name);
-extern "C" lldb::SBValue* LLDBSWIGPython_CastPyObjectToSBValue (void* data);
+extern "C" uint32_t LLDBSwigPython_CalculateNumChildren (void *implementor);
+extern "C" void* LLDBSwigPython_GetChildAtIndex (void *implementor, uint32_t idx);
+extern "C" int LLDBSwigPython_GetIndexOfChildWithName (void *implementor, const char* child_name);
+extern "C" lldb::SBValue* LLDBSWIGPython_CastPyObjectToSBValue (void* data);
+extern "C" void LLDBSwigPython_UpdateSynthProviderInstance (void* implementor);
extern "C" void init_lldb(void);
@@ -352,6 +353,7 @@
LLDBSwigPython_CalculateNumChildren,
LLDBSwigPython_GetChildAtIndex,
LLDBSwigPython_GetIndexOfChildWithName,
- LLDBSWIGPython_CastPyObjectToSBValue);
+ LLDBSWIGPython_CastPyObjectToSBValue,
+ LLDBSwigPython_UpdateSynthProviderInstance);
}
}
diff --git a/source/API/SBModule.cpp b/source/API/SBModule.cpp
index 852952a..faeb5e9 100644
--- a/source/API/SBModule.cpp
+++ b/source/API/SBModule.cpp
@@ -17,6 +17,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Target.h"
@@ -342,3 +343,59 @@
return sb_value_list;
}
+
+lldb::SBType
+SBModule::FindFirstType (const char* name_cstr)
+{
+ if (!IsValid())
+ return lldb::SBType();
+
+ SymbolContext sc;
+ TypeList type_list;
+ uint32_t num_matches = 0;
+ ConstString name(name_cstr);
+
+ num_matches = m_opaque_sp->FindTypes(sc,
+ name,
+ false,
+ 1,
+ type_list);
+
+ if (num_matches)
+ {
+ TypeSP type_sp (type_list.GetTypeAtIndex(0));
+ return lldb::SBType(type_sp);
+ }
+ else
+ return lldb::SBType();
+}
+
+lldb::SBTypeList
+SBModule::FindTypes (const char* type)
+{
+
+ SBTypeList retval;
+
+ if (!IsValid())
+ return retval;
+
+ SymbolContext sc;
+ TypeList type_list;
+ uint32_t num_matches = 0;
+ ConstString name(type);
+
+ num_matches = m_opaque_sp->FindTypes(sc,
+ name,
+ false,
+ UINT32_MAX,
+ type_list);
+
+ for (size_t idx = 0; idx < num_matches; idx++)
+ {
+ TypeSP sp_at_idx = type_list.GetTypeAtIndex(idx);
+
+ retval.AppendType(SBType(sp_at_idx));
+ }
+
+ return retval;
+}
\ No newline at end of file
diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp
index 2250440..82da45a 100644
--- a/source/API/SBTarget.cpp
+++ b/source/API/SBTarget.cpp
@@ -38,6 +38,7 @@
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
@@ -879,6 +880,52 @@
return 0;
}
+lldb::SBType
+SBTarget::FindFirstType (const char* type)
+{
+ if (m_opaque_sp)
+ {
+ size_t count = m_opaque_sp->GetImages().GetSize();
+ for (size_t idx = 0; idx < count; idx++)
+ {
+ SBType found_at_idx = GetModuleAtIndex(idx).FindFirstType(type);
+
+ if (found_at_idx.IsValid())
+ return found_at_idx;
+ }
+ }
+ return SBType();
+}
+
+lldb::SBTypeList
+SBTarget::FindTypes (const char* type)
+{
+
+ SBTypeList retval;
+
+ if (m_opaque_sp)
+ {
+ ModuleList& images = m_opaque_sp->GetImages();
+ ConstString name_const(type);
+ SymbolContext sc;
+ TypeList type_list;
+
+ uint32_t num_matches = images.FindTypes(sc,
+ name_const,
+ true,
+ UINT32_MAX,
+ type_list);
+
+ for (size_t idx = 0; idx < num_matches; idx++)
+ {
+ TypeSP sp_at_idx = type_list.GetTypeAtIndex(idx);
+
+ retval.AppendType(SBType(sp_at_idx));
+ }
+ }
+ return retval;
+}
+
SBValueList
SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches)
{
diff --git a/source/API/SBType.cpp b/source/API/SBType.cpp
index 647a20c..b17dd8a 100644
--- a/source/API/SBType.cpp
+++ b/source/API/SBType.cpp
@@ -9,6 +9,12 @@
#include <string.h>
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/TemplateBase.h"
+#include "clang/AST/Type.h"
+
+#include "lldb/API/SBDefines.h"
+
#include "lldb/API/SBType.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/ConstString.h"
@@ -18,334 +24,340 @@
using namespace lldb;
using namespace lldb_private;
+using namespace clang;
+SBType::SBType (lldb_private::ClangASTType type) :
+m_opaque_ap(new TypeImpl(ClangASTType(type.GetASTContext(),
+ type.GetOpaqueQualType())))
+{
+}
+
+SBType::SBType (lldb::TypeSP type) :
+m_opaque_ap(new TypeImpl(type))
+{}
+
+SBType::SBType (const SBType &rhs)
+{
+ if (rhs.m_opaque_ap.get() != NULL)
+ {
+ m_opaque_ap = std::auto_ptr<TypeImpl>(new TypeImpl(ClangASTType(rhs.m_opaque_ap->GetASTContext(),
+ rhs.m_opaque_ap->GetOpaqueQualType())));
+ }
+}
+
+SBType::SBType (clang::ASTContext *ctx, clang_type_t ty) :
+m_opaque_ap(new TypeImpl(ClangASTType(ctx, ty)))
+{
+}
+
+SBType::SBType() :
+m_opaque_ap(NULL)
+{
+}
+
+SBType::SBType (TypeImpl impl) :
+m_opaque_ap(&impl)
+{}
bool
-SBType::IsPointerType (void *opaque_type)
+SBType::operator == (const lldb::SBType &rhs) const
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- //if (log)
- // log->Printf ("SBType::IsPointerType (%p)", opaque_type);
+ if (IsValid() == false)
+ return !rhs.IsValid();
- bool ret_value = ClangASTContext::IsPointerType (opaque_type);
+ return (rhs.m_opaque_ap->GetASTContext() == m_opaque_ap->GetASTContext())
+ &&
+ (rhs.m_opaque_ap->GetOpaqueQualType() == m_opaque_ap->GetOpaqueQualType());
+}
- if (log)
- log->Printf ("SBType::IsPointerType (opaque_type=%p) ==> '%s'", opaque_type, (ret_value ? "true" : "false"));
+bool
+SBType::operator != (const lldb::SBType &rhs) const
+{
+ if (IsValid() == false)
+ return rhs.IsValid();
- return ret_value;
+ return (rhs.m_opaque_ap->GetASTContext() != m_opaque_ap->GetASTContext())
+ ||
+ (rhs.m_opaque_ap->GetOpaqueQualType() != m_opaque_ap->GetOpaqueQualType());
}
-SBType::SBType (void *ast, void *clang_type) :
- m_ast (ast),
- m_type (clang_type)
+const lldb::SBType &
+SBType::operator = (const lldb::SBType &rhs)
{
-}
-
-SBType::SBType (const SBType &rhs) :
- m_ast (rhs.m_ast),
- m_type (rhs.m_type)
-{
-}
-
-const SBType &
-SBType::operator =(const SBType &rhs)
-{
- m_ast = rhs.m_ast;
- m_type = rhs.m_type;
+ if (*this != rhs)
+ {
+ if (!rhs.IsValid())
+ m_opaque_ap.reset(NULL);
+ else
+ m_opaque_ap = std::auto_ptr<TypeImpl>(new TypeImpl(ClangASTType(rhs.m_opaque_ap->GetASTContext(),
+ rhs.m_opaque_ap->GetOpaqueQualType())));
+ }
return *this;
}
SBType::~SBType ()
+{}
+
+lldb_private::TypeImpl &
+SBType::ref ()
{
+ if (m_opaque_ap.get() == NULL)
+ m_opaque_ap.reset (new lldb_private::TypeImpl());
+ return *m_opaque_ap;
+}
+
+const lldb_private::TypeImpl &
+SBType::ref () const
+{
+ // "const SBAddress &addr" should already have checked "addr.IsValid()"
+ // prior to calling this function. In case you didn't we will assert
+ // and die to let you know.
+ assert (m_opaque_ap.get());
+ return *m_opaque_ap;
}
bool
-SBType::IsValid ()
+SBType::IsValid() const
{
- return m_ast != NULL && m_type != NULL;
-}
-
-const char *
-SBType::GetName ()
-{
- if (IsValid ())
- return ClangASTType::GetConstTypeName (m_type).AsCString(NULL);
- return NULL;
-}
-
-uint64_t
-SBType::GetByteSize()
-{
- if (IsValid ())
- return ClangASTType::GetClangTypeBitWidth (static_cast<clang::ASTContext *>(m_ast), m_type);
- return NULL;
-}
-
-Encoding
-SBType::GetEncoding (uint32_t &count)
-{
- if (IsValid ())
- return ClangASTType::GetEncoding (m_type, count);
- count = 0;
- return eEncodingInvalid;
-}
-
-uint64_t
-SBType::GetNumberChildren (bool omit_empty_base_classes)
-{
- if (IsValid ())
- return ClangASTContext::GetNumChildren (static_cast<clang::ASTContext *>(m_ast),
- m_type,
- omit_empty_base_classes);
- return 0;
-}
-
-
-bool
-SBType::GetChildAtIndex (bool omit_empty_base_classes, uint32_t idx, SBTypeMember &member)
-{
- void *child_clang_type = NULL;
- bool ignore_array_bounds = false;
- std::string child_name;
- uint32_t child_byte_size = 0;
- int32_t child_byte_offset = 0;
- uint32_t child_bitfield_bit_size = 0;
- uint32_t child_bitfield_bit_offset = 0;
- bool child_is_base_class = false;
- bool child_is_deref_of_parent = false;
-
- if (IsValid ())
- {
-
- child_clang_type = ClangASTContext::GetChildClangTypeAtIndex (NULL,
- static_cast<clang::ASTContext *>(m_ast),
- NULL,
- m_type,
- idx,
- false, // transparent pointers
- omit_empty_base_classes,
- ignore_array_bounds,
- child_name,
- child_byte_size,
- child_byte_offset,
- child_bitfield_bit_size,
- child_bitfield_bit_offset,
- child_is_base_class,
- child_is_deref_of_parent);
-
- }
+ if (m_opaque_ap.get() == NULL)
+ return false;
- if (child_clang_type)
- {
- member.m_ast = m_ast;
- member.m_parent_type = m_type;
- member.m_member_type = child_clang_type,
- member.SetName (child_name.c_str());
- member.m_offset = child_byte_offset;
- member.m_bit_size = child_bitfield_bit_size;
- member.m_bit_offset = child_bitfield_bit_offset;
- member.m_is_base_class = child_is_base_class;
- member.m_is_deref_of_paremt = child_is_deref_of_parent;
- }
- else
- {
- member.Clear();
- }
-
- return child_clang_type != NULL;
+ return m_opaque_ap->IsValid();
}
-uint32_t
-SBType::GetChildIndexForName (bool omit_empty_base_classes, const char *name)
+size_t
+SBType::GetByteSize() const
{
- return ClangASTContext::GetIndexOfChildWithName (static_cast<clang::ASTContext *>(m_ast),
- m_type,
- name,
- omit_empty_base_classes);
+ if (!IsValid())
+ return 0;
+
+ return ClangASTType::GetTypeByteSize(m_opaque_ap->GetASTContext(), m_opaque_ap->GetOpaqueQualType());
+
}
bool
-SBType::IsAPointerType ()
+SBType::IsPointerType() const
{
- return ClangASTContext::IsPointerType (m_type);
+ if (!IsValid())
+ return false;
+
+ QualType qt = QualType::getFromOpaquePtr(m_opaque_ap->GetOpaqueQualType());
+ const clang::Type* typePtr = qt.getTypePtrOrNull();
+
+ if (typePtr)
+ return typePtr->isAnyPointerType();
+ return false;
+}
+
+bool
+SBType::IsReferenceType() const
+{
+ if (!IsValid())
+ return false;
+
+ QualType qt = QualType::getFromOpaquePtr(m_opaque_ap->GetOpaqueQualType());
+ const clang::Type* typePtr = qt.getTypePtrOrNull();
+
+ if (typePtr)
+ return typePtr->isReferenceType();
+ return false;
}
SBType
-SBType::GetPointeeType ()
+SBType::GetPointerType() const
{
- void *pointee_type = NULL;
- if (IsAPointerType ())
- {
- pointee_type = ClangASTType::GetPointeeType (m_type);
- }
- return SBType (pointee_type ? m_ast : NULL, pointee_type);
+ if (!IsValid())
+ return SBType();
+
+ return SBType(m_opaque_ap->GetASTContext(),
+ ClangASTContext::CreatePointerType(m_opaque_ap->GetASTContext(), m_opaque_ap->GetOpaqueQualType()));
}
-bool
-SBType::GetDescription (SBStream &description)
+SBType
+SBType::GetPointeeType() const
{
- const char *name = GetName();
- uint64_t byte_size = GetByteSize();
- uint64_t num_children = GetNumberChildren (true);
- bool is_ptr = IsAPointerType ();
+ if (!IsValid())
+ return SBType();
- description.Printf ("type_name: %s, size: %d bytes", (name != NULL ? name : "<unknown type name>"), byte_size);
- if (is_ptr)
- {
- SBType pointee_type = GetPointeeType();
- const char *pointee_name = pointee_type.GetName();
- description.Printf (", (* %s)", (pointee_name != NULL ? pointee_name : "<unknown type name>"));
- }
- else if (num_children > 0)
- {
- description.Printf (", %d members:\n", num_children);
- for (uint32_t i = 0; i < num_children; ++i)
- {
- SBTypeMember field;
- GetChildAtIndex (true, i, field);
- const char *field_name = field.GetName();
- SBType field_type = field.GetType();
- const char *field_type_name = field_type.GetName();
-
- description.Printf (" %s (type: %s", (field_name != NULL ? field_name : "<unknown member name>"),
- (field_type_name != NULL ? field_type_name : "<unknown type name>"));
-
- if (field.IsBitfield())
- {
- size_t width = field.GetBitfieldWidth ();
- description.Printf (" , %d bits", (int) width);
- }
- description.Printf (")\n");
- }
- }
- return true;
-}
-
-SBTypeMember::SBTypeMember () :
- m_ast (NULL),
- m_parent_type (NULL),
- m_member_type (NULL),
- m_member_name (NULL),
- m_offset (0),
- m_bit_size (0),
- m_bit_offset (0),
- m_is_base_class (false)
+ QualType qt = QualType::getFromOpaquePtr(m_opaque_ap->GetOpaqueQualType());
+ const clang::Type* typePtr = qt.getTypePtrOrNull();
-{
+ if (typePtr)
+ return SBType(m_opaque_ap->GetASTContext(),typePtr->getPointeeType().getAsOpaquePtr());
+ return SBType();
}
-SBTypeMember::SBTypeMember (const SBTypeMember &rhs) :
- m_ast (rhs.m_ast),
- m_parent_type (rhs.m_parent_type),
- m_member_type (rhs.m_member_type),
- m_member_name (rhs.m_member_name),
- m_offset (rhs.m_offset),
- m_bit_size (rhs.m_bit_size),
- m_bit_offset (rhs.m_bit_offset),
- m_is_base_class (rhs.m_is_base_class)
+SBType
+SBType::GetReferenceType() const
{
+ if (!IsValid())
+ return SBType();
+
+ return SBType(m_opaque_ap->GetASTContext(),
+ ClangASTContext::CreateLValueReferenceType(m_opaque_ap->GetASTContext(), m_opaque_ap->GetOpaqueQualType()));
}
-const SBTypeMember&
-SBTypeMember::operator =(const SBTypeMember &rhs)
+SBType
+SBType::GetDereferencedType() const
{
- if (this != &rhs)
+ if (!IsValid())
+ return SBType();
+
+ QualType qt = QualType::getFromOpaquePtr(m_opaque_ap->GetOpaqueQualType());
+
+ return SBType(m_opaque_ap->GetASTContext(),qt.getNonReferenceType().getAsOpaquePtr());
+}
+
+SBType
+SBType::GetBasicType(lldb::BasicType type) const
+{
+
+ if (!IsValid())
+ return SBType();
+
+ clang::CanQualType base_type_qual;
+
+ switch (type)
{
- m_ast = rhs.m_ast;
- m_parent_type = rhs.m_parent_type;
- m_member_type = rhs.m_member_type;
- m_member_name = rhs.m_member_name;
- m_offset = rhs.m_offset;
- m_bit_size = rhs.m_bit_size;
- m_bit_offset = rhs.m_bit_offset;
- m_is_base_class = rhs.m_is_base_class;
+ case eBasicTypeChar:
+ base_type_qual = m_opaque_ap->GetASTContext()->CharTy;
+ break;
+ case eBasicTypeSignedChar:
+ base_type_qual = m_opaque_ap->GetASTContext()->SignedCharTy;
+ break;
+ case eBasicTypeShort:
+ base_type_qual = m_opaque_ap->GetASTContext()->ShortTy;
+ break;
+ case eBasicTypeUnsignedShort:
+ base_type_qual = m_opaque_ap->GetASTContext()->UnsignedShortTy;
+ break;
+ case eBasicTypeInt:
+ base_type_qual = m_opaque_ap->GetASTContext()->IntTy;
+ break;
+ case eBasicTypeUnsignedInt:
+ base_type_qual = m_opaque_ap->GetASTContext()->UnsignedIntTy;
+ break;
+ case eBasicTypeLong:
+ base_type_qual = m_opaque_ap->GetASTContext()->LongTy;
+ break;
+ case eBasicTypeUnsignedLong:
+ base_type_qual = m_opaque_ap->GetASTContext()->UnsignedLongTy;
+ break;
+ case eBasicTypeBool:
+ base_type_qual = m_opaque_ap->GetASTContext()->BoolTy;
+ break;
+ case eBasicTypeFloat:
+ base_type_qual = m_opaque_ap->GetASTContext()->FloatTy;
+ break;
+ case eBasicTypeDouble:
+ base_type_qual = m_opaque_ap->GetASTContext()->DoubleTy;
+ break;
+ case eBasicTypeObjCID:
+ base_type_qual = m_opaque_ap->GetASTContext()->ObjCBuiltinIdTy;
+ break;
+ case eBasicTypeVoid:
+ base_type_qual = m_opaque_ap->GetASTContext()->VoidTy;
+ break;
+ case eBasicTypeWChar:
+ base_type_qual = m_opaque_ap->GetASTContext()->WCharTy;
+ break;
+ case eBasicTypeChar16:
+ base_type_qual = m_opaque_ap->GetASTContext()->Char16Ty;
+ break;
+ case eBasicTypeChar32:
+ base_type_qual = m_opaque_ap->GetASTContext()->Char32Ty;
+ break;
+ case eBasicTypeLongLong:
+ base_type_qual = m_opaque_ap->GetASTContext()->LongLongTy;
+ break;
+ case eBasicTypeUnsignedLongLong:
+ base_type_qual = m_opaque_ap->GetASTContext()->UnsignedLongLongTy;
+ break;
+ case eBasicTypeInt128:
+ base_type_qual = m_opaque_ap->GetASTContext()->Int128Ty;
+ break;
+ case eBasicTypeUnsignedInt128:
+ base_type_qual = m_opaque_ap->GetASTContext()->UnsignedInt128Ty;
+ break;
+ case eBasicTypeLongDouble:
+ base_type_qual = m_opaque_ap->GetASTContext()->LongDoubleTy;
+ break;
+ case eBasicTypeFloatComplex:
+ base_type_qual = m_opaque_ap->GetASTContext()->FloatComplexTy;
+ break;
+ case eBasicTypeDoubleComplex:
+ base_type_qual = m_opaque_ap->GetASTContext()->DoubleComplexTy;
+ break;
+ case eBasicTypeLongDoubleComplex:
+ base_type_qual = m_opaque_ap->GetASTContext()->LongDoubleComplexTy;
+ break;
+ case eBasicTypeObjCClass:
+ base_type_qual = m_opaque_ap->GetASTContext()->ObjCBuiltinClassTy;
+ break;
+ case eBasicTypeObjCSel:
+ base_type_qual = m_opaque_ap->GetASTContext()->ObjCBuiltinSelTy;
+ break;
+ default:
+ return SBType();
+ }
+
+ return SBType(m_opaque_ap->GetASTContext(),
+ base_type_qual.getAsOpaquePtr());
+}
+
+const char*
+SBType::GetName()
+{
+ if (!IsValid())
+ return "";
+
+ return ClangASTType::GetConstTypeName(m_opaque_ap->GetOpaqueQualType()).GetCString();
+}
+
+SBTypeList::SBTypeList() :
+m_opaque_ap(new TypeListImpl())
+{
+}
+
+SBTypeList::SBTypeList(const SBTypeList& rhs) :
+m_opaque_ap(new TypeListImpl())
+{
+ for (int j = 0; j < rhs.GetSize(); j++)
+ AppendType(rhs.GetTypeAtIndex(j));
+}
+
+SBTypeList&
+SBTypeList::operator = (const SBTypeList& rhs)
+{
+ if (m_opaque_ap.get() != rhs.m_opaque_ap.get())
+ {
+ m_opaque_ap.reset(new TypeListImpl());
+ for (int j = 0; j < rhs.GetSize(); j++)
+ AppendType(rhs.GetTypeAtIndex(j));
}
return *this;
}
-SBTypeMember::~SBTypeMember ()
-{
- SetName (NULL);
-}
-
void
-SBTypeMember::SetName (const char *name)
+SBTypeList::AppendType(SBType type)
{
- if (m_member_name)
- free (m_member_name);
- if (name && name[0])
- m_member_name = ::strdup (name);
- else
- m_member_name = NULL;
-}
-
-void
-SBTypeMember::Clear()
-{
- m_ast = NULL;
- m_parent_type = NULL;
- m_member_type = NULL;
- SetName (NULL);
- m_offset = 0;
- m_bit_size = 0;
- m_bit_offset = 0;
- m_is_base_class = false;
-}
-
-bool
-SBTypeMember::IsValid ()
-{
- return m_member_type != NULL;
-}
-
-bool
-SBTypeMember::IsBitfield ()
-{
- return m_bit_size != 0;
-}
-
-size_t
-SBTypeMember::GetBitfieldWidth ()
-{
- return m_bit_size;
-}
-
-size_t
-SBTypeMember::GetBitfieldOffset ()
-{
- return m_bit_offset;
-}
-
-bool
-SBTypeMember::IsBaseClass ()
-{
- return m_is_base_class;
-}
-
-size_t
-SBTypeMember::GetOffset ()
-{
- return m_offset;
+ if (type.IsValid())
+ m_opaque_ap->AppendType(*type.m_opaque_ap.get());
}
SBType
-SBTypeMember::GetType()
+SBTypeList::GetTypeAtIndex(int index) const
{
- return SBType (m_ast, m_member_type);
+ return SBType(m_opaque_ap->GetTypeAtIndex(index));
}
-SBType
-SBTypeMember::GetParentType()
+int
+SBTypeList::GetSize() const
{
- return SBType (m_ast, m_parent_type);
+ return m_opaque_ap->GetSize();
}
-
-const char *
-SBTypeMember::GetName ()
+SBTypeList::~SBTypeList()
{
- return m_member_name;
-}
-
+}
\ No newline at end of file
diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp
index 2528f4c..229eba5 100644
--- a/source/API/SBValue.cpp
+++ b/source/API/SBValue.cpp
@@ -17,6 +17,7 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Variable.h"
@@ -156,9 +157,9 @@
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
result = m_opaque_sp->IsInScope ();
}
}
@@ -182,9 +183,9 @@
const char *cstr = NULL;
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
cstr = m_opaque_sp->GetValueAsCString ();
}
}
@@ -237,9 +238,9 @@
const char *cstr = NULL;
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
cstr = m_opaque_sp->GetObjectDescription ();
}
}
@@ -260,15 +261,39 @@
return GetValueDidChange ();
}
+SBType
+SBValue::GetType()
+{
+ SBType result;
+ if (m_opaque_sp)
+ {
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
+ result = SBType(m_opaque_sp->GetClangAST(),
+ m_opaque_sp->GetClangType());
+ }
+ }
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (log)
+ {
+ if (result.IsValid())
+ log->Printf ("SBValue(%p)::GetType => %p", m_opaque_sp.get(), &result);
+ else
+ log->Printf ("SBValue(%p)::GetType => NULL", m_opaque_sp.get());
+ }
+ return result;
+}
+
bool
SBValue::GetValueDidChange ()
{
bool result = false;
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
result = m_opaque_sp->GetValueDidChange ();
}
}
@@ -291,9 +316,9 @@
const char *cstr = NULL;
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
cstr = m_opaque_sp->GetSummaryAsCString();
}
}
@@ -320,9 +345,9 @@
const char *cstr = NULL;
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
cstr = m_opaque_sp->GetLocationAsCString();
}
}
@@ -349,22 +374,109 @@
bool success = false;
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
success = m_opaque_sp->SetValueFromCString (value_str);
}
}
return success;
}
+lldb::SBValue
+SBValue::CreateChildAtOffset (const char *name, uint32_t offset, const SBType& type)
+{
+ lldb::SBValue result;
+ if (m_opaque_sp)
+ {
+ if (type.IsValid())
+ {
+ result = SBValue(m_opaque_sp->GetSyntheticChildAtOffset(offset, *type.m_opaque_ap->GetClangASTType(), true));
+ result.m_opaque_sp->SetName(ConstString(name));
+ }
+ }
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (log)
+ {
+ if (result.IsValid())
+ log->Printf ("SBValue(%p)::GetChildAtOffset => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get());
+ else
+ log->Printf ("SBValue(%p)::GetChildAtOffset => NULL", m_opaque_sp.get());
+ }
+ return result;
+}
+
+lldb::SBValue
+SBValue::Cast(const SBType& type)
+{
+ return CreateChildAtOffset(m_opaque_sp->GetName().GetCString(), 0, type);
+}
+
+lldb::SBValue
+SBValue::CreateValueFromExpression (const char *name, const char* expression)
+{
+ lldb::SBValue result;
+ if (m_opaque_sp)
+ {
+ ValueObjectSP result_valobj_sp;
+ m_opaque_sp->GetUpdatePoint().GetTargetSP()->EvaluateExpression(expression,
+ m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame(),
+ true, true, eNoDynamicValues,
+ result_valobj_sp);
+ result_valobj_sp->SetName(ConstString(name));
+ result = SBValue(result_valobj_sp);
+ }
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (log)
+ {
+ if (result.IsValid())
+ log->Printf ("SBValue(%p)::GetChildFromExpression => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get());
+ else
+ log->Printf ("SBValue(%p)::GetChildFromExpression => NULL", m_opaque_sp.get());
+ }
+ return result;
+}
+
+lldb::SBValue
+SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, const SBType& type)
+{
+ lldb::SBValue result;
+ if (m_opaque_sp)
+ {
+
+ SBType real_type(type.GetPointerType());
+
+ lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t)));
+
+ ValueObjectSP result_valobj_sp(ValueObjectConstResult::Create(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope(),
+ real_type.m_opaque_ap->GetASTContext(),
+ real_type.m_opaque_ap->GetOpaqueQualType(),
+ ConstString(name),
+ buffer,
+ lldb::endian::InlHostByteOrder(),
+ GetTarget().GetProcess().GetAddressByteSize()));
+
+ result_valobj_sp->SetName(ConstString(name));
+ result = SBValue(result_valobj_sp);
+ }
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (log)
+ {
+ if (result.IsValid())
+ log->Printf ("SBValue(%p)::GetChildFromAddress => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get());
+ else
+ log->Printf ("SBValue(%p)::GetChildFromAddress => NULL", m_opaque_sp.get());
+ }
+ return result;
+}
+
SBValue
SBValue::GetChildAtIndex (uint32_t idx)
{
const bool can_create_synthetic = false;
lldb::DynamicValueType use_dynamic = eNoDynamicValues;
if (m_opaque_sp)
- use_dynamic = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue();
+ use_dynamic = m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetPreferDynamicValue();
return GetChildAtIndex (idx, use_dynamic, can_create_synthetic);
}
@@ -375,9 +487,9 @@
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
const bool can_create = true;
child_sp = m_opaque_sp->GetChildAtIndex (idx, can_create);
if (can_create_synthetic && !child_sp)
@@ -418,9 +530,9 @@
uint32_t idx = UINT32_MAX;
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
idx = m_opaque_sp->GetIndexOfChildWithName (ConstString(name));
}
@@ -441,7 +553,7 @@
{
if (m_opaque_sp)
{
- lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue();
+ lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetPreferDynamicValue();
return GetChildMemberWithName (name, use_dynamic_value);
}
else
@@ -457,9 +569,9 @@
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true);
if (use_dynamic_value != lldb::eNoDynamicValues)
{
@@ -488,9 +600,9 @@
lldb::ValueObjectSP child_sp;
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
// using default values for all the fancy options, just do it if you can
child_sp = m_opaque_sp->GetValueForExpressionPath(expr_path);
}
@@ -512,9 +624,9 @@
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
num_children = m_opaque_sp->GetNumChildren();
}
@@ -534,9 +646,9 @@
SBValue sb_value;
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Error error;
sb_value = m_opaque_sp->Dereference (error);
@@ -556,9 +668,9 @@
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
is_ptr_type = m_opaque_sp->IsPointerType();
}
@@ -577,9 +689,9 @@
{
if (m_opaque_sp)
{
- if (m_opaque_sp->GetUpdatePoint().GetTarget())
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
- Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
return m_opaque_sp->GetClangType();
}
@@ -587,6 +699,95 @@
return NULL;
}
+lldb::SBTarget
+SBValue::GetTarget()
+{
+ SBTarget result;
+ if (m_opaque_sp)
+ {
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
+ {
+ result = SBTarget(lldb::TargetSP(m_opaque_sp->GetUpdatePoint().GetTargetSP()));
+ }
+ }
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (log)
+ {
+ if (result.get() == NULL)
+ log->Printf ("SBValue(%p)::GetTarget () => NULL", m_opaque_sp.get());
+ else
+ log->Printf ("SBValue(%p)::GetTarget () => %p", m_opaque_sp.get(), result.get());
+ }
+ return result;
+}
+
+lldb::SBProcess
+SBValue::GetProcess()
+{
+ SBProcess result;
+ if (m_opaque_sp)
+ {
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
+ {
+ result = SBProcess(lldb::ProcessSP(m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetProcessSP()));
+ }
+ }
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (log)
+ {
+ if (result.get() == NULL)
+ log->Printf ("SBValue(%p)::GetProcess () => NULL", m_opaque_sp.get());
+ else
+ log->Printf ("SBValue(%p)::GetProcess () => %p", m_opaque_sp.get(), result.get());
+ }
+ return result;
+}
+
+lldb::SBThread
+SBValue::GetThread()
+{
+ SBThread result;
+ if (m_opaque_sp)
+ {
+ if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope())
+ {
+ result = SBThread(lldb::ThreadSP(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateThread()));
+ }
+ }
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (log)
+ {
+ if (result.get() == NULL)
+ log->Printf ("SBValue(%p)::GetThread () => NULL", m_opaque_sp.get());
+ else
+ log->Printf ("SBValue(%p)::GetThread () => %p", m_opaque_sp.get(), result.get());
+ }
+ return result;
+}
+
+lldb::SBFrame
+SBValue::GetFrame()
+{
+ SBFrame result;
+ if (m_opaque_sp)
+ {
+ if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope())
+ {
+ result = SBFrame(lldb::StackFrameSP(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame()));
+ }
+ }
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (log)
+ {
+ if (result.get() == NULL)
+ log->Printf ("SBValue(%p)::GetFrame () => NULL", m_opaque_sp.get());
+ else
+ log->Printf ("SBValue(%p)::GetFrame () => %p", m_opaque_sp.get(), result.get());
+ }
+ return result;
+}
+
+
// Mimic shared pointer...
lldb_private::ValueObject *
SBValue::get() const
@@ -685,3 +886,23 @@
m_opaque_sp->SetFormat(format);
}
+lldb::SBValue
+SBValue::AddressOf()
+{
+ SBValue sb_value;
+ if (m_opaque_sp)
+ {
+ if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
+ {
+ Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
+
+ Error error;
+ sb_value = m_opaque_sp->AddressOf (error);
+ }
+ }
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ if (log)
+ log->Printf ("SBValue(%p)::GetPointerToObject () => SBValue(%p)", m_opaque_sp.get(), sb_value.get());
+
+ return sb_value;
+}
\ No newline at end of file