LLDB mainline
IntelPTCollector.h
Go to the documentation of this file.
1//===-- IntelPTCollector.h ------------------------------------ -*- C++ -*-===//
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#ifndef liblldb_IntelPTCollector_H_
10#define liblldb_IntelPTCollector_H_
11
15#include "Perf.h"
17#include "lldb/Utility/Status.h"
19#include "lldb/lldb-types.h"
20#include <linux/perf_event.h>
21#include <sys/mman.h>
22#include <unistd.h>
23
24namespace lldb_private {
25
26namespace process_linux {
27
28/// Main class that manages intel-pt process and thread tracing.
30public:
31 /// \param[in] process
32 /// Process to be traced.
34
35 static bool IsSupported();
36
37 /// To be invoked as soon as we know the process stopped.
38 void ProcessDidStop();
39
40 /// To be invoked before the process will resume, so that we can capture the
41 /// first instructions after the resume.
42 void ProcessWillResume();
43
44 /// If "process tracing" is enabled, then trace the given thread.
45 llvm::Error OnThreadCreated(lldb::tid_t tid);
46
47 /// Stops tracing a tracing upon a destroy event.
48 llvm::Error OnThreadDestroyed(lldb::tid_t tid);
49
50 /// Implementation of the jLLDBTraceStop packet
51 llvm::Error TraceStop(const TraceStopRequest &request);
52
53 /// Implementation of the jLLDBTraceStart packet
54 llvm::Error TraceStart(const TraceIntelPTStartRequest &request);
55
56 /// Implementation of the jLLDBTraceGetState packet
57 llvm::Expected<llvm::json::Value> GetState();
58
59 /// Implementation of the jLLDBTraceGetBinaryData packet
60 llvm::Expected<std::vector<uint8_t>>
62
63 /// Dispose of all traces
64 void Clear();
65
66private:
67 llvm::Error TraceStop(lldb::tid_t tid);
68
69 /// Start tracing a specific thread.
70 llvm::Error TraceStart(lldb::tid_t tid,
71 const TraceIntelPTStartRequest &request);
72
73 /// \return
74 /// The conversion object between TSC and wall time.
75 llvm::Expected<LinuxPerfZeroTscConversion &>
77
78 /// The target process.
80 /// Threads traced due to "thread tracing"
82
83 /// Only one instance of "process trace" can be active at a given time.
84 /// It might be \b nullptr.
86};
87
88} // namespace process_linux
89} // namespace lldb_private
90
91#endif // liblldb_IntelPTCollector_H_
This file contains a thin wrapper of the perf_event_open API and classes to handle the destruction of...
Main class that manages intel-pt process and thread tracing.
llvm::Expected< LinuxPerfZeroTscConversion & > FetchPerfTscConversionParameters()
llvm::Expected< std::vector< uint8_t > > GetBinaryData(const TraceGetBinaryDataRequest &request)
Implementation of the jLLDBTraceGetBinaryData packet.
llvm::Error TraceStart(lldb::tid_t tid, const TraceIntelPTStartRequest &request)
Start tracing a specific thread.
llvm::Error TraceStop(const TraceStopRequest &request)
Implementation of the jLLDBTraceStop packet.
IntelPTProcessTraceUP m_process_trace_up
Only one instance of "process trace" can be active at a given time.
NativeProcessProtocol & m_process
The target process.
llvm::Error TraceStart(const TraceIntelPTStartRequest &request)
Implementation of the jLLDBTraceStart packet.
IntelPTThreadTraceCollection m_thread_traces
Threads traced due to "thread tracing".
llvm::Error OnThreadCreated(lldb::tid_t tid)
If "process tracing" is enabled, then trace the given thread.
llvm::Error OnThreadDestroyed(lldb::tid_t tid)
Stops tracing a tracing upon a destroy event.
llvm::Expected< llvm::json::Value > GetState()
Implementation of the jLLDBTraceGetState packet.
void ProcessWillResume()
To be invoked before the process will resume, so that we can capture the first instructions after the...
void ProcessDidStop()
To be invoked as soon as we know the process stopped.
std::unique_ptr< IntelPTProcessTrace > IntelPTProcessTraceUP
A class that represents a running process on the host machine.
uint64_t tid_t
Definition: lldb-types.h:86
jLLDBTraceGetBinaryData gdb-remote packet
jLLDBTraceStop gdb-remote packet