xref: /llvm-project/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp (revision 1188faa7ab4b005e3ee28f30055de2f76e210eb8)
1 //===-- IntelPTPerThreadProcessTrace.cpp ----------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "IntelPTPerThreadProcessTrace.h"
10 
11 using namespace lldb;
12 using namespace lldb_private;
13 using namespace process_linux;
14 using namespace llvm;
15 
16 bool IntelPTPerThreadProcessTrace::TracesThread(lldb::tid_t tid) const {
17   return m_thread_traces.TracesThread(tid);
18 }
19 
20 Error IntelPTPerThreadProcessTrace::TraceStop(lldb::tid_t tid) {
21   return m_thread_traces.TraceStop(tid);
22 }
23 
24 Error IntelPTPerThreadProcessTrace::TraceStart(lldb::tid_t tid) {
25   if (m_thread_traces.GetTotalBufferSize() +
26           m_tracing_params.trace_buffer_size >
27       static_cast<size_t>(*m_tracing_params.process_buffer_size_limit))
28     return createStringError(
29         inconvertibleErrorCode(),
30         "Thread %" PRIu64 " can't be traced as the process trace size limit "
31         "has been reached. Consider retracing with a higher "
32         "limit.",
33         tid);
34 
35   return m_thread_traces.TraceStart(tid, m_tracing_params);
36 }
37 
38 IntelPTThreadTraceCollection &IntelPTPerThreadProcessTrace::GetThreadTraces() {
39   return m_thread_traces;
40 }
41