1 //===-- ProcessTrace.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 LLDB_TARGET_PROCESSTRACE_H
10 #define LLDB_TARGET_PROCESSTRACE_H
11 
12 #include "lldb/Target/PostMortemProcess.h"
13 #include "lldb/Utility/ConstString.h"
14 #include "lldb/Utility/Status.h"
15 
16 namespace lldb_private {
17 
18 /// Class that represents a defunct process loaded on memory via the "trace
19 /// load" command.
20 class ProcessTrace : public PostMortemProcess {
21 public:
22   static void Initialize();
23 
24   static void Terminate();
25 
26   static ConstString GetPluginNameStatic();
27 
28   static const char *GetPluginDescriptionStatic();
29 
30   ProcessTrace(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp);
31 
32   ~ProcessTrace() override;
33 
34   bool CanDebug(lldb::TargetSP target_sp,
35                 bool plugin_specified_by_name) override;
36 
37   void DidAttach(ArchSpec &process_arch) override;
38 
39   DynamicLoader *GetDynamicLoader() override { return nullptr; }
40 
41   SystemRuntime *GetSystemRuntime() override { return nullptr; }
42 
43   ConstString GetPluginName() override;
44 
45   uint32_t GetPluginVersion() override;
46 
47   Status DoDestroy() override;
48 
49   void RefreshStateAfterStop() override;
50 
51   Status WillResume() override {
52     Status error;
53     error.SetErrorStringWithFormat(
54         "error: %s does not support resuming processes",
55         GetPluginName().GetCString());
56     return error;
57   }
58 
59   bool WarnBeforeDetach() const override { return false; }
60 
61   size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size,
62                     Status &error) override;
63 
64   size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
65                       Status &error) override;
66 
67   ArchSpec GetArchitecture();
68 
69   bool GetProcessInfo(ProcessInstanceInfo &info) override;
70 
71 protected:
72   void Clear();
73 
74   bool DoUpdateThreadList(ThreadList &old_thread_list,
75                           ThreadList &new_thread_list) override;
76 
77 private:
78   static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
79                                         lldb::ListenerSP listener_sp,
80                                         const FileSpec *crash_file_path,
81                                         bool can_connect);
82 };
83 
84 } // namespace lldb_private
85 
86 #endif // LLDB_TARGET_PROCESSTRACE_H
87