LLDB mainline
ProcessMachCore.h
Go to the documentation of this file.
1//===-- ProcessMachCore.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_MACH_CORE_PROCESSMACHCORE_H
10#define LLDB_SOURCE_PLUGINS_PROCESS_MACH_CORE_PROCESSMACHCORE_H
11
12#include <list>
13#include <vector>
14
17#include "lldb/Utility/Status.h"
18
19class ThreadKDP;
20
22public:
23 // Constructors and Destructors
25 const lldb_private::FileSpec &core_file);
26
27 ~ProcessMachCore() override;
28
29 static lldb::ProcessSP
31 const lldb_private::FileSpec *crash_file_path,
32 bool can_connect);
33
34 static void Initialize();
35
36 static void Terminate();
37
38 static llvm::StringRef GetPluginNameStatic() { return "mach-o-core"; }
39
40 static llvm::StringRef GetPluginDescriptionStatic();
41
42 // Check if a given Process
43 bool CanDebug(lldb::TargetSP target_sp,
44 bool plugin_specified_by_name) override;
45
46 // Creating a new process, or attaching to an existing one
48
50
51 // PluginInterface protocol
52 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
53
54 // Process Control
56
57 void RefreshStateAfterStop() override;
58
59 // Process Queries
60 bool IsAlive() override;
61
62 bool WarnBeforeDetach() const override;
63
64 // Process Memory
65 size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size,
66 lldb_private::Status &error) override;
67
68 size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
69 lldb_private::Status &error) override;
70
72
73protected:
74 friend class ThreadMachCore;
75
76 void Clear();
77
78 bool DoUpdateThreadList(lldb_private::ThreadList &old_thread_list,
79 lldb_private::ThreadList &new_thread_list) override;
80
82
85 lldb_private::MemoryRegionInfo &region_info) override;
86
87private:
89
91
92 /// \return
93 /// True if any metadata were found indicating the binary that should
94 /// be loaded, regardless of whether the specified binary could be found.
95 /// False if no metadata were present.
97
101
103 lldb::addr_t &kernel);
104
106
107 /// If a core file can be interpreted multiple ways, this establishes
108 /// which style wins.
109 ///
110 /// If a core file contains both a kernel binary and a user-process
111 /// dynamic loader, lldb needs to pick one over the other. This could
112 /// be a kernel corefile that happens to have a copy of dyld in its
113 /// memory. Or it could be a user process coredump of lldb while doing
114 /// kernel debugging - so a copy of the kernel is in its heap. This
115 /// should become a setting so it can be over-ridden when necessary.
117 // For now, if both user process and kernel binaries a present,
118 // assume this is a kernel coredump which has a copy of a user
119 // process dyld in one of its pages.
120 return eKernelCorefile;
121 }
122
123 // For ProcessMachCore only
129
135 llvm::StringRef m_dyld_plugin_name;
136};
137
138#endif // LLDB_SOURCE_PLUGINS_PROCESS_MACH_CORE_PROCESSMACHCORE_H
static llvm::raw_ostream & error(Stream &strm)
lldb::addr_t m_dyld_addr
bool WarnBeforeDetach() const override
Before lldb detaches from a process, it warns the user that they are about to lose their debug sessio...
static llvm::StringRef GetPluginDescriptionStatic()
static void Initialize()
size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size, lldb_private::Status &error) override
Read of memory from a process.
bool LoadBinaryViaLowmemUUID()
VMRangeToFileOffset m_core_aranges
bool LoadBinariesViaMetadata()
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size, lldb_private::Status &error) override
Actually do the reading of memory from a process.
CorefilePreference GetCorefilePreference()
If a core file can be interpreted multiple ways, this establishes which style wins.
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
void CleanupMemoryRegionPermissions()
lldb_private::ObjectFile * GetCoreObjectFile()
llvm::StringRef m_dyld_plugin_name
lldb_private::DynamicLoader * GetDynamicLoader() override
Get the dynamic loader plug-in for this process.
lldb_private::Status DoDestroy() override
lldb_private::RangeDataVector< lldb::addr_t, lldb::addr_t, FileRange > VMRangeToFileOffset
lldb_private::RangeDataVector< lldb::addr_t, lldb::addr_t, uint32_t > VMRangeToPermissions
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener, const lldb_private::FileSpec *crash_file_path, bool can_connect)
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
bool DoUpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list) override
Update the thread list following process plug-in's specific logic.
static llvm::StringRef GetPluginNameStatic()
bool IsAlive() override
Check if a process is still alive.
bool CheckAddressForDyldOrKernel(lldb::addr_t addr, lldb::addr_t &dyld, lldb::addr_t &kernel)
lldb_private::Range< lldb::addr_t, lldb::addr_t > FileRange
VMRangeToPermissions m_core_range_infos
lldb_private::Status DoLoadCore() override
void LoadBinariesViaExhaustiveSearch()
llvm::StringRef GetPluginName() override
lldb::addr_t m_mach_kernel_addr
lldb::addr_t GetImageInfoAddress() override
Get the image information address for the current process.
~ProcessMachCore() override
lldb::ModuleSP m_core_module_sp
lldb_private::Status DoGetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &region_info) override
DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has removed non address bits from loa...
static void Terminate()
A plug-in interface definition class for dynamic loaders.
Definition: DynamicLoader.h:53
A file utility class.
Definition: FileSpec.h:56
A plug-in interface definition class for object file parsers.
Definition: ObjectFile.h:44
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
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:387
std::shared_ptr< lldb_private::Listener > ListenerSP
Definition: lldb-forward.h:366
uint64_t addr_t
Definition: lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:444
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:371