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
This commit is contained in:
Ravitheja Addepally
2017-04-26 08:48:50 +00:00
parent 2bcd94f8d8
commit d5d8d91c1d
22 changed files with 785 additions and 69 deletions

View File

@@ -44,6 +44,8 @@
#include "lldb/API/SBStructuredData.h"
#include "lldb/API/SBThread.h"
#include "lldb/API/SBThreadCollection.h"
#include "lldb/API/SBTrace.h"
#include "lldb/API/SBTraceOptions.h"
#include "lldb/API/SBUnixSignals.h"
using namespace lldb;
@@ -349,6 +351,26 @@ size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const {
return bytes_read;
}
lldb::SBTrace SBProcess::StartTrace(SBTraceOptions &options,
lldb::SBError &error) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
ProcessSP process_sp(GetSP());
error.Clear();
SBTrace trace_instance;
trace_instance.SetSP(process_sp);
lldb::user_id_t uid = LLDB_INVALID_UID;
if (!process_sp) {
error.SetErrorString("invalid process");
} else {
uid = process_sp->StartTrace(options.m_traceoptions_sp, error.ref());
trace_instance.SetTraceUID(uid);
LLDB_LOG(log, "SBProcess::returned uid - %" PRIx64, uid);
}
return trace_instance;
}
void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const {
if (out == NULL)
return;