ProcessMinidump.h revision 360784
1//===-- ProcessMinidump.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_ProcessMinidump_h_
10#define liblldb_ProcessMinidump_h_
11
12#include "MinidumpParser.h"
13#include "MinidumpTypes.h"
14
15#include "lldb/Target/Process.h"
16#include "lldb/Target/StopInfo.h"
17#include "lldb/Target/Target.h"
18#include "lldb/Utility/ConstString.h"
19#include "lldb/Utility/Status.h"
20
21#include "llvm/Support/Format.h"
22#include "llvm/Support/raw_ostream.h"
23
24
25namespace lldb_private {
26
27namespace minidump {
28
29class ProcessMinidump : public Process {
30public:
31  static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
32                                        lldb::ListenerSP listener_sp,
33                                        const FileSpec *crash_file_path);
34
35  static void Initialize();
36
37  static void Terminate();
38
39  static ConstString GetPluginNameStatic();
40
41  static const char *GetPluginDescriptionStatic();
42
43  ProcessMinidump(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
44                  const FileSpec &core_file, lldb::DataBufferSP code_data);
45
46  ~ProcessMinidump() override;
47
48  bool CanDebug(lldb::TargetSP target_sp,
49                bool plugin_specified_by_name) override;
50
51  CommandObject *GetPluginCommandObject() override;
52
53  Status DoLoadCore() override;
54
55  DynamicLoader *GetDynamicLoader() override { return nullptr; }
56
57  ConstString GetPluginName() override;
58
59  uint32_t GetPluginVersion() override;
60
61  SystemRuntime *GetSystemRuntime() override { return nullptr; }
62
63  Status DoDestroy() override;
64
65  void RefreshStateAfterStop() override;
66
67  bool IsAlive() override;
68
69  bool WarnBeforeDetach() const override;
70
71  size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size,
72                    Status &error) override;
73
74  size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
75                      Status &error) override;
76
77  ArchSpec GetArchitecture();
78
79  Status GetMemoryRegionInfo(lldb::addr_t load_addr,
80                             MemoryRegionInfo &range_info) override;
81
82  Status GetMemoryRegions(
83      lldb_private::MemoryRegionInfos &region_list) override;
84
85  bool GetProcessInfo(ProcessInstanceInfo &info) override;
86
87  Status WillResume() override {
88    Status error;
89    error.SetErrorStringWithFormat(
90        "error: %s does not support resuming processes",
91        GetPluginName().GetCString());
92    return error;
93  }
94
95  llvm::Optional<MinidumpParser> m_minidump_parser;
96
97protected:
98  void Clear();
99
100  bool UpdateThreadList(ThreadList &old_thread_list,
101                        ThreadList &new_thread_list) override;
102
103  void ReadModuleList();
104
105  JITLoaderList &GetJITLoaders() override;
106
107private:
108  FileSpec m_core_file;
109  lldb::DataBufferSP m_core_data;
110  llvm::ArrayRef<minidump::Thread> m_thread_list;
111  const minidump::ExceptionStream *m_active_exception;
112  lldb::CommandObjectSP m_command_sp;
113  bool m_is_wow64;
114  llvm::Optional<MemoryRegionInfos> m_memory_regions;
115
116  void BuildMemoryRegions();
117};
118
119} // namespace minidump
120} // namespace lldb_private
121
122#endif // liblldb_ProcessMinidump_h_
123