1 //===-- IntelPTProcessTrace.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_IntelPTProcessTrace_H_
10 #define liblldb_IntelPTProcessTrace_H_
11 
12 #include "lldb/Utility/TraceIntelPTGDBRemotePackets.h"
13 
14 #include <memory>
15 
16 namespace lldb_private {
17 namespace process_linux {
18 
19 // Abstract class to be inherited by all the process tracing strategies.
20 class IntelPTProcessTrace {
21 public:
22   virtual ~IntelPTProcessTrace() = default;
23 
24   virtual void ProcessDidStop() {}
25 
26   virtual void ProcessWillResume() {}
27 
28   /// Construct a minimal jLLDBTraceGetState response for this process trace.
29   virtual TraceIntelPTGetStateResponse GetState() = 0;
30 
31   virtual bool TracesThread(lldb::tid_t tid) const = 0;
32 
33   /// \copydoc IntelPTThreadTraceCollection::TraceStart()
34   virtual llvm::Error TraceStart(lldb::tid_t tid) = 0;
35 
36   /// \copydoc IntelPTThreadTraceCollection::TraceStop()
37   virtual llvm::Error TraceStop(lldb::tid_t tid) = 0;
38 
39   /// \return
40   ///   \b None if this instance doesn't support the requested data, an \a
41   ///   llvm::Error if this isntance supports it but fails at fetching it, and
42   ///   \b Error::success() otherwise.
43   virtual llvm::Expected<llvm::Optional<std::vector<uint8_t>>>
44   TryGetBinaryData(const TraceGetBinaryDataRequest &request) = 0;
45 };
46 
47 using IntelPTProcessTraceUP = std::unique_ptr<IntelPTProcessTrace>;
48 
49 } // namespace process_linux
50 } // namespace lldb_private
51 
52 #endif // liblldb_IntelPTProcessTrace_H_
53