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 // Returns AUXV structure found in the core file
58
59 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
60
61 Status DoDestroy() override;
62
63 void RefreshStateAfterStop() override;
64
65 bool IsAlive() override;
66
67 bool WarnBeforeDetach() const override;
68
69 size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size,
70 Status &error) override;
71
72 size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
73 Status &error) override;
74
76
78 lldb_private::MemoryRegionInfos &region_list) override;
79
80 bool GetProcessInfo(ProcessInstanceInfo &info) override;
81
82 Status WillResume() override {
84 "error: {0} does not support resuming processes", GetPluginName());
85 }
86
87 std::optional<MinidumpParser> m_minidump_parser;
88
89protected:
90 void Clear();
91
92 bool DoUpdateThreadList(ThreadList &old_thread_list,
93 ThreadList &new_thread_list) override;
94
96 MemoryRegionInfo &range_info) override;
97
98 void ReadModuleList();
99
101 llvm::StringRef name,
102 lldb_private::ModuleSpec module_spec);
103
104 JITLoaderList &GetJITLoaders() override;
105
106private:
108 llvm::ArrayRef<minidump::Thread> m_thread_list;
109 std::unordered_map<uint32_t, const minidump::ExceptionStream>
113 std::optional<MemoryRegionInfos> m_memory_regions;
114
115 void BuildMemoryRegions();
116};
117
118} // namespace minidump
119} // namespace lldb_private
120
121#endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_PROCESSMINIDUMP_H
static llvm::raw_ostream & error(Stream &strm)
An architecture specification class.
Definition: ArchSpec.h:31
An data extractor class.
Definition: DataExtractor.h:48
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:115
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
Definition: Status.h:148
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()
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
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
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.
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
Definition: lldb-forward.h:333
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:389
std::shared_ptr< lldb_private::Listener > ListenerSP
Definition: lldb-forward.h:368
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
Definition: lldb-forward.h:336
uint64_t addr_t
Definition: lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:448
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:373