#ifndef liblldb_ValueObject_h_
#define liblldb_ValueObject_h_
#include <map>
#include <vector>
#include "lldb/lldb-private.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Flags.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/UserID.h"
#include "lldb/Core/Value.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/StackID.h"
#include "lldb/Utility/SharedCluster.h"
namespace lldb_private {
class ValueObject : public UserID
{
public:
enum GetExpressionPathFormat
{
eDereferencePointers = 1,
eHonorPointers,
};
enum ValueObjectRepresentationStyle
{
eDisplayValue,
eDisplaySummary,
eDisplayLanguageSpecific
};
class EvaluationPoint
{
public:
EvaluationPoint ();
EvaluationPoint (ExecutionContextScope *exe_scope, bool use_selected = false);
EvaluationPoint (const EvaluationPoint &rhs);
~EvaluationPoint ();
ExecutionContextScope *
GetExecutionContextScope ();
Target *
GetTarget () const
{
return m_target_sp.get();
}
Process *
GetProcess () const
{
return m_process_sp.get();
}
bool
SetContext (ExecutionContextScope *exe_scope);
void
SetIsConstant ()
{
SetUpdated();
m_stop_id = LLDB_INVALID_UID;
}
bool
IsConstant () const
{
return m_stop_id == LLDB_INVALID_UID;
}
lldb::user_id_t
GetUpdateID () const
{
return m_stop_id;
}
void
SetUpdateID (lldb::user_id_t new_id)
{
m_stop_id = new_id;
}
bool
IsFirstEvaluation () const
{
return m_first_update;
}
void
SetNeedsUpdate ()
{
m_needs_update = true;
}
void
SetUpdated ();
bool
NeedsUpdating()
{
SyncWithProcessState();
return m_needs_update;
}
bool
IsValid ()
{
if (m_stop_id == LLDB_INVALID_UID)
return false;
else if (SyncWithProcessState ())
{
if (m_stop_id == LLDB_INVALID_UID)
return false;
}
return true;
}
void
SetInvalid ()
{
m_stop_id = LLDB_INVALID_UID;
m_needs_update = false;
}
private:
bool
SyncWithProcessState ();
ExecutionContextScope *m_exe_scope; bool m_needs_update;
bool m_first_update;
lldb::TargetSP m_target_sp;
lldb::ProcessSP m_process_sp;
lldb::user_id_t m_thread_id;
StackID m_stack_id;
lldb::user_id_t m_stop_id; };
const EvaluationPoint &
GetUpdatePoint () const
{
return m_update_point;
}
EvaluationPoint &
GetUpdatePoint ()
{
return m_update_point;
}
ExecutionContextScope *
GetExecutionContextScope ()
{
return m_update_point.GetExecutionContextScope();
}
virtual ~ValueObject();
virtual size_t
GetByteSize() = 0;
virtual clang::ASTContext *
GetClangAST () = 0;
virtual lldb::clang_type_t
GetClangType () = 0;
virtual lldb::ValueType
GetValueType() const = 0;
virtual ConstString
GetTypeName() = 0;
virtual lldb::LanguageType
GetObjectRuntimeLanguage();
virtual bool
IsPointerType ();
virtual bool
IsScalarType ();
virtual bool
IsPointerOrReferenceType ();
virtual bool
IsPossibleCPlusPlusDynamicType ();
virtual bool
IsPossibleDynamicType ();
virtual bool
IsBaseClass ()
{
return false;
}
virtual bool
IsDereferenceOfParent ()
{
return false;
}
bool
IsIntegerType (bool &is_signed);
virtual bool
GetBaseClassPath (Stream &s);
virtual void
GetExpressionPath (Stream &s, bool qualify_cxx_base_classes, GetExpressionPathFormat = eDereferencePointers);
virtual bool
IsInScope ()
{
return true;
}
virtual off_t
GetByteOffset()
{
return 0;
}
virtual uint32_t
GetBitfieldBitSize()
{
return 0;
}
virtual uint32_t
GetBitfieldBitOffset()
{
return 0;
}
virtual bool
IsArrayItemForPointer()
{
return m_is_array_item_for_pointer;
}
virtual bool
SetClangAST (clang::ASTContext *ast)
{
return false;
}
virtual const char *
GetValueAsCString ();
virtual bool
SetValueFromCString (const char *value_str);
const Error &
GetError();
const ConstString &
GetName() const;
lldb::ValueObjectSP
GetChildAtIndex (uint32_t idx, bool can_create);
virtual lldb::ValueObjectSP
GetChildMemberWithName (const ConstString &name, bool can_create);
virtual uint32_t
GetIndexOfChildWithName (const ConstString &name);
uint32_t
GetNumChildren ();
const Value &
GetValue() const;
Value &
GetValue();
bool
ResolveValue (Scalar &scalar);
const char *
GetLocationAsCString ();
const char *
GetSummaryAsCString ();
const char *
GetObjectDescription ();
const char *
GetPrintableRepresentation(ValueObjectRepresentationStyle val_obj_display = eDisplaySummary,
lldb::Format custom_format = lldb::eFormatInvalid);
bool
DumpPrintableRepresentation(Stream& s,
ValueObjectRepresentationStyle val_obj_display = eDisplaySummary,
lldb::Format custom_format = lldb::eFormatInvalid);
bool
GetValueIsValid () const;
bool
GetValueDidChange ();
bool
UpdateValueIfNeeded (bool update_format = true);
void
UpdateFormatsIfNeeded();
DataExtractor &
GetDataExtractor ();
bool
Write ();
lldb::ValueObjectSP
GetSP ()
{
return m_manager->GetSharedPointer(this);
}
protected:
void
AddSyntheticChild (const ConstString &key,
ValueObject *valobj);
public:
lldb::ValueObjectSP
GetSyntheticChild (const ConstString &key) const;
lldb::ValueObjectSP
GetSyntheticArrayMemberFromPointer (int32_t index, bool can_create);
lldb::ValueObjectSP
GetSyntheticBitFieldChild (uint32_t from, uint32_t to, bool can_create);
lldb::ValueObjectSP
GetDynamicValue (lldb::DynamicValueType valueType);
virtual lldb::ValueObjectSP
CreateConstantValue (const ConstString &name);
virtual lldb::ValueObjectSP
Dereference (Error &error);
virtual lldb::ValueObjectSP
AddressOf (Error &error);
virtual lldb::ValueObjectSP
CastPointerType (const char *name,
ClangASTType &ast_type);
virtual lldb::ValueObjectSP
CastPointerType (const char *name,
lldb::TypeSP &type_sp);
virtual void
ValueUpdated ()
{
m_value_str.clear();
m_summary_str.clear();
m_object_desc_str.clear();
}
virtual bool
IsDynamic ()
{
return false;
}
static void
DumpValueObject (Stream &s,
ValueObject *valobj,
const char *root_valobj_name,
uint32_t ptr_depth,
uint32_t curr_depth,
uint32_t max_depth,
bool show_types,
bool show_location,
bool use_objc,
lldb::DynamicValueType use_dynamic,
bool scope_already_checked,
bool flat_output);
bool
GetIsConstant () const
{
return m_update_point.IsConstant();
}
void
SetIsConstant ()
{
m_update_point.SetIsConstant();
}
lldb::Format
GetFormat () const
{
if (m_parent && m_format == lldb::eFormatDefault)
return m_parent->GetFormat();
return m_format;
}
void
SetFormat (lldb::Format format)
{
if (format != m_format)
m_value_str.clear();
m_format = format;
}
virtual ValueObject *
GetParent()
{
return m_parent;
}
virtual const ValueObject *
GetParent() const
{
return m_parent;
}
ValueObject *
GetNonBaseClassParent();
void
SetPointersPointToLoadAddrs (bool b)
{
m_pointers_point_to_load_addrs = b;
}
protected:
typedef ClusterManager<ValueObject> ValueObjectManager;
ValueObject * m_parent; EvaluationPoint m_update_point; ConstString m_name; DataExtractor m_data; Value m_value;
Error m_error; std::string m_value_str; std::string m_old_value_str; std::string m_location_str; std::string m_summary_str; std::string m_object_desc_str;
ValueObjectManager *m_manager;
std::vector<ValueObject *> m_children;
std::map<ConstString, ValueObject *> m_synthetic_children;
ValueObject *m_dynamic_value;
lldb::ValueObjectSP m_addr_of_valobj_sp; ValueObject *m_deref_valobj;
lldb::Format m_format;
uint32_t m_last_format_mgr_revision;
lldb::SummaryFormatSP m_last_summary_format;
lldb::ValueFormatSP m_last_value_format;
bool m_value_is_valid:1,
m_value_did_change:1,
m_children_count_valid:1,
m_old_value_valid:1,
m_pointers_point_to_load_addrs:1,
m_is_deref_of_parent:1,
m_is_array_item_for_pointer:1,
m_is_bitfield_for_scalar:1;
friend class ClangExpressionDeclMap; friend class ClangExpressionVariable; friend class Target;
ValueObject();
ValueObject (ExecutionContextScope *exe_scope);
ValueObject (ValueObject &parent);
ValueObjectManager *
GetManager()
{
return m_manager;
}
virtual bool
UpdateValue () = 0;
virtual void
CalculateDynamicValue (lldb::DynamicValueType use_dynamic);
virtual ValueObject *
CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index);
virtual uint32_t
CalculateNumChildren() = 0;
void
SetName (const char *name);
void
SetName (const ConstString &name);
void
SetNumChildren (uint32_t num_children);
void
SetValueDidChange (bool value_changed);
void
SetValueIsValid (bool valid);
public:
lldb::addr_t
GetPointerValue (AddressType &address_type,
bool scalar_is_load_address);
lldb::addr_t
GetAddressOf (AddressType &address_type,
bool scalar_is_load_address);
private:
DISALLOW_COPY_AND_ASSIGN (ValueObject);
};
}
#endif // liblldb_ValueObject_h_