LLDB  mainline
ProcessMinidump.h
Go to the documentation of this file.
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 LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_PROCESSMINIDUMP_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_PROCESSMINIDUMP_H
11 
12 #include "MinidumpParser.h"
13 #include "MinidumpTypes.h"
14 
16 #include "lldb/Target/StopInfo.h"
17 #include "lldb/Target/Target.h"
19 #include "lldb/Utility/Status.h"
20 
21 #include "llvm/Support/Format.h"
22 #include "llvm/Support/raw_ostream.h"
23 
24 
25 namespace lldb_private {
26 
27 namespace minidump {
28 
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);
35 
36  static void Initialize();
37 
38  static void Terminate();
39 
41 
42  static const char *GetPluginDescriptionStatic();
43 
44  ProcessMinidump(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
45  const FileSpec &core_file, lldb::DataBufferSP code_data);
46 
47  ~ProcessMinidump() override;
48 
49  bool CanDebug(lldb::TargetSP target_sp,
50  bool plugin_specified_by_name) override;
51 
53 
54  Status DoLoadCore() override;
55 
56  DynamicLoader *GetDynamicLoader() override { return nullptr; }
57 
58  ConstString GetPluginName() override;
59 
60  SystemRuntime *GetSystemRuntime() override { return nullptr; }
61 
62  Status DoDestroy() override;
63 
64  void RefreshStateAfterStop() override;
65 
66  bool IsAlive() override;
67 
68  bool WarnBeforeDetach() const override;
69 
70  size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size,
71  Status &error) override;
72 
73  size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
74  Status &error) override;
75 
77 
79  MemoryRegionInfo &range_info) override;
80 
82  lldb_private::MemoryRegionInfos &region_list) override;
83 
84  bool GetProcessInfo(ProcessInstanceInfo &info) override;
85 
86  Status WillResume() override {
87  Status error;
88  error.SetErrorStringWithFormat(
89  "error: %s does not support resuming processes",
90  GetPluginName().GetCString());
91  return error;
92  }
93 
94  llvm::Optional<MinidumpParser> m_minidump_parser;
95 
96 protected:
97  void Clear();
98 
99  bool DoUpdateThreadList(ThreadList &old_thread_list,
100  ThreadList &new_thread_list) override;
101 
102  void ReadModuleList();
103 
104  lldb::ModuleSP GetOrCreateModule(lldb_private::UUID minidump_uuid,
105  llvm::StringRef name,
106  lldb_private::ModuleSpec module_spec);
107 
108  JITLoaderList &GetJITLoaders() override;
109 
110 private:
112  lldb::DataBufferSP m_core_data;
113  llvm::ArrayRef<minidump::Thread> m_thread_list;
114  const minidump::ExceptionStream *m_active_exception;
115  lldb::CommandObjectSP m_command_sp;
117  llvm::Optional<MemoryRegionInfos> m_memory_regions;
118 
119  void BuildMemoryRegions();
120 };
121 
122 } // namespace minidump
123 } // namespace lldb_private
124 
125 #endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_PROCESSMINIDUMP_H
lldb_private::ProcessInstanceInfo
Definition: ProcessInfo.h:108
lldb_private::UUID
Definition: UUID.h:23
lldb_private::minidump::ProcessMinidump::m_memory_regions
llvm::Optional< MemoryRegionInfos > m_memory_regions
Definition: ProcessMinidump.h:117
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::minidump::ProcessMinidump::GetPluginCommandObject
CommandObject * GetPluginCommandObject() override
Return a multi-word command object that can be used to expose plug-in specific commands.
Definition: ProcessMinidump.cpp:1003
lldb_private::JITLoaderList
Definition: JITLoaderList.h:22
lldb_private::minidump::ProcessMinidump::RefreshStateAfterStop
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
Definition: ProcessMinidump.cpp:311
lldb_private::minidump::ProcessMinidump::Initialize
static void Initialize()
Definition: ProcessMinidump.cpp:249
lldb_private::minidump::ProcessMinidump::GetJITLoaders
JITLoaderList & GetJITLoaders() override
Definition: ProcessMinidump.cpp:632
MinidumpTypes.h
lldb_private::minidump::ProcessMinidump::BuildMemoryRegions
void BuildMemoryRegions()
Definition: ProcessMinidump.cpp:405
lldb_private::SystemRuntime
Definition: SystemRuntime.h:43
lldb_private::MemoryRegionInfo
Definition: MemoryRegionInfo.h:21
lldb_private::minidump::ProcessMinidump::GetOrCreateModule
lldb::ModuleSP GetOrCreateModule(lldb_private::UUID minidump_uuid, llvm::StringRef name, lldb_private::ModuleSpec module_spec)
Definition: ProcessMinidump.cpp:485
lldb_private::minidump::ProcessMinidump::m_core_file
FileSpec m_core_file
Definition: ProcessMinidump.h:111
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::minidump::ProcessMinidump::GetMemoryRegions
Status GetMemoryRegions(lldb_private::MemoryRegionInfos &region_list) override
Obtain all the mapped memory regions within this process.
Definition: ProcessMinidump.cpp:454
lldb_private::minidump::ProcessMinidump::WillResume
Status WillResume() override
Called before resuming to a process.
Definition: ProcessMinidump.h:86
lldb_private::minidump::ProcessMinidump::m_core_data
lldb::DataBufferSP m_core_data
Definition: ProcessMinidump.h:112
Target.h
lldb_private::minidump::ProcessMinidump::~ProcessMinidump
~ProcessMinidump() override
Definition: ProcessMinidump.cpp:240
lldb_private::minidump::ProcessMinidump::GetPluginName
ConstString GetPluginName() override
Definition: ProcessMinidump.cpp:307
lldb_private::minidump::ProcessMinidump::GetPluginDescriptionStatic
static const char * GetPluginDescriptionStatic()
Definition: ProcessMinidump.cpp:196
lldb_private::FileSpec
Definition: FileSpec.h:56
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
MinidumpParser.h
lldb_private::minidump::ProcessMinidump::GetPluginNameStatic
static ConstString GetPluginNameStatic()
Definition: ProcessMinidump.cpp:191
lldb_private::minidump::ProcessMinidump::GetSystemRuntime
SystemRuntime * GetSystemRuntime() override
Get the system runtime plug-in for this process.
Definition: ProcessMinidump.h:60
lldb_private::minidump::ProcessMinidump
Definition: ProcessMinidump.h:29
lldb_private::minidump::ProcessMinidump::Clear
void Clear()
Definition: ProcessMinidump.cpp:460
lldb_private::MemoryRegionInfos
Definition: MemoryRegionInfo.h:164
lldb_private::ThreadList
Definition: ThreadList.h:26
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::minidump::ProcessMinidump::CreateInstance
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect)
Definition: ProcessMinidump.cpp:200
lldb_private::PostMortemProcess
Definition: PostMortemProcess.h:23
lldb_private::DynamicLoader
Definition: DynamicLoader.h:52
lldb_private::minidump::ProcessMinidump::m_is_wow64
bool m_is_wow64
Definition: ProcessMinidump.h:116
lldb_private::minidump::ProcessMinidump::GetDynamicLoader
DynamicLoader * GetDynamicLoader() override
Get the dynamic loader plug-in for this process.
Definition: ProcessMinidump.h:56
lldb_private::minidump::ProcessMinidump::GetMemoryRegionInfo
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) override
Locate the memory region that contains load_addr.
Definition: ProcessMinidump.cpp:447
PostMortemProcess.h
lldb_private::minidump::ProcessMinidump::m_thread_list
llvm::ArrayRef< minidump::Thread > m_thread_list
Definition: ProcessMinidump.h:113
lldb_private::CommandObject
Definition: CommandObject.h:67
lldb_private::minidump::ProcessMinidump::DoDestroy
Status DoDestroy() override
Definition: ProcessMinidump.cpp:309
lldb_private::minidump::ProcessMinidump::m_minidump_parser
llvm::Optional< MinidumpParser > m_minidump_parser
Definition: ProcessMinidump.h:94
lldb_private::minidump::ProcessMinidump::DoReadMemory
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Status &error) override
Actually do the reading of memory from a process.
Definition: ProcessMinidump.cpp:380
lldb_private::ModuleSpec
Definition: ModuleSpec.h:26
lldb_private::Status
Definition: Status.h:44
lldb_private::minidump::ProcessMinidump::DoUpdateThreadList
bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override
Update the thread list following process plug-in's specific logic.
Definition: ProcessMinidump.cpp:462
lldb_private::minidump::ProcessMinidump::GetArchitecture
ArchSpec GetArchitecture()
Definition: ProcessMinidump.cpp:393
lldb_private::minidump::ProcessMinidump::ReadMemory
size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size, Status &error) override
Read of memory from a process.
Definition: ProcessMinidump.cpp:373
lldb_private::minidump::ProcessMinidump::m_command_sp
lldb::CommandObjectSP m_command_sp
Definition: ProcessMinidump.h:115
lldb_private::minidump::ProcessMinidump::DoLoadCore
Status DoLoadCore() override
Definition: ProcessMinidump.cpp:263
lldb_private::minidump::ProcessMinidump::WarnBeforeDetach
bool WarnBeforeDetach() const override
Before lldb detaches from a process, it warns the user that they are about to lose their debug sessio...
Definition: ProcessMinidump.cpp:371
lldb_private::minidump::ProcessMinidump::ReadModuleList
void ReadModuleList()
Definition: ProcessMinidump.cpp:532
StopInfo.h
lldb_private::minidump::ProcessMinidump::m_active_exception
const minidump::ExceptionStream * m_active_exception
Definition: ProcessMinidump.h:114
lldb_private::minidump::ProcessMinidump::ProcessMinidump
ProcessMinidump(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec &core_file, lldb::DataBufferSP code_data)
Definition: ProcessMinidump.cpp:233
lldb_private::minidump::ProcessMinidump::GetProcessInfo
bool GetProcessInfo(ProcessInstanceInfo &info) override
Definition: ProcessMinidump.cpp:615
Status.h
lldb_private::minidump::ProcessMinidump::Terminate
static void Terminate()
Definition: ProcessMinidump.cpp:259
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
ConstString.h
lldb_private::minidump::ProcessMinidump::IsAlive
bool IsAlive() override
Check if a process is still alive.
Definition: ProcessMinidump.cpp:369
lldb_private::minidump::ProcessMinidump::CanDebug
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
Definition: ProcessMinidump.cpp:228