summaryrefslogtreecommitdiffstats
path: root/lldb/source/API/SBTraceOptions.cpp
diff options
context:
space:
mode:
authorRavitheja Addepally <ravitheja.addepally@intel.com>2017-04-26 08:48:50 +0000
committerRavitheja Addepally <ravitheja.addepally@intel.com>2017-04-26 08:48:50 +0000
commitd5d8d91c1db18b984adb43632a1832202a0ecf1b (patch)
tree7391e1acfc7b953e755552c21ed20778ade191f1 /lldb/source/API/SBTraceOptions.cpp
parent2bcd94f8d8959a523adf8211c57a94782d561ca5 (diff)
downloadbcm5719-llvm-d5d8d91c1db18b984adb43632a1832202a0ecf1b.tar.gz
bcm5719-llvm-d5d8d91c1db18b984adb43632a1832202a0ecf1b.zip
Initial implementation of SB APIs for Tracing support.
Summary: This patch introduces new SB APIs for tracing support inside LLDB. The idea is to gather trace data from LLDB and provide it through this APIs to external tools integrating with LLDB. These tools will be responsible for interpreting and presenting the trace data to their users. The patch implements the following new SB APIs -> -> StartTrace - starts tracing with given parameters -> StopTrace - stops tracing. -> GetTraceData - read the trace data . -> GetMetaData - read the meta data assosciated with the trace. -> GetTraceConfig - read the trace configuration Tracing is associated with a user_id that is returned by the StartTrace API and this id needs to be used for accessing the trace data and also Stopping the trace. The user_id itself may map to tracing the complete process or just an individual thread. The APIs require an additional thread parameter when the user of these APIs wishes to perform thread specific manipulations on the tracing instances. The patch also includes the corresponding python wrappers for the C++ based APIs. Reviewers: k8stone, lldb-commits, clayborg Reviewed By: clayborg Subscribers: jingham, mgorny Differential Revision: https://reviews.llvm.org/D29581 llvm-svn: 301389
Diffstat (limited to 'lldb/source/API/SBTraceOptions.cpp')
-rw-r--r--lldb/source/API/SBTraceOptions.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/lldb/source/API/SBTraceOptions.cpp b/lldb/source/API/SBTraceOptions.cpp
new file mode 100644
index 00000000000..474fa911f7e
--- /dev/null
+++ b/lldb/source/API/SBTraceOptions.cpp
@@ -0,0 +1,94 @@
+//===-- SBTraceOptions.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/API/SBTraceOptions.h"
+#include "lldb/API/SBError.h"
+#include "lldb/API/SBStructuredData.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Core/TraceOptions.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+SBTraceOptions::SBTraceOptions() {
+ m_traceoptions_sp.reset(new TraceOptions());
+}
+
+lldb::TraceType SBTraceOptions::getType() const {
+ if (m_traceoptions_sp)
+ return m_traceoptions_sp->getType();
+ return lldb::TraceType::eTraceTypeNone;
+}
+
+uint64_t SBTraceOptions::getTraceBufferSize() const {
+ if (m_traceoptions_sp)
+ return m_traceoptions_sp->getTraceBufferSize();
+ return 0;
+}
+
+lldb::SBStructuredData SBTraceOptions::getTraceParams(lldb::SBError &error) {
+ error.Clear();
+ const lldb_private::StructuredData::DictionarySP dict_obj =
+ m_traceoptions_sp->getTraceParams();
+ lldb::SBStructuredData structData;
+ if (dict_obj && structData.m_impl_up)
+ structData.m_impl_up->SetObjectSP(dict_obj->shared_from_this());
+ else
+ error.SetErrorString("Empty trace params");
+ return structData;
+}
+
+uint64_t SBTraceOptions::getMetaDataBufferSize() const {
+ if (m_traceoptions_sp)
+ return m_traceoptions_sp->getTraceBufferSize();
+ return 0;
+}
+
+void SBTraceOptions::setTraceParams(lldb::SBStructuredData &params) {
+ if (m_traceoptions_sp && params.m_impl_up) {
+ StructuredData::ObjectSP obj_sp = params.m_impl_up->GetObjectSP();
+ if (obj_sp && obj_sp->GetAsDictionary() != nullptr)
+ m_traceoptions_sp->setTraceParams(
+ std::static_pointer_cast<StructuredData::Dictionary>(obj_sp));
+ }
+ return;
+}
+
+void SBTraceOptions::setType(lldb::TraceType type) {
+ if (m_traceoptions_sp)
+ m_traceoptions_sp->setType(type);
+}
+
+void SBTraceOptions::setTraceBufferSize(uint64_t size) {
+ if (m_traceoptions_sp)
+ m_traceoptions_sp->setTraceBufferSize(size);
+}
+
+void SBTraceOptions::setMetaDataBufferSize(uint64_t size) {
+ if (m_traceoptions_sp)
+ m_traceoptions_sp->setMetaDataBufferSize(size);
+}
+
+bool SBTraceOptions::IsValid() {
+ if (m_traceoptions_sp)
+ return true;
+ return false;
+}
+
+void SBTraceOptions::setThreadID(lldb::tid_t thread_id) {
+ if (m_traceoptions_sp)
+ m_traceoptions_sp->setThreadID(thread_id);
+}
+
+lldb::tid_t SBTraceOptions::getThreadID() {
+ if (m_traceoptions_sp)
+ return m_traceoptions_sp->getThreadID();
+ return LLDB_INVALID_THREAD_ID;
+}
OpenPOWER on IntegriCloud