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 
15 #include "lldb/Target/Process.h"
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 
33  static void Initialize();
34 
35  static void Terminate();
36 
38 
39  static const char *GetPluginDescriptionStatic();
40 
41  // Check if a given Process
42  bool CanDebug(lldb::TargetSP target_sp,
43  bool plugin_specified_by_name) override;
44 
45  // Creating a new process, or attaching to an existing one
47 
49 
50  // PluginInterface protocol
52 
53  uint32_t GetPluginVersion() override;
54 
55  // Process Control
57 
58  void RefreshStateAfterStop() override;
59 
60  // Process Queries
61  bool IsAlive() override;
62 
63  bool WarnBeforeDetach() const override;
64 
65  // Process Memory
66  size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size,
67  lldb_private::Status &error) override;
68 
69  size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
70  lldb_private::Status &error) override;
71 
74  lldb_private::MemoryRegionInfo &region_info) override;
75 
77 
78 protected:
79  friend class ThreadMachCore;
80 
81  void Clear();
82 
83  bool UpdateThreadList(lldb_private::ThreadList &old_thread_list,
84  lldb_private::ThreadList &new_thread_list) override;
85 
87 
88 private:
90 
92 
93  /// If a core file can be interpreted multiple ways, this establishes
94  /// which style wins.
95  ///
96  /// If a core file contains both a kernel binary and a user-process
97  /// dynamic loader, lldb needs to pick one over the other. This could
98  /// be a kernel corefile that happens to have a copy of dyld in its
99  /// memory. Or it could be a user process coredump of lldb while doing
100  /// kernel debugging - so a copy of the kernel is in its heap. This
101  /// should become a setting so it can be over-ridden when necessary.
103  // For now, if both user process and kernel binaries a present,
104  // assume this is a kernel coredump which has a copy of a user
105  // process dyld in one of its pages.
106  return eKernelCorefile;
107  }
108 
109  // For ProcessMachCore only
115 
118  lldb::ModuleSP m_core_module_sp;
123 
124  ProcessMachCore(const ProcessMachCore &) = delete;
125  const ProcessMachCore &operator=(const ProcessMachCore &) = delete;
126 };
127 
128 #endif // LLDB_SOURCE_PLUGINS_PROCESS_MACH_CORE_PROCESSMACHCORE_H
bool GetDynamicLoaderAddress(lldb::addr_t 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 const char * GetPluginDescriptionStatic()
lldb::addr_t m_mach_kernel_addr
A file utility class.
Definition: FileSpec.h:56
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener, const lldb_private::FileSpec *crash_file_path)
lldb_private::RangeDataVector< lldb::addr_t, lldb::addr_t, uint32_t > VMRangeToPermissions
A plug-in interface definition class for object file parsers.
Definition: ObjectFile.h:58
bool IsAlive() override
Check if a process is still alive.
lldb_private::ObjectFile * GetCoreObjectFile()
size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size, lldb_private::Status &error) override
Read of memory from a process.
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
lldb_private::RangeDataVector< lldb::addr_t, lldb::addr_t, FileRange > VMRangeToFileOffset
const ProcessMachCore & operator=(const ProcessMachCore &)=delete
static llvm::raw_ostream & error(Stream &strm)
VMRangeToFileOffset m_core_aranges
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.
lldb_private::Range< lldb::addr_t, lldb::addr_t > FileRange
A plug-in interface definition class for debugging a process.
Definition: Process.h:362
lldb::ModuleSP m_core_module_sp
lldb_private::Status GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &region_info) override
Locate the memory region that contains load_addr.
lldb_private::DynamicLoader * GetDynamicLoader() override
Get the dynamic loader plug-in for this process.
A plug-in interface definition class for dynamic loaders.
Definition: DynamicLoader.h:52
static void Terminate()
CorefilePreference GetCorefilePreference()
If a core file can be interpreted multiple ways, this establishes which style wins.
lldb_private::ConstString m_dyld_plugin_name
lldb_private::FileSpec m_core_file
~ProcessMachCore() override
lldb::addr_t m_dyld_addr
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::Status DoDestroy() override
A uniqued constant string class.
Definition: ConstString.h:40
lldb_private::Status DoLoadCore() override
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
lldb_private::ConstString GetPluginName() override
bool UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list) override
lldb::addr_t GetImageInfoAddress() override
Get the image information address for the current process.
ProcessMachCore(lldb::TargetSP target_sp, lldb::ListenerSP listener, const lldb_private::FileSpec &core_file)
uint32_t GetPluginVersion() override
VMRangeToPermissions m_core_range_infos
static lldb_private::ConstString GetPluginNameStatic()
static void Initialize()
An error handling class.
Definition: Status.h:44