lldb::SBError GetDescription(lldb::SBStream &stream) const;
+ //------------------------------------------------------------------
+ /// Return the type of data in this data structure
+ //------------------------------------------------------------------
+ lldb::StructuredDataType GetType() const;
+
+ //------------------------------------------------------------------
+ /// Return the size (i.e. number of elements) in this data structure
+ /// if it is an array or dictionary type. For other types, 0 will be
+ // returned.
+ //------------------------------------------------------------------
+ size_t GetSize() const;
+
+ //------------------------------------------------------------------
+ /// Return the value corresponding to a key if this data structure
+ /// is a dictionary type.
+ //------------------------------------------------------------------
+ lldb::SBStructuredData GetValueForKey(const char *key) const;
+
+ //------------------------------------------------------------------
+ /// Return the value corresponding to an index if this data structure
+ /// is array.
+ //------------------------------------------------------------------
+ lldb::SBStructuredData GetItemAtIndex(size_t idx) const;
+
+ //------------------------------------------------------------------
+ /// Return the integer value if this data structure is an integer type.
+ //------------------------------------------------------------------
+ uint64_t GetIntegerValue(uint64_t fail_value = 0) const;
+
+ //------------------------------------------------------------------
+ /// Return the floating point value if this data structure is a floating
+ /// type.
+ //------------------------------------------------------------------
+ double GetFloatValue(double fail_value = 0.0) const;
+
+ //------------------------------------------------------------------
+ /// Return the boolean value if this data structure is a boolean type.
+ //------------------------------------------------------------------
+ bool GetBooleanValue(bool fail_value = false) const;
+
+ //------------------------------------------------------------------
+ /// Provides the string value if this data structure is a string type.
+ ///
+ /// @param[out] dst
+ /// pointer where the string value will be written. In case it is null,
+ /// nothing will be written at @dst.
+ ///
+ /// @param[in] dst_len
+ /// max number of characters that can be written at @dst. In case it is
+ /// zero, nothing will be written at @dst. If this length is not enough
+ /// to write the complete string value, (dst_len-1) bytes of the string
+ /// value will be written at @dst followed by a null character.
+ ///
+ /// @return
+ /// Returns the byte size needed to completely write the string value at
+ /// @dst in all cases.
+ //------------------------------------------------------------------
+ size_t GetStringValue(char *dst, size_t dst_len) const;
+
protected:
friend class SBTraceOptions;
StructuredDataImplUP m_impl_up;
};
-}
+} // namespace lldb
#endif /* SBStructuredData_h */
#include "llvm/ADT/StringRef.h"
#include "lldb/Utility/ConstString.h"
-#include "lldb/Utility/FileSpec.h" // for FileSpec
+#include "lldb/Utility/FileSpec.h" // for FileSpec
+#include "lldb/lldb-enumerations.h" // for StructuredDataType
#include <functional>
#include <map>
typedef std::shared_ptr<Dictionary> DictionarySP;
typedef std::shared_ptr<Generic> GenericSP;
- enum class Type {
- eTypeInvalid = -1,
- eTypeNull = 0,
- eTypeGeneric,
- eTypeArray,
- eTypeInteger,
- eTypeFloat,
- eTypeBoolean,
- eTypeString,
- eTypeDictionary
- };
-
class Object : public std::enable_shared_from_this<Object> {
public:
- Object(Type t = Type::eTypeInvalid) : m_type(t) {}
+ Object(lldb::StructuredDataType t = lldb::eStructuredDataTypeInvalid)
+ : m_type(t) {}
virtual ~Object() = default;
virtual bool IsValid() const { return true; }
- virtual void Clear() { m_type = Type::eTypeInvalid; }
+ virtual void Clear() { m_type = lldb::eStructuredDataTypeInvalid; }
- Type GetType() const { return m_type; }
+ lldb::StructuredDataType GetType() const { return m_type; }
- void SetType(Type t) { m_type = t; }
+ void SetType(lldb::StructuredDataType t) { m_type = t; }
Array *GetAsArray() {
- return ((m_type == Type::eTypeArray) ? static_cast<Array *>(this)
- : nullptr);
+ return ((m_type == lldb::eStructuredDataTypeArray)
+ ? static_cast<Array *>(this)
+ : nullptr);
}
Dictionary *GetAsDictionary() {
- return ((m_type == Type::eTypeDictionary)
- ? static_cast<Dictionary *>(this)
- : nullptr);
+ return (
+ (m_type == lldb::eStructuredDataTypeDictionary)
+ ? static_cast<Dictionary *>(this)
+ : nullptr);
}
Integer *GetAsInteger() {
- return ((m_type == Type::eTypeInteger) ? static_cast<Integer *>(this)
- : nullptr);
+ return ((m_type == lldb::eStructuredDataTypeInteger)
+ ? static_cast<Integer *>(this)
+ : nullptr);
}
uint64_t GetIntegerValue(uint64_t fail_value = 0) {
}
Float *GetAsFloat() {
- return ((m_type == Type::eTypeFloat) ? static_cast<Float *>(this)
- : nullptr);
+ return ((m_type == lldb::eStructuredDataTypeFloat)
+ ? static_cast<Float *>(this)
+ : nullptr);
}
double GetFloatValue(double fail_value = 0.0) {
}
Boolean *GetAsBoolean() {
- return ((m_type == Type::eTypeBoolean) ? static_cast<Boolean *>(this)
- : nullptr);
+ return ((m_type == lldb::eStructuredDataTypeBoolean)
+ ? static_cast<Boolean *>(this)
+ : nullptr);
}
bool GetBooleanValue(bool fail_value = false) {
}
String *GetAsString() {
- return ((m_type == Type::eTypeString) ? static_cast<String *>(this)
- : nullptr);
+ return ((m_type == lldb::eStructuredDataTypeString)
+ ? static_cast<String *>(this)
+ : nullptr);
}
llvm::StringRef GetStringValue(const char *fail_value = nullptr) {
}
Generic *GetAsGeneric() {
- return ((m_type == Type::eTypeGeneric) ? static_cast<Generic *>(this)
- : nullptr);
+ return ((m_type == lldb::eStructuredDataTypeGeneric)
+ ? static_cast<Generic *>(this)
+ : nullptr);
}
ObjectSP GetObjectForDotSeparatedPath(llvm::StringRef path);
virtual void Dump(Stream &s, bool pretty_print = true) const = 0;
private:
- Type m_type;
+ lldb::StructuredDataType m_type;
};
class Array : public Object {
public:
- Array() : Object(Type::eTypeArray) {}
+ Array() : Object(lldb::eStructuredDataTypeArray) {}
~Array() override = default;
class Integer : public Object {
public:
- Integer(uint64_t i = 0) : Object(Type::eTypeInteger), m_value(i) {}
+ Integer(uint64_t i = 0)
+ : Object(lldb::eStructuredDataTypeInteger), m_value(i) {}
~Integer() override = default;
class Float : public Object {
public:
- Float(double d = 0.0) : Object(Type::eTypeFloat), m_value(d) {}
+ Float(double d = 0.0) : Object(lldb::eStructuredDataTypeFloat),
+ m_value(d) {}
~Float() override = default;
class Boolean : public Object {
public:
- Boolean(bool b = false) : Object(Type::eTypeBoolean), m_value(b) {}
+ Boolean(bool b = false) : Object(lldb::eStructuredDataTypeBoolean),
+ m_value(b) {}
~Boolean() override = default;
class String : public Object {
public:
- String() : Object(Type::eTypeString) {}
+ String() : Object(lldb::eStructuredDataTypeString) {}
explicit String(llvm::StringRef S)
- : Object(Type::eTypeString), m_value(S) {}
+ : Object(lldb::eStructuredDataTypeString),
+ m_value(S) {}
void SetValue(llvm::StringRef S) { m_value = S; }
class Dictionary : public Object {
public:
- Dictionary() : Object(Type::eTypeDictionary), m_dict() {}
+ Dictionary() : Object(lldb::eStructuredDataTypeDictionary),
+ m_dict() {}
~Dictionary() override = default;
class Null : public Object {
public:
- Null() : Object(Type::eTypeNull) {}
+ Null() : Object(lldb::eStructuredDataTypeNull) {}
~Null() override = default;
class Generic : public Object {
public:
explicit Generic(void *object = nullptr)
- : Object(Type::eTypeGeneric), m_object(object) {}
+ : Object(lldb::eStructuredDataTypeGeneric), m_object(object) {}
void SetValue(void *value) { m_object = value; }
#include "lldb/Target/StructuredDataPlugin.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h"
+#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringRef.h"
#pragma mark--
#pragma mark StructuredDataImpl
return plugin_sp->GetDescription(m_data_sp, stream);
}
- StructuredData::ObjectSP GetObjectSP() {
- return m_data_sp;
+ StructuredData::ObjectSP GetObjectSP() { return m_data_sp; }
+
+ void SetObjectSP(const StructuredData::ObjectSP &obj) { m_data_sp = obj; }
+
+ lldb::StructuredDataType GetType() const {
+ return (m_data_sp ? m_data_sp->GetType() :
+ lldb::eStructuredDataTypeInvalid);
}
- void SetObjectSP(const StructuredData::ObjectSP &obj) {
- m_data_sp = obj;
+ size_t GetSize() const {
+ if (!m_data_sp)
+ return 0;
+
+ if (m_data_sp->GetType() == lldb::eStructuredDataTypeDictionary) {
+ auto dict = m_data_sp->GetAsDictionary();
+ return (dict->GetSize());
+ } else if (m_data_sp->GetType() == lldb::eStructuredDataTypeArray) {
+ auto array = m_data_sp->GetAsArray();
+ return (array->GetSize());
+ } else
+ return 0;
}
-private:
+ StructuredData::ObjectSP GetValueForKey(const char *key) const {
+ if (m_data_sp) {
+ auto dict = m_data_sp->GetAsDictionary();
+ if (dict)
+ return dict->GetValueForKey(llvm::StringRef(key));
+ }
+ return StructuredData::ObjectSP();
+ }
+
+ StructuredData::ObjectSP GetItemAtIndex(size_t idx) const {
+ if (m_data_sp) {
+ auto array = m_data_sp->GetAsArray();
+ if (array)
+ return array->GetItemAtIndex(idx);
+ }
+ return StructuredData::ObjectSP();
+ }
+
+ uint64_t GetIntegerValue(uint64_t fail_value = 0) const {
+ return (m_data_sp ? m_data_sp->GetIntegerValue(fail_value) : fail_value);
+ }
+ double GetFloatValue(double fail_value = 0.0) const {
+ return (m_data_sp ? m_data_sp->GetFloatValue(fail_value) : fail_value);
+ }
+
+ bool GetBooleanValue(bool fail_value = false) const {
+ return (m_data_sp ? m_data_sp->GetBooleanValue(fail_value) : fail_value);
+ }
+
+ size_t GetStringValue(char *dst, size_t dst_len) const {
+ if (!m_data_sp)
+ return 0;
+
+ llvm::StringRef result = m_data_sp->GetStringValue();
+ if (result.empty())
+ return 0;
+
+ if (!dst || !dst_len) {
+ char s[1];
+ return (::snprintf(s, 1, "%s", result.data()));
+ }
+ return (::snprintf(dst, dst_len, "%s", result.data()));
+ }
+
+private:
lldb::StructuredDataPluginWP m_plugin_wp;
StructuredData::ObjectSP m_data_sp;
};
-}
+} // namespace lldb_private
#endif
eTraceTypeProcessorTrace
};
+enum StructuredDataType {
+ eStructuredDataTypeInvalid = -1,
+ eStructuredDataTypeNull = 0,
+ eStructuredDataTypeGeneric,
+ eStructuredDataTypeArray,
+ eStructuredDataTypeInteger,
+ eStructuredDataTypeFloat,
+ eStructuredDataTypeBoolean,
+ eStructuredDataTypeString,
+ eStructuredDataTypeDictionary
+};
+
FLAGS_ENUM(TypeClass){
eTypeClassInvalid = (0u), eTypeClassArray = (1u << 0),
eTypeClassBlockPointer = (1u << 1), eTypeClassBuiltin = (1u << 2),
--- /dev/null
+"""
+Test some SBStructuredData API.
+"""
+
+from __future__ import print_function
+
+import os
+import re
+import time
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestStructuredDataAPI(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test(self):
+ self.structured_data_api_test()
+
+ def setUp(self):
+ TestBase.setUp(self)
+
+ @add_test_categories(['pyapi'])
+ def structured_data_api_test(self):
+ error = lldb.SBError()
+ s = lldb.SBStream()
+ s.Print(
+ "{\"key_dict\":{\"key_string\":\"STRING\",\"key_int\":3,\"key_float\":2.99,\"key_bool\":true,\"key_array\":[\"23\",\"arr\"]}}")
+ example = lldb.SBStructuredData()
+
+ # Check SetFromJSON API for dictionaries, integers, floating point
+ # values, strings and arrays
+ error = example.SetFromJSON(s)
+ if not error.Success():
+ self.fail("FAILED: " + error.GetCString())
+
+ # Tests for invalid data type
+ self.invalid_struct_test(example)
+
+ dict_struct = lldb.SBStructuredData()
+ dict_struct = example.GetValueForKey("key_dict")
+
+ # Tests for dictionary data type
+ self.dictionary_struct_test(example)
+
+ # Tests for string data type
+ self.string_struct_test(dict_struct)
+
+ # Tests for integer data type
+ self.int_struct_test(dict_struct)
+
+ # Tests for floating point data type
+ self.double_struct_test(dict_struct)
+
+ # Tests for boolean data type
+ self.bool_struct_test(dict_struct)
+
+ # Tests for array data type
+ self.array_struct_test(dict_struct)
+
+ def invalid_struct_test(self, example):
+ invalid_struct = lldb.SBStructuredData()
+ invalid_struct = example.GetValueForKey("invalid_key")
+ if invalid_struct.IsValid():
+ self.fail("An invalid object should have been returned")
+
+ # Check Type API
+ if not invalid_struct.GetType() == lldb.eStructuredDataTypeInvalid:
+ self.fail("Wrong type returned: " + str(invalid_struct.GetType()))
+
+ def dictionary_struct_test(self, example):
+ # Check API returning a valid SBStructuredData of 'dictionary' type
+ dict_struct = lldb.SBStructuredData()
+ dict_struct = example.GetValueForKey("key_dict")
+ if not dict_struct.IsValid():
+ self.fail("A valid object should have been returned")
+
+ # Check Type API
+ if not dict_struct.GetType() == lldb.eStructuredDataTypeDictionary:
+ self.fail("Wrong type returned: " + str(dict_struct.GetType()))
+
+ # Check Size API for 'dictionary' type
+ if not dict_struct.GetSize() == 5:
+ self.fail("Wrong no of elements returned: " +
+ str(dict_struct.GetSize()))
+
+ def string_struct_test(self, dict_struct):
+ string_struct = lldb.SBStructuredData()
+ string_struct = dict_struct.GetValueForKey("key_string")
+ if not string_struct.IsValid():
+ self.fail("A valid object should have been returned")
+
+ # Check Type API
+ if not string_struct.GetType() == lldb.eStructuredDataTypeString:
+ self.fail("Wrong type returned: " + str(string_struct.GetType()))
+
+ # Check API returning 'string' value
+ output = string_struct.GetStringValue(25)
+ if not "STRING" in output:
+ self.fail("wrong output: " + output)
+
+ # Calling wrong API on a SBStructuredData
+ # (e.g. getting an integer from a string type structure)
+ output = string_struct.GetIntegerValue()
+ if output:
+ self.fail(
+ "Valid integer value " +
+ str(output) +
+ " returned for a string object")
+
+ def int_struct_test(self, dict_struct):
+ # Check a valid SBStructuredData containing an 'integer' by
+ int_struct = lldb.SBStructuredData()
+ int_struct = dict_struct.GetValueForKey("key_int")
+ if not int_struct.IsValid():
+ self.fail("A valid object should have been returned")
+
+ # Check Type API
+ if not int_struct.GetType() == lldb.eStructuredDataTypeInteger:
+ self.fail("Wrong type returned: " + str(int_struct.GetType()))
+
+ # Check API returning 'integer' value
+ output = int_struct.GetIntegerValue()
+ if not output == 3:
+ self.fail("wrong output: " + str(output))
+
+ # Calling wrong API on a SBStructuredData
+ # (e.g. getting a string value from an integer type structure)
+ output = int_struct.GetStringValue(25)
+ if output:
+ self.fail(
+ "Valid string " +
+ output +
+ " returned for an integer object")
+
+ def double_struct_test(self, dict_struct):
+ floating_point_struct = lldb.SBStructuredData()
+ floating_point_struct = dict_struct.GetValueForKey("key_float")
+ if not floating_point_struct.IsValid():
+ self.fail("A valid object should have been returned")
+
+ # Check Type API
+ if not floating_point_struct.GetType() == lldb.eStructuredDataTypeFloat:
+ self.fail("Wrong type returned: " +
+ str(floating_point_struct.GetType()))
+
+ # Check API returning 'double' value
+ output = floating_point_struct.GetFloatValue()
+ if not output == 2.99:
+ self.fail("wrong output: " + str(output))
+
+ def bool_struct_test(self, dict_struct):
+ bool_struct = lldb.SBStructuredData()
+ bool_struct = dict_struct.GetValueForKey("key_bool")
+ if not bool_struct.IsValid():
+ self.fail("A valid object should have been returned")
+
+ # Check Type API
+ if not bool_struct.GetType() == lldb.eStructuredDataTypeBoolean:
+ self.fail("Wrong type returned: " + str(bool_struct.GetType()))
+
+ # Check API returning 'bool' value
+ output = bool_struct.GetBooleanValue()
+ if not output:
+ self.fail("wrong output: " + str(output))
+
+ def array_struct_test(self, dict_struct):
+ # Check API returning a valid SBStructuredData of 'array' type
+ array_struct = lldb.SBStructuredData()
+ array_struct = dict_struct.GetValueForKey("key_array")
+ if not array_struct.IsValid():
+ self.fail("A valid object should have been returned")
+
+ # Check Type API
+ if not array_struct.GetType() == lldb.eStructuredDataTypeArray:
+ self.fail("Wrong type returned: " + str(array_struct.GetType()))
+
+ # Check Size API for 'array' type
+ if not array_struct.GetSize() == 2:
+ self.fail("Wrong no of elements returned: " +
+ str(array_struct.GetSize()))
+
+ # Check API returning a valid SBStructuredData for different 'array'
+ # indices
+ string_struct = array_struct.GetItemAtIndex(0)
+ if not string_struct.IsValid():
+ self.fail("A valid object should have been returned")
+ if not string_struct.GetType() == lldb.eStructuredDataTypeString:
+ self.fail("Wrong type returned: " + str(string_struct.GetType()))
+ output = string_struct.GetStringValue(5)
+ if not output == "23":
+ self.fail("wrong output: " + str(output))
+
+ string_struct = array_struct.GetItemAtIndex(1)
+ if not string_struct.IsValid():
+ self.fail("A valid object should have been returned")
+ if not string_struct.GetType() == lldb.eStructuredDataTypeString:
+ self.fail("Wrong type returned: " + str(string_struct.GetType()))
+ output = string_struct.GetStringValue(5)
+ if not output == "arr":
+ self.fail("wrong output: " + str(output))
class SBStructuredData
{
public:
-
SBStructuredData();
-
+
SBStructuredData(const lldb::SBStructuredData &rhs);
SBStructuredData(const lldb::EventSP &event_sp);
~SBStructuredData();
-
+
bool
IsValid() const;
-
+
void
Clear();
+ lldb::SBStructuredData &operator=(const lldb::SBStructuredData &rhs);
+
+ lldb::StructuredDataType GetType() const;
+
+ size_t GetSize() const;
+
+ lldb::SBStructuredData GetValueForKey(const char *key) const;
+
+ lldb::SBStructuredData GetItemAtIndex(size_t idx) const;
+
+ uint64_t GetIntegerValue(uint64_t fail_value = 0) const;
+
+ double GetFloatValue(double fail_value = 0.0) const;
+
+ bool GetBooleanValue(bool fail_value = false) const;
+
+ size_t GetStringValue(char *dst, size_t dst_len) const;
+
lldb::SBError
GetAsJSON(lldb::SBStream &stream) const;
StructuredData::ObjectSP json_obj = StructuredData::ParseJSON(json_str);
m_impl_up->SetObjectSP(json_obj);
- if (!json_obj || json_obj->GetType() != StructuredData::Type::eTypeDictionary)
+ if (!json_obj || json_obj->GetType() != eStructuredDataTypeDictionary)
error.SetErrorString("Invalid Syntax");
return error;
}
sb_error.SetError(error);
return sb_error;
}
+
+StructuredDataType SBStructuredData::GetType() const {
+ return (m_impl_up ? m_impl_up->GetType() : eStructuredDataTypeInvalid);
+}
+
+size_t SBStructuredData::GetSize() const {
+ return (m_impl_up ? m_impl_up->GetSize() : 0);
+}
+
+lldb::SBStructuredData SBStructuredData::GetValueForKey(const char *key) const {
+ if (!m_impl_up)
+ return SBStructuredData();
+
+ SBStructuredData result;
+ result.m_impl_up->SetObjectSP(m_impl_up->GetValueForKey(key));
+ return result;
+}
+
+lldb::SBStructuredData SBStructuredData::GetItemAtIndex(size_t idx) const {
+ if (!m_impl_up)
+ return SBStructuredData();
+
+ SBStructuredData result;
+ result.m_impl_up->SetObjectSP(m_impl_up->GetItemAtIndex(idx));
+ return result;
+}
+
+uint64_t SBStructuredData::GetIntegerValue(uint64_t fail_value) const {
+ return (m_impl_up ? m_impl_up->GetIntegerValue(fail_value) : fail_value);
+}
+
+double SBStructuredData::GetFloatValue(double fail_value) const {
+ return (m_impl_up ? m_impl_up->GetFloatValue(fail_value) : fail_value);
+}
+
+bool SBStructuredData::GetBooleanValue(bool fail_value) const {
+ return (m_impl_up ? m_impl_up->GetBooleanValue(fail_value) : fail_value);
+}
+
+size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const {
+ return (m_impl_up ? m_impl_up->GetStringValue(dst, dst_len) : 0);
+}
#include "lldb/API/SBThreadCollection.h"
#include "lldb/API/SBThreadPlan.h"
#include "lldb/API/SBValue.h"
+#include "lldb/lldb-enumerations.h"
using namespace lldb;
using namespace lldb_private;
StructuredData::ObjectSP node =
info_root_sp->GetObjectForDotSeparatedPath(path);
if (node) {
- if (node->GetType() == StructuredData::Type::eTypeString) {
+ if (node->GetType() == eStructuredDataTypeString) {
strm.Printf("%s", node->GetAsString()->GetValue().str().c_str());
success = true;
}
- if (node->GetType() == StructuredData::Type::eTypeInteger) {
+ if (node->GetType() == eStructuredDataTypeInteger) {
strm.Printf("0x%" PRIx64, node->GetAsInteger()->GetValue());
success = true;
}
- if (node->GetType() == StructuredData::Type::eTypeFloat) {
+ if (node->GetType() == eStructuredDataTypeFloat) {
strm.Printf("0x%f", node->GetAsFloat()->GetValue());
success = true;
}
- if (node->GetType() == StructuredData::Type::eTypeBoolean) {
+ if (node->GetType() == eStructuredDataTypeBoolean) {
if (node->GetAsBoolean()->GetValue() == true)
strm.Printf("true");
else
strm.Printf("false");
success = true;
}
- if (node->GetType() == StructuredData::Type::eTypeNull) {
+ if (node->GetType() == eStructuredDataTypeNull) {
strm.Printf("null");
success = true;
}
thread_info_dictionary->GetObjectForDotSeparatedPath(path);
if (value) {
- if (value->GetType() == StructuredData::Type::eTypeInteger) {
+ if (value->GetType() == eStructuredDataTypeInteger) {
const char *token_format = "0x%4.4" PRIx64;
if (!entry.printf_format.empty())
token_format = entry.printf_format.c_str();
s.Printf(token_format, value->GetAsInteger()->GetValue());
return true;
- } else if (value->GetType() == StructuredData::Type::eTypeFloat) {
+ } else if (value->GetType() == eStructuredDataTypeFloat) {
s.Printf("%f", value->GetAsFloat()->GetValue());
return true;
- } else if (value->GetType() == StructuredData::Type::eTypeString) {
+ } else if (value->GetType() == eStructuredDataTypeString) {
s.Format("{0}", value->GetAsString()->GetValue());
return true;
- } else if (value->GetType() == StructuredData::Type::eTypeArray) {
+ } else if (value->GetType() == eStructuredDataTypeArray) {
if (value->GetAsArray()->GetSize() > 0) {
s.Printf("%zu", value->GetAsArray()->GetSize());
return true;
}
- } else if (value->GetType() == StructuredData::Type::eTypeDictionary) {
+ } else if (value->GetType() == eStructuredDataTypeDictionary) {
s.Printf("%zu",
value->GetAsDictionary()->GetKeys()->GetAsArray()->GetSize());
return true;
if (thread) {
StructuredData::ObjectSP object_sp = thread->GetExtendedInfo();
if (object_sp &&
- object_sp->GetType() == StructuredData::Type::eTypeDictionary) {
+ object_sp->GetType() == eStructuredDataTypeDictionary) {
if (FormatThreadExtendedInfoRecurse(entry, object_sp, sc, exe_ctx, s))
return true;
}
StructuredData::ObjectSP
StructuredData::Object::GetObjectForDotSeparatedPath(llvm::StringRef path) {
- if (this->GetType() == Type::eTypeDictionary) {
+ if (this->GetType() == lldb::eStructuredDataTypeDictionary) {
std::pair<llvm::StringRef, llvm::StringRef> match = path.split('.');
std::string key = match.first.str();
ObjectSP value = this->GetAsDictionary()->GetValueForKey(key);
return ObjectSP();
}
- if (this->GetType() == Type::eTypeArray) {
+ if (this->GetType() == lldb::eStructuredDataTypeArray) {
std::pair<llvm::StringRef, llvm::StringRef> match = path.split('[');
if (match.second.size() == 0) {
return this->shared_from_this();
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
+#include "lldb/lldb-enumerations.h"
using namespace lldb;
using namespace lldb_private;
bool plan_overrides_trace =
have_valid_stop_info && have_valid_completed_plan
&& (m_stop_info_sp->GetStopReason() == eStopReasonTrace);
-
+
if (have_valid_stop_info && !plan_overrides_trace) {
return m_stop_info_sp;
} else if (have_valid_completed_plan) {
saved_state.orig_stop_id = process_sp->GetStopID();
saved_state.current_inlined_depth = GetCurrentInlinedDepth();
saved_state.m_completed_plan_stack = m_completed_plan_stack;
-
+
return true;
}
thread_info->GetObjectForDotSeparatedPath("trace_messages");
bool printed_activity = false;
- if (activity &&
- activity->GetType() == StructuredData::Type::eTypeDictionary) {
+ if (activity && activity->GetType() == eStructuredDataTypeDictionary) {
StructuredData::Dictionary *activity_dict = activity->GetAsDictionary();
StructuredData::ObjectSP id = activity_dict->GetValueForKey("id");
StructuredData::ObjectSP name = activity_dict->GetValueForKey("name");
- if (name && name->GetType() == StructuredData::Type::eTypeString && id &&
- id->GetType() == StructuredData::Type::eTypeInteger) {
+ if (name && name->GetType() == eStructuredDataTypeString && id &&
+ id->GetType() == eStructuredDataTypeInteger) {
strm.Format(" Activity '{0}', {1:x}\n",
name->GetAsString()->GetValue(),
id->GetAsInteger()->GetValue());
printed_activity = true;
}
bool printed_breadcrumb = false;
- if (breadcrumb &&
- breadcrumb->GetType() == StructuredData::Type::eTypeDictionary) {
+ if (breadcrumb && breadcrumb->GetType() == eStructuredDataTypeDictionary) {
if (printed_activity)
strm.Printf("\n");
StructuredData::Dictionary *breadcrumb_dict =
StructuredData::ObjectSP breadcrumb_text =
breadcrumb_dict->GetValueForKey("name");
if (breadcrumb_text &&
- breadcrumb_text->GetType() == StructuredData::Type::eTypeString) {
+ breadcrumb_text->GetType() == eStructuredDataTypeString) {
strm.Format(" Current Breadcrumb: {0}\n",
breadcrumb_text->GetAsString()->GetValue());
}
printed_breadcrumb = true;
}
- if (messages && messages->GetType() == StructuredData::Type::eTypeArray) {
+ if (messages && messages->GetType() == eStructuredDataTypeArray) {
if (printed_breadcrumb)
strm.Printf("\n");
StructuredData::Array *messages_array = messages->GetAsArray();
strm.Printf(" %zu trace messages:\n", msg_count);
for (size_t i = 0; i < msg_count; i++) {
StructuredData::ObjectSP message = messages_array->GetItemAtIndex(i);
- if (message &&
- message->GetType() == StructuredData::Type::eTypeDictionary) {
+ if (message && message->GetType() == eStructuredDataTypeDictionary) {
StructuredData::Dictionary *message_dict =
message->GetAsDictionary();
StructuredData::ObjectSP message_text =
message_dict->GetValueForKey("message");
if (message_text &&
- message_text->GetType() == StructuredData::Type::eTypeString) {
+ message_text->GetType() == eStructuredDataTypeString) {
strm.Format(" {0}\n", message_text->GetAsString()->GetValue());
}
}
#include "lldb/Host/File.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/lldb-enumerations.h"
#include "PythonTestSuite.h"
list.AppendItem(PythonString(string_value1));
auto array_sp = list.CreateStructuredArray();
- EXPECT_EQ(StructuredData::Type::eTypeInteger,
+ EXPECT_EQ(lldb::eStructuredDataTypeInteger,
array_sp->GetItemAtIndex(0)->GetType());
- EXPECT_EQ(StructuredData::Type::eTypeString,
+ EXPECT_EQ(lldb::eStructuredDataTypeString,
array_sp->GetItemAtIndex(1)->GetType());
auto int_sp = array_sp->GetItemAtIndex(0)->GetAsInteger();
auto array_sp = tuple.CreateStructuredArray();
EXPECT_EQ(tuple.GetSize(), array_sp->GetSize());
- EXPECT_EQ(StructuredData::Type::eTypeInteger,
+ EXPECT_EQ(lldb::eStructuredDataTypeInteger,
array_sp->GetItemAtIndex(0)->GetType());
- EXPECT_EQ(StructuredData::Type::eTypeString,
+ EXPECT_EQ(lldb::eStructuredDataTypeString,
array_sp->GetItemAtIndex(1)->GetType());
}