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
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#include <optional>
24
25namespace lldb_private {
26
27namespace minidump {
28
30public:
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
40 static llvm::StringRef GetPluginNameStatic() { return "minidump"; }
41
42 static llvm::StringRef 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 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
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 lldb_private::MemoryRegionInfos &region_list) override;
80
81 bool GetProcessInfo(ProcessInstanceInfo &info) override;
82
83 Status WillResume() override {
85 error.SetErrorStringWithFormatv(
86 "error: {0} does not support resuming processes", GetPluginName());
87 return error;
88 }
89
90 std::optional<MinidumpParser> m_minidump_parser;
91
92protected:
93 void Clear();
94
95 bool DoUpdateThreadList(ThreadList &old_thread_list,
96 ThreadList &new_thread_list) override;
97
99 MemoryRegionInfo &range_info) override;
100
101 void ReadModuleList();
102
104 llvm::StringRef name,
105 lldb_private::ModuleSpec module_spec);
106
107 JITLoaderList &GetJITLoaders() override;
108
109private:
111 llvm::ArrayRef<minidump::Thread> m_thread_list;
112 const minidump::ExceptionStream *m_active_exception;
115 std::optional<MemoryRegionInfos> m_memory_regions;
116
117 void BuildMemoryRegions();
118};
119
120} // namespace minidump
121} // namespace lldb_private
122
123#endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_PROCESSMINIDUMP_H
static llvm::raw_ostream & error(Stream &strm)
An architecture specification class.
Definition: ArchSpec.h:31
A plug-in interface definition class for dynamic loaders.
Definition: DynamicLoader.h:52
A file utility class.
Definition: FileSpec.h:56
Class used by the Process to hold a list of its JITLoaders.
Definition: JITLoaderList.h:22
Base class for all processes that don't represent a live process, such as coredumps or processes trac...
An error handling class.
Definition: Status.h:44
A plug-in interface definition class for system runtimes.
Definition: SystemRuntime.h:43
bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override
Update the thread list following process plug-in's specific logic.
const minidump::ExceptionStream * m_active_exception
SystemRuntime * GetSystemRuntime() override
Get the system runtime plug-in for this process.
bool GetProcessInfo(ProcessInstanceInfo &info) override
static llvm::StringRef GetPluginNameStatic()
DynamicLoader * GetDynamicLoader() override
Get the dynamic loader plug-in for this process.
bool IsAlive() override
Check if a process is still alive.
lldb::ModuleSP GetOrCreateModule(lldb_private::UUID minidump_uuid, llvm::StringRef name, lldb_private::ModuleSpec module_spec)
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Status &error) override
Actually do the reading of memory from a process.
CommandObject * GetPluginCommandObject() override
Return a multi-word command object that can be used to expose plug-in specific commands.
Status GetMemoryRegions(lldb_private::MemoryRegionInfos &region_list) override
Obtain all the mapped memory regions within this process.
llvm::StringRef GetPluginName() override
std::optional< MemoryRegionInfos > m_memory_regions
static llvm::StringRef GetPluginDescriptionStatic()
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect)
bool WarnBeforeDetach() const override
Before lldb detaches from a process, it warns the user that they are about to lose their debug sessio...
llvm::ArrayRef< minidump::Thread > m_thread_list
Status WillResume() override
Called before resuming to a process.
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
Status DoGetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) override
DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has removed non address bits from loa...
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
std::optional< MinidumpParser > m_minidump_parser
size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size, Status &error) override
Read of memory from a process.
JITLoaderList & GetJITLoaders() override
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
Definition: lldb-forward.h:325
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:381
std::shared_ptr< lldb_private::Listener > ListenerSP
Definition: lldb-forward.h:360
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
Definition: lldb-forward.h:328
uint64_t addr_t
Definition: lldb-types.h:79
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:436
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:365