1 //===-- SBTrace.cpp ---------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Utility/Log.h"
11 #include "lldb/Target/Process.h"
13 #include "lldb/API/SBTrace.h"
14 #include "lldb/API/SBTraceOptions.h"
17 using namespace lldb_private;
24 lldb::ProcessSP SBTrace::GetSP() const { return m_opaque_wp.lock(); }
26 size_t SBTrace::GetTraceData(SBError &error, void *buf, size_t size,
27 size_t offset, lldb::tid_t thread_id) {
28 size_t bytes_read = 0;
29 ProcessSP process_sp(GetSP());
30 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
34 error.SetErrorString("invalid process");
36 bytes_read = process_sp->GetData(GetTraceUID(), thread_id, error.ref(), buf,
38 LLDB_LOG(log, "SBTrace::bytes_read - %" PRIx64, bytes_read);
43 size_t SBTrace::GetMetaData(SBError &error, void *buf, size_t size,
44 size_t offset, lldb::tid_t thread_id) {
45 size_t bytes_read = 0;
46 ProcessSP process_sp(GetSP());
47 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
51 error.SetErrorString("invalid process");
54 bytes_read = process_sp->GetMetaData(GetTraceUID(), thread_id, error.ref(),
56 LLDB_LOG(log, "SBTrace::bytes_read - %" PRIx64, bytes_read);
61 void SBTrace::StopTrace(SBError &error, lldb::tid_t thread_id) {
62 ProcessSP process_sp(GetSP());
66 error.SetErrorString("invalid process");
69 process_sp->StopTrace(GetTraceUID(), thread_id, error.ref());
72 void SBTrace::GetTraceConfig(SBTraceOptions &options, SBError &error) {
73 ProcessSP process_sp(GetSP());
77 error.SetErrorString("invalid process");
79 process_sp->GetTraceConfig(GetTraceUID(), error.ref(),
80 options.m_traceoptions_sp);
84 lldb::user_id_t SBTrace::GetTraceUID() {
86 return m_trace_impl_sp->uid;
87 return LLDB_INVALID_UID;
90 void SBTrace::SetTraceUID(lldb::user_id_t uid) {
92 m_trace_impl_sp->uid = uid;
96 m_trace_impl_sp.reset(new TraceImpl);
98 m_trace_impl_sp->uid = LLDB_INVALID_UID;
101 void SBTrace::SetSP(const ProcessSP &process_sp) { m_opaque_wp = process_sp; }
103 bool SBTrace::IsValid() {
104 if (!m_trace_impl_sp)