xref: /freebsd/contrib/llvm-project/lldb/include/lldb/Target/ProcessTrace.h (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
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 llvm::StringRef GetPluginNameStatic() { return "trace"; }
27 
28   static llvm::StringRef 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   llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
44 
45   Status DoDestroy() override;
46 
47   void RefreshStateAfterStop() override;
48 
49   Status WillResume() override {
50     Status error;
51     error.SetErrorStringWithFormatv(
52         "error: {0} does not support resuming processes", GetPluginName());
53     return error;
54   }
55 
56   bool WarnBeforeDetach() const override { return false; }
57 
58   size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size,
59                     Status &error) override;
60 
61   size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
62                       Status &error) override;
63 
64   ArchSpec GetArchitecture();
65 
66   bool GetProcessInfo(ProcessInstanceInfo &info) override;
67 
68 protected:
69   void Clear();
70 
71   bool DoUpdateThreadList(ThreadList &old_thread_list,
72                           ThreadList &new_thread_list) override;
73 
74 private:
75   static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
76                                         lldb::ListenerSP listener_sp,
77                                         const FileSpec *crash_file_path,
78                                         bool can_connect);
79 };
80 
81 } // namespace lldb_private
82 
83 #endif // LLDB_TARGET_PROCESSTRACE_H
84