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
57
58 // Returns AUXV structure found in the core file
60
61 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
62
63 Status DoDestroy() override;
64
65 void RefreshStateAfterStop() override;
66
67 bool IsAlive() override;
68
69 bool WarnBeforeDetach() const override;
70
71 bool ShouldUseMemoryCache(const ProcessAddress &process_addr) override;
72
73 size_t DoReadMemory(const ProcessAddress &addr, void *buf, size_t size,
74 Status &error) override;
75
77
78 Status
80
81 bool GetProcessInfo(ProcessInstanceInfo &info) override;
82
83 Status WillResume() override {
85 "error: {0} does not support resuming processes", GetPluginName());
86 }
87
88 std::optional<MinidumpParser> m_minidump_parser;
89
90protected:
91 void Clear();
92
93 bool DoUpdateThreadList(ThreadList &old_thread_list,
94 ThreadList &new_thread_list) override;
95
97 MemoryRegionInfo &range_info) override;
98
99 void ReadModuleList();
100
102 llvm::StringRef name,
103 lldb_private::ModuleSpec module_spec);
104
105 JITLoaderList &GetJITLoaders() override;
106
107private:
109 llvm::ArrayRef<minidump::Thread> m_thread_list;
110 std::unordered_map<uint32_t, const minidump::ExceptionStream>
114 std::optional<MemoryRegionInfos> m_memory_regions;
115
116 void BuildMemoryRegions();
117 bool IsLLDBMinidump();
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:32
An data extractor class.
A plug-in interface definition class for dynamic loaders.
A file utility class.
Definition FileSpec.h:56
Class used by the Process to hold a list of its JITLoaders.
PostMortemProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec &core_file)
An address in a process, qualified by an address space.
friend class ThreadList
Definition Process.h:376
An error handling class.
Definition Status.h:118
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
Definition Status.h:151
Represents UUID's of various sizes.
Definition UUID.h:27
bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override
Update the thread list following process plug-in's specific logic.
bool GetProcessInfo(ProcessInstanceInfo &info) override
static llvm::StringRef GetPluginNameStatic()
ProcessMinidump(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec &core_file, lldb::DataBufferSP code_data)
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)
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.
bool ShouldUseMemoryCache(const ProcessAddress &process_addr) override
Whether ReadMemory should serve reads of process_addr out of the memory cache.
size_t DoReadMemory(const ProcessAddress &addr, void *buf, size_t size, Status &error) override
Actually do the reading of memory from a 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
lldb_private::DataExtractor GetAuxvData() override
Status WillResume() override
Called before resuming to a process.
std::unordered_map< uint32_t, const minidump::ExceptionStream > m_exceptions_by_tid
DynamicLoader * GetDynamicLoader() override
Get the dynamic loader plug-in for this 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
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Listener > ListenerSP
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP