summaryrefslogtreecommitdiff
path: root/include/lldb/Core
diff options
context:
space:
mode:
Diffstat (limited to 'include/lldb/Core')
-rw-r--r--include/lldb/Core/StructuredDataImpl.h95
-rw-r--r--include/lldb/Core/TraceOptions.h62
-rw-r--r--include/lldb/Core/ValueObject.h26
3 files changed, 162 insertions, 21 deletions
diff --git a/include/lldb/Core/StructuredDataImpl.h b/include/lldb/Core/StructuredDataImpl.h
new file mode 100644
index 000000000000..94f9cce52548
--- /dev/null
+++ b/include/lldb/Core/StructuredDataImpl.h
@@ -0,0 +1,95 @@
+//===-- StructuredDataImpl.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_StructuredDataImpl_h_
+#define liblldb_StructuredDataImpl_h_
+
+#include "lldb/Core/Event.h"
+#include "lldb/Core/StructuredData.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Target/StructuredDataPlugin.h"
+#include "lldb/lldb-forward.h"
+
+#pragma mark--
+#pragma mark StructuredDataImpl
+
+namespace lldb_private {
+
+class StructuredDataImpl {
+public:
+ StructuredDataImpl() : m_plugin_wp(), m_data_sp() {}
+
+ StructuredDataImpl(const StructuredDataImpl &rhs) = default;
+
+ StructuredDataImpl(const lldb::EventSP &event_sp)
+ : m_plugin_wp(
+ EventDataStructuredData::GetPluginFromEvent(event_sp.get())),
+ m_data_sp(EventDataStructuredData::GetObjectFromEvent(event_sp.get())) {
+ }
+
+ ~StructuredDataImpl() = default;
+
+ StructuredDataImpl &operator=(const StructuredDataImpl &rhs) = default;
+
+ bool IsValid() const { return m_data_sp.get() != nullptr; }
+
+ void Clear() {
+ m_plugin_wp.reset();
+ m_data_sp.reset();
+ }
+
+ Error GetAsJSON(Stream &stream) const {
+ Error error;
+
+ if (!m_data_sp) {
+ error.SetErrorString("No structured data.");
+ return error;
+ }
+
+ m_data_sp->Dump(stream);
+ return error;
+ }
+
+ Error GetDescription(Stream &stream) const {
+ Error error;
+
+ if (!m_data_sp) {
+ error.SetErrorString("Cannot pretty print structured data: "
+ "no data to print.");
+ return error;
+ }
+
+ // Grab the plugin.
+ auto plugin_sp = lldb::StructuredDataPluginSP(m_plugin_wp);
+ if (!plugin_sp) {
+ error.SetErrorString("Cannot pretty print structured data: "
+ "plugin doesn't exist.");
+ return error;
+ }
+
+ // Get the data's description.
+ return plugin_sp->GetDescription(m_data_sp, stream);
+ }
+
+ StructuredData::ObjectSP GetObjectSP() {
+ return m_data_sp;
+ }
+
+ void SetObjectSP(const StructuredData::ObjectSP &obj) {
+ m_data_sp = obj;
+ }
+
+private:
+
+ lldb::StructuredDataPluginWP m_plugin_wp;
+ StructuredData::ObjectSP m_data_sp;
+};
+}
+#endif
diff --git a/include/lldb/Core/TraceOptions.h b/include/lldb/Core/TraceOptions.h
new file mode 100644
index 000000000000..ffa2bae7f659
--- /dev/null
+++ b/include/lldb/Core/TraceOptions.h
@@ -0,0 +1,62 @@
+//===-- TraceOptions.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_TraceOptions_h_
+#define liblldb_TraceOptions_h_
+
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-enumerations.h"
+
+#include "lldb/Core/StructuredData.h"
+
+namespace lldb_private {
+class TraceOptions {
+public:
+ TraceOptions()
+ : m_trace_params(new StructuredData::Dictionary()) {}
+
+ const StructuredData::DictionarySP &getTraceParams() const {
+ return m_trace_params;
+ }
+
+ lldb::TraceType getType() const { return m_type; }
+
+ uint64_t getTraceBufferSize() const { return m_trace_buffer_size; }
+
+ uint64_t getMetaDataBufferSize() const { return m_meta_data_buffer_size; }
+
+ void setTraceParams(const StructuredData::DictionarySP &dict_obj) {
+ m_trace_params = dict_obj;
+ }
+
+ void setType(lldb::TraceType type) { m_type = type; }
+
+ void setTraceBufferSize(uint64_t size) { m_trace_buffer_size = size; }
+
+ void setMetaDataBufferSize(uint64_t size) { m_meta_data_buffer_size = size; }
+
+ void setThreadID(lldb::tid_t thread_id) { m_thread_id = thread_id; }
+
+ lldb::tid_t getThreadID() { return m_thread_id; }
+
+private:
+ lldb::TraceType m_type;
+ uint64_t m_trace_buffer_size;
+ uint64_t m_meta_data_buffer_size;
+ lldb::tid_t m_thread_id;
+
+ /// m_trace_params is meant to hold any custom parameters
+ /// apart from meta buffer size and trace size.
+ /// The interpretation of such parameters is left to
+ /// the lldb-server.
+ StructuredData::DictionarySP m_trace_params;
+};
+}
+
+#endif // liblldb_TraceOptions_h_ \ No newline at end of file
diff --git a/include/lldb/Core/ValueObject.h b/include/lldb/Core/ValueObject.h
index 1c923f317b7c..0898754b211a 100644
--- a/include/lldb/Core/ValueObject.h
+++ b/include/lldb/Core/ValueObject.h
@@ -27,6 +27,7 @@
#include "lldb/lldb-private-enumerations.h" // for AddressType
#include "lldb/lldb-types.h" // for addr_t, offs...
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h" // for StringRef
@@ -37,7 +38,6 @@
#include <mutex> // for recursive_mutex
#include <string> // for string
#include <utility> // for pair
-#include <vector>
#include <stddef.h> // for size_t
#include <stdint.h> // for uint32_t
@@ -489,35 +489,19 @@ public:
virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create);
// this will always create the children if necessary
- lldb::ValueObjectSP
- GetChildAtIndexPath(const std::initializer_list<size_t> &idxs,
- size_t *index_of_error = nullptr);
-
- lldb::ValueObjectSP GetChildAtIndexPath(const std::vector<size_t> &idxs,
+ lldb::ValueObjectSP GetChildAtIndexPath(llvm::ArrayRef<size_t> idxs,
size_t *index_of_error = nullptr);
- lldb::ValueObjectSP GetChildAtIndexPath(
- const std::initializer_list<std::pair<size_t, bool>> &idxs,
- size_t *index_of_error = nullptr);
-
lldb::ValueObjectSP
- GetChildAtIndexPath(const std::vector<std::pair<size_t, bool>> &idxs,
+ GetChildAtIndexPath(llvm::ArrayRef<std::pair<size_t, bool>> idxs,
size_t *index_of_error = nullptr);
// this will always create the children if necessary
- lldb::ValueObjectSP
- GetChildAtNamePath(const std::initializer_list<ConstString> &names,
- ConstString *name_of_error = nullptr);
-
- lldb::ValueObjectSP GetChildAtNamePath(const std::vector<ConstString> &names,
+ lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef<ConstString> names,
ConstString *name_of_error = nullptr);
- lldb::ValueObjectSP GetChildAtNamePath(
- const std::initializer_list<std::pair<ConstString, bool>> &names,
- ConstString *name_of_error = nullptr);
-
lldb::ValueObjectSP
- GetChildAtNamePath(const std::vector<std::pair<ConstString, bool>> &names,
+ GetChildAtNamePath(llvm::ArrayRef<std::pair<ConstString, bool>> names,
ConstString *name_of_error = nullptr);
virtual lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name,