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 
19 class ThreadKDP;
20 
22 public:
23  // Constructors and Destructors
24  ProcessMachCore(lldb::TargetSP target_sp, lldb::ListenerSP listener,
25  const lldb_private::FileSpec &core_file);
26 
27  ~ProcessMachCore() override;
28 
29  static lldb::ProcessSP
30  CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener,
31  const lldb_private::FileSpec *crash_file_path,
32  bool can_connect);
33 
34  static void Initialize();
35 
36  static void Terminate();
37 
39 
40  static const char *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
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 
73  lldb_private::MemoryRegionInfo &region_info) override;
74 
76 
77 protected:
78  friend class ThreadMachCore;
79 
80  void Clear();
81 
82  bool DoUpdateThreadList(lldb_private::ThreadList &old_thread_list,
83  lldb_private::ThreadList &new_thread_list) override;
84 
86 
87 private:
89 
91 
92  /// If a core file can be interpreted multiple ways, this establishes
93  /// which style wins.
94  ///
95  /// If a core file contains both a kernel binary and a user-process
96  /// dynamic loader, lldb needs to pick one over the other. This could
97  /// be a kernel corefile that happens to have a copy of dyld in its
98  /// memory. Or it could be a user process coredump of lldb while doing
99  /// kernel debugging - so a copy of the kernel is in its heap. This
100  /// should become a setting so it can be over-ridden when necessary.
102  // For now, if both user process and kernel binaries a present,
103  // assume this is a kernel coredump which has a copy of a user
104  // process dyld in one of its pages.
105  return eKernelCorefile;
106  }
107 
108  // For ProcessMachCore only
114 
117  lldb::ModuleSP m_core_module_sp;
122 };
123 
124 #endif // LLDB_SOURCE_PLUGINS_PROCESS_MACH_CORE_PROCESSMACHCORE_H
ProcessMachCore::GetPluginName
lldb_private::ConstString GetPluginName() override
Definition: ProcessMachCore.cpp:132
ThreadMachCore
Definition: ThreadMachCore.h:18
ProcessMachCore::GetPluginNameStatic
static lldb_private::ConstString GetPluginNameStatic()
Definition: ProcessMachCore.cpp:51
ProcessMachCore::ReadMemory
size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size, lldb_private::Status &error) override
Read of memory from a process.
Definition: ProcessMachCore.cpp:596
ProcessMachCore::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: ProcessMachCore.cpp:88
ProcessMachCore::m_core_module_sp
lldb::ModuleSP m_core_module_sp
Definition: ProcessMachCore.h:117
ProcessMachCore::Initialize
static void Initialize()
Definition: ProcessMachCore.cpp:696
ProcessMachCore::m_core_file
lldb_private::FileSpec m_core_file
Definition: ProcessMachCore.h:118
ProcessMachCore::m_mach_kernel_addr
lldb::addr_t m_mach_kernel_addr
Definition: ProcessMachCore.h:120
lldb_private::MemoryRegionInfo
Definition: MemoryRegionInfo.h:21
ProcessMachCore::GetCoreObjectFile
lldb_private::ObjectFile * GetCoreObjectFile()
Definition: ProcessMachCore.cpp:721
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
ProcessMachCore::DoDestroy
lldb_private::Status DoDestroy() override
Definition: ProcessMachCore.cpp:587
lldb_private::FileSpec
Definition: FileSpec.h:56
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
ProcessMachCore
Definition: ProcessMachCore.h:21
ProcessMachCore::GetDynamicLoader
lldb_private::DynamicLoader * GetDynamicLoader() override
Get the dynamic loader plug-in for this process.
Definition: ProcessMachCore.cpp:550
ProcessMachCore::RefreshStateAfterStop
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
Definition: ProcessMachCore.cpp:580
ProcessMachCore::Clear
void Clear()
Definition: ProcessMachCore.cpp:694
ProcessMachCore::VMRangeToPermissions
lldb_private::RangeDataVector< lldb::addr_t, lldb::addr_t, uint32_t > VMRangeToPermissions
Definition: ProcessMachCore.h:113
ProcessMachCore::GetCorefilePreference
CorefilePreference GetCorefilePreference()
If a core file can be interpreted multiple ways, this establishes which style wins.
Definition: ProcessMachCore.h:101
ProcessMachCore::VMRangeToFileOffset
lldb_private::RangeDataVector< lldb::addr_t, lldb::addr_t, FileRange > VMRangeToFileOffset
Definition: ProcessMachCore.h:111
ProcessMachCore::~ProcessMachCore
~ProcessMachCore() override
Definition: ProcessMachCore.cpp:122
ProcessMachCore::m_dyld_plugin_name
lldb_private::ConstString m_dyld_plugin_name
Definition: ProcessMachCore.h:121
ProcessMachCore::DoReadMemory
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.
Definition: ProcessMachCore.cpp:603
lldb_private::ThreadList
Definition: ThreadList.h:26
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::PostMortemProcess
Definition: PostMortemProcess.h:23
ProcessMachCore::IsAlive
bool IsAlive() override
Check if a process is still alive.
Definition: ProcessMachCore.cpp:591
lldb_private::Range< lldb::addr_t, lldb::addr_t >
lldb_private::DynamicLoader
Definition: DynamicLoader.h:52
ThreadKDP
Definition: ThreadKDP.h:19
ProcessMachCore::FileRange
lldb_private::Range< lldb::addr_t, lldb::addr_t > FileRange
Definition: ProcessMachCore.h:109
ProcessMachCore::ProcessMachCore
ProcessMachCore(lldb::TargetSP target_sp, lldb::ListenerSP listener, const lldb_private::FileSpec &core_file)
Definition: ProcessMachCore.cpp:113
PostMortemProcess.h
ProcessMachCore::CreateInstance
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener, const lldb_private::FileSpec *crash_file_path, bool can_connect)
Definition: ProcessMachCore.cpp:64
lldb_private::Status
Definition: Status.h:44
lldb_private::RangeDataVector< lldb::addr_t, lldb::addr_t, FileRange >
ProcessMachCore::eKernelCorefile
@ eKernelCorefile
Definition: ProcessMachCore.h:90
ProcessMachCore::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: ProcessMachCore.cpp:593
ProcessMachCore::GetDynamicLoaderAddress
bool GetDynamicLoaderAddress(lldb::addr_t addr)
Definition: ProcessMachCore.cpp:134
ProcessMachCore::CorefilePreference
CorefilePreference
Definition: ProcessMachCore.h:90
ProcessMachCore::GetPluginDescriptionStatic
static const char * GetPluginDescriptionStatic()
Definition: ProcessMachCore.cpp:56
Status.h
ProcessMachCore::DoUpdateThreadList
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.
Definition: ProcessMachCore.cpp:558
ConstString.h
ProcessMachCore::GetImageInfoAddress
lldb::addr_t GetImageInfoAddress() override
Get the image information address for the current process.
Definition: ProcessMachCore.cpp:705
ProcessMachCore::GetMemoryRegionInfo
lldb_private::Status GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &region_info) override
Locate the memory region that contains load_addr.
Definition: ProcessMachCore.cpp:654
ProcessMachCore::eUserProcessCorefile
@ eUserProcessCorefile
Definition: ProcessMachCore.h:90
ProcessMachCore::Terminate
static void Terminate()
Definition: ProcessMachCore.cpp:60
ProcessMachCore::m_core_range_infos
VMRangeToPermissions m_core_range_infos
Definition: ProcessMachCore.h:116
ProcessMachCore::DoLoadCore
lldb_private::Status DoLoadCore() override
Definition: ProcessMachCore.cpp:245
lldb_private::ObjectFile
Definition: ObjectFile.h:58
ProcessMachCore::m_core_aranges
VMRangeToFileOffset m_core_aranges
Definition: ProcessMachCore.h:115
ProcessMachCore::m_dyld_addr
lldb::addr_t m_dyld_addr
Definition: ProcessMachCore.h:119