Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / source / Plugins / Process / minidump / ProcessMinidump.h
blob0e4e52c0113fb958b0526af7663e273616be82cc
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 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_PROCESSMINIDUMP_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_PROCESSMINIDUMP_H
12 #include "MinidumpParser.h"
13 #include "MinidumpTypes.h"
15 #include "lldb/Target/PostMortemProcess.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"
21 #include "llvm/Support/Format.h"
22 #include "llvm/Support/raw_ostream.h"
23 #include <optional>
25 namespace lldb_private {
27 namespace minidump {
29 class ProcessMinidump : public PostMortemProcess {
30 public:
31 static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
32 lldb::ListenerSP listener_sp,
33 const FileSpec *crash_file_path,
34 bool can_connect);
36 static void Initialize();
38 static void Terminate();
40 static llvm::StringRef GetPluginNameStatic() { return "minidump"; }
42 static llvm::StringRef GetPluginDescriptionStatic();
44 ProcessMinidump(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
45 const FileSpec &core_file, lldb::DataBufferSP code_data);
47 ~ProcessMinidump() override;
49 bool CanDebug(lldb::TargetSP target_sp,
50 bool plugin_specified_by_name) override;
52 CommandObject *GetPluginCommandObject() override;
54 Status DoLoadCore() override;
56 DynamicLoader *GetDynamicLoader() override { return nullptr; }
58 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
60 SystemRuntime *GetSystemRuntime() override { return nullptr; }
62 Status DoDestroy() override;
64 void RefreshStateAfterStop() override;
66 bool IsAlive() override;
68 bool WarnBeforeDetach() const override;
70 size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size,
71 Status &error) override;
73 size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
74 Status &error) override;
76 ArchSpec GetArchitecture();
78 Status GetMemoryRegions(
79 lldb_private::MemoryRegionInfos &region_list) override;
81 bool GetProcessInfo(ProcessInstanceInfo &info) override;
83 Status WillResume() override {
84 Status error;
85 error.SetErrorStringWithFormatv(
86 "error: {0} does not support resuming processes", GetPluginName());
87 return error;
90 std::optional<MinidumpParser> m_minidump_parser;
92 protected:
93 void Clear();
95 bool DoUpdateThreadList(ThreadList &old_thread_list,
96 ThreadList &new_thread_list) override;
98 Status DoGetMemoryRegionInfo(lldb::addr_t load_addr,
99 MemoryRegionInfo &range_info) override;
101 void ReadModuleList();
103 lldb::ModuleSP GetOrCreateModule(lldb_private::UUID minidump_uuid,
104 llvm::StringRef name,
105 lldb_private::ModuleSpec module_spec);
107 JITLoaderList &GetJITLoaders() override;
109 private:
110 FileSpec m_core_file;
111 lldb::DataBufferSP m_core_data;
112 llvm::ArrayRef<minidump::Thread> m_thread_list;
113 const minidump::ExceptionStream *m_active_exception;
114 lldb::CommandObjectSP m_command_sp;
115 bool m_is_wow64;
116 std::optional<MemoryRegionInfos> m_memory_regions;
118 void BuildMemoryRegions();
121 } // namespace minidump
122 } // namespace lldb_private
124 #endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_PROCESSMINIDUMP_H