Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 1 | //===-- NativeProcessLinux.h ---------------------------------- -*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef liblldb_NativeProcessLinux_H_ |
| 11 | #define liblldb_NativeProcessLinux_H_ |
| 12 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 13 | // C++ Includes |
| 14 | #include <unordered_set> |
| 15 | |
| 16 | // Other libraries and framework includes |
| 17 | #include "lldb/Core/ArchSpec.h" |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 18 | #include "lldb/Host/Debug.h" |
Zachary Turner | 39de311 | 2014-09-09 20:54:56 +0000 | [diff] [blame] | 19 | #include "lldb/Host/HostThread.h" |
Pavel Labath | b7f0f45 | 2017-03-17 11:08:40 +0000 | [diff] [blame] | 20 | #include "lldb/Host/linux/Support.h" |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 21 | #include "lldb/Target/MemoryRegionInfo.h" |
Zachary Turner | 5713a05 | 2017-03-22 18:40:07 +0000 | [diff] [blame] | 22 | #include "lldb/Utility/FileSpec.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 23 | #include "lldb/lldb-types.h" |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 24 | |
Pavel Labath | 8c8ff7a | 2015-05-11 10:03:10 +0000 | [diff] [blame] | 25 | #include "NativeThreadLinux.h" |
Ravitheja Addepally | 99e3769 | 2017-06-28 07:58:31 +0000 | [diff] [blame^] | 26 | #include "ProcessorTrace.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 27 | #include "lldb/Host/common/NativeProcessProtocol.h" |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 28 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 29 | namespace lldb_private { |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 30 | class Status; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 31 | class Scalar; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 32 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 33 | namespace process_linux { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 34 | /// @class NativeProcessLinux |
| 35 | /// @brief Manages communication with the inferior (debugee) process. |
| 36 | /// |
| 37 | /// Upon construction, this class prepares and launches an inferior process for |
| 38 | /// debugging. |
| 39 | /// |
| 40 | /// Changes in the inferior process state are broadcasted. |
| 41 | class NativeProcessLinux : public NativeProcessProtocol { |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 42 | friend Status NativeProcessProtocol::Launch( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 43 | ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate, |
| 44 | MainLoop &mainloop, NativeProcessProtocolSP &process_sp); |
Pavel Labath | d5b310f | 2015-07-09 11:51:11 +0000 | [diff] [blame] | 45 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 46 | friend Status NativeProcessProtocol::Attach( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 47 | lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate, |
| 48 | MainLoop &mainloop, NativeProcessProtocolSP &process_sp); |
Pavel Labath | d5b310f | 2015-07-09 11:51:11 +0000 | [diff] [blame] | 49 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 50 | public: |
| 51 | // --------------------------------------------------------------------- |
| 52 | // NativeProcessProtocol Interface |
| 53 | // --------------------------------------------------------------------- |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 54 | Status Resume(const ResumeActionList &resume_actions) override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 55 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 56 | Status Halt() override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 57 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 58 | Status Detach() override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 59 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 60 | Status Signal(int signo) override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 61 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 62 | Status Interrupt() override; |
Chaoren Lin | e9547b8 | 2015-02-03 01:51:00 +0000 | [diff] [blame] | 63 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 64 | Status Kill() override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 65 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 66 | Status GetMemoryRegionInfo(lldb::addr_t load_addr, |
| 67 | MemoryRegionInfo &range_info) override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 68 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 69 | Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, |
| 70 | size_t &bytes_read) override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 71 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 72 | Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, |
| 73 | size_t &bytes_read) override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 74 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 75 | Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, |
| 76 | size_t &bytes_written) override; |
Chaoren Lin | 3eb4b45 | 2015-04-29 17:24:48 +0000 | [diff] [blame] | 77 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 78 | Status AllocateMemory(size_t size, uint32_t permissions, |
| 79 | lldb::addr_t &addr) override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 80 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 81 | Status DeallocateMemory(lldb::addr_t addr) override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 82 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 83 | lldb::addr_t GetSharedLibraryInfoAddress() override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 84 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 85 | size_t UpdateThreads() override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 86 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 87 | bool GetArchitecture(ArchSpec &arch) const override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 88 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 89 | Status SetBreakpoint(lldb::addr_t addr, uint32_t size, |
| 90 | bool hardware) override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 91 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 92 | Status RemoveBreakpoint(lldb::addr_t addr, bool hardware = false) override; |
Omair Javaid | d5ffbad | 2017-02-24 13:27:31 +0000 | [diff] [blame] | 93 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 94 | void DoStopIDBumped(uint32_t newBumpId) override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 95 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 96 | Status GetLoadedModuleFileSpec(const char *module_path, |
| 97 | FileSpec &file_spec) override; |
Tamas Berghammer | 068f8a7 | 2015-05-26 11:58:52 +0000 | [diff] [blame] | 98 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 99 | Status GetFileLoadAddress(const llvm::StringRef &file_name, |
| 100 | lldb::addr_t &load_addr) override; |
Tamas Berghammer | 783bfc8 | 2015-06-18 20:43:56 +0000 | [diff] [blame] | 101 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 102 | NativeThreadLinuxSP GetThreadByID(lldb::tid_t id); |
Pavel Labath | f907778 | 2015-08-21 09:13:53 +0000 | [diff] [blame] | 103 | |
Pavel Labath | b7f0f45 | 2017-03-17 11:08:40 +0000 | [diff] [blame] | 104 | llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> |
| 105 | GetAuxvData() const override { |
| 106 | return getProcFile(GetID(), "auxv"); |
| 107 | } |
| 108 | |
Ravitheja Addepally | 99e3769 | 2017-06-28 07:58:31 +0000 | [diff] [blame^] | 109 | lldb::user_id_t StartTrace(const TraceOptions &config, |
| 110 | Status &error) override; |
| 111 | |
| 112 | Status StopTrace(lldb::user_id_t traceid, |
| 113 | lldb::tid_t thread) override; |
| 114 | |
| 115 | Status GetData(lldb::user_id_t traceid, lldb::tid_t thread, |
| 116 | llvm::MutableArrayRef<uint8_t> &buffer, |
| 117 | size_t offset = 0) override; |
| 118 | |
| 119 | Status GetMetaData(lldb::user_id_t traceid, lldb::tid_t thread, |
| 120 | llvm::MutableArrayRef<uint8_t> &buffer, |
| 121 | size_t offset = 0) override; |
| 122 | |
| 123 | Status GetTraceConfig(lldb::user_id_t traceid, TraceOptions &config) override; |
| 124 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 125 | // --------------------------------------------------------------------- |
| 126 | // Interface used by NativeRegisterContext-derived classes. |
| 127 | // --------------------------------------------------------------------- |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 128 | static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr, |
| 129 | void *data = nullptr, size_t data_size = 0, |
| 130 | long *result = nullptr); |
Tamas Berghammer | 7cb18bf | 2015-03-24 11:15:23 +0000 | [diff] [blame] | 131 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 132 | bool SupportHardwareSingleStepping() const; |
Pavel Labath | 605b51b | 2016-02-23 13:56:30 +0000 | [diff] [blame] | 133 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 134 | protected: |
| 135 | // --------------------------------------------------------------------- |
| 136 | // NativeProcessProtocol protected interface |
| 137 | // --------------------------------------------------------------------- |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 138 | Status |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 139 | GetSoftwareBreakpointTrapOpcode(size_t trap_opcode_size_hint, |
| 140 | size_t &actual_opcode_size, |
| 141 | const uint8_t *&trap_opcode_bytes) override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 142 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 143 | private: |
| 144 | MainLoop::SignalHandleUP m_sigchld_handle; |
| 145 | ArchSpec m_arch; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 146 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 147 | LazyBool m_supports_mem_region; |
Tamas Berghammer | a6f5795 | 2017-01-03 16:29:43 +0000 | [diff] [blame] | 148 | std::vector<std::pair<MemoryRegionInfo, FileSpec>> m_mem_region_cache; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 149 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 150 | lldb::tid_t m_pending_notification_tid; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 151 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 152 | // List of thread ids stepping with a breakpoint with the address of |
| 153 | // the relevan breakpoint |
| 154 | std::map<lldb::tid_t, lldb::addr_t> m_threads_stepping_with_breakpoint; |
Pavel Labath | 0e1d729 | 2015-08-20 09:06:12 +0000 | [diff] [blame] | 155 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 156 | // --------------------------------------------------------------------- |
| 157 | // Private Instance Methods |
| 158 | // --------------------------------------------------------------------- |
| 159 | NativeProcessLinux(); |
Tamas Berghammer | d8c338d | 2015-04-15 09:47:02 +0000 | [diff] [blame] | 160 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 161 | Status LaunchInferior(MainLoop &mainloop, ProcessLaunchInfo &launch_info); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 162 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 163 | /// Attaches to an existing process. Forms the |
| 164 | /// implementation of Process::DoAttach |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 165 | void AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, Status &error); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 166 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 167 | ::pid_t Attach(lldb::pid_t pid, Status &error); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 168 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 169 | static Status SetDefaultPtraceOpts(const lldb::pid_t); |
Pavel Labath | 1107b5a | 2015-04-17 14:07:49 +0000 | [diff] [blame] | 170 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 171 | static void *MonitorThread(void *baton); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 172 | |
Pavel Labath | 3508fc8 | 2017-06-19 12:47:50 +0000 | [diff] [blame] | 173 | void MonitorCallback(lldb::pid_t pid, bool exited, WaitStatus status); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 174 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 175 | void WaitForNewThread(::pid_t tid); |
Pavel Labath | 1107b5a | 2015-04-17 14:07:49 +0000 | [diff] [blame] | 176 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 177 | void MonitorSIGTRAP(const siginfo_t &info, NativeThreadLinux &thread); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 178 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 179 | void MonitorTrace(NativeThreadLinux &thread); |
Pavel Labath | 426bdf8 | 2015-04-28 07:51:52 +0000 | [diff] [blame] | 180 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 181 | void MonitorBreakpoint(NativeThreadLinux &thread); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 182 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 183 | void MonitorWatchpoint(NativeThreadLinux &thread, uint32_t wp_index); |
Chaoren Lin | c16f5dc | 2015-03-19 23:28:10 +0000 | [diff] [blame] | 184 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 185 | void MonitorSignal(const siginfo_t &info, NativeThreadLinux &thread, |
| 186 | bool exited); |
Chaoren Lin | c16f5dc | 2015-03-19 23:28:10 +0000 | [diff] [blame] | 187 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 188 | Status SetupSoftwareSingleStepping(NativeThreadLinux &thread); |
Tamas Berghammer | e770868 | 2015-04-22 10:00:23 +0000 | [diff] [blame] | 189 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 190 | #if 0 |
| 191 | static ::ProcessMessage::CrashReason |
| 192 | GetCrashReasonForSIGSEGV(const siginfo_t *info); |
| 193 | |
| 194 | static ::ProcessMessage::CrashReason |
| 195 | GetCrashReasonForSIGILL(const siginfo_t *info); |
| 196 | |
| 197 | static ::ProcessMessage::CrashReason |
| 198 | GetCrashReasonForSIGFPE(const siginfo_t *info); |
| 199 | |
| 200 | static ::ProcessMessage::CrashReason |
| 201 | GetCrashReasonForSIGBUS(const siginfo_t *info); |
| 202 | #endif |
| 203 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 204 | bool HasThreadNoLock(lldb::tid_t thread_id); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 205 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 206 | bool StopTrackingThread(lldb::tid_t thread_id); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 207 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 208 | NativeThreadLinuxSP AddThread(lldb::tid_t thread_id); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 209 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 210 | Status GetSoftwareBreakpointPCOffset(uint32_t &actual_opcode_size); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 211 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 212 | Status FixupBreakpointPCAsNeeded(NativeThreadLinux &thread); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 213 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 214 | /// Writes a siginfo_t structure corresponding to the given thread ID to the |
| 215 | /// memory region pointed to by @p siginfo. |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 216 | Status GetSignalInfo(lldb::tid_t tid, void *siginfo); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 217 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 218 | /// Writes the raw event message code (vis-a-vis PTRACE_GETEVENTMSG) |
| 219 | /// corresponding to the given thread ID to the memory pointed to by @p |
| 220 | /// message. |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 221 | Status GetEventMessage(lldb::tid_t tid, unsigned long *message); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 222 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 223 | void NotifyThreadDeath(lldb::tid_t tid); |
Chaoren Lin | fa03ad2 | 2015-02-03 01:50:42 +0000 | [diff] [blame] | 224 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 225 | Status Detach(lldb::tid_t tid); |
Chaoren Lin | 86fd8e4 | 2015-02-03 01:51:15 +0000 | [diff] [blame] | 226 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 227 | // This method is requests a stop on all threads which are still running. It |
| 228 | // sets up a |
| 229 | // deferred delegate notification, which will fire once threads report as |
| 230 | // stopped. The |
| 231 | // triggerring_tid will be set as the current thread (main stop reason). |
| 232 | void StopRunningThreads(lldb::tid_t triggering_tid); |
Pavel Labath | c076559 | 2015-05-06 10:46:34 +0000 | [diff] [blame] | 233 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 234 | // Notify the delegate if all threads have stopped. |
| 235 | void SignalIfAllThreadsStopped(); |
Pavel Labath | c076559 | 2015-05-06 10:46:34 +0000 | [diff] [blame] | 236 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 237 | // Resume the given thread, optionally passing it the given signal. The type |
| 238 | // of resume |
| 239 | // operation (continue, single-step) depends on the state parameter. |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 240 | Status ResumeThread(NativeThreadLinux &thread, lldb::StateType state, |
| 241 | int signo); |
Pavel Labath | c076559 | 2015-05-06 10:46:34 +0000 | [diff] [blame] | 242 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 243 | void ThreadWasCreated(NativeThreadLinux &thread); |
Pavel Labath | c076559 | 2015-05-06 10:46:34 +0000 | [diff] [blame] | 244 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 245 | void SigchldHandler(); |
Tamas Berghammer | a6f5795 | 2017-01-03 16:29:43 +0000 | [diff] [blame] | 246 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 247 | Status PopulateMemoryRegionCache(); |
Ravitheja Addepally | 99e3769 | 2017-06-28 07:58:31 +0000 | [diff] [blame^] | 248 | |
| 249 | lldb::user_id_t StartTraceGroup(const TraceOptions &config, |
| 250 | Status &error); |
| 251 | |
| 252 | // This function is intended to be used to stop tracing |
| 253 | // on a thread that exited. |
| 254 | Status StopTracingForThread(lldb::tid_t thread); |
| 255 | |
| 256 | // The below function as the name suggests, looks up a ProcessorTrace |
| 257 | // instance from the m_processor_trace_monitor map. In the case of |
| 258 | // process tracing where the traceid passed would map to the complete |
| 259 | // process, it is mandatory to provide a threadid to obtain a trace |
| 260 | // instance (since ProcessorTrace is tied to a thread). In the other |
| 261 | // scenario that an individual thread is being traced, just the traceid |
| 262 | // is sufficient to obtain the actual ProcessorTrace instance. |
| 263 | llvm::Expected<ProcessorTraceMonitor &> |
| 264 | LookupProcessorTraceInstance(lldb::user_id_t traceid, lldb::tid_t thread); |
| 265 | |
| 266 | // Stops tracing on individual threads being traced. Not intended |
| 267 | // to be used to stop tracing on complete process. |
| 268 | Status StopProcessorTracingOnThread(lldb::user_id_t traceid, |
| 269 | lldb::tid_t thread); |
| 270 | |
| 271 | // Intended to stop tracing on complete process. |
| 272 | // Should not be used for stopping trace on |
| 273 | // individual threads. |
| 274 | void StopProcessorTracingOnProcess(); |
| 275 | |
| 276 | llvm::DenseMap<lldb::tid_t, ProcessorTraceMonitorUP> |
| 277 | m_processor_trace_monitor; |
| 278 | |
| 279 | // Set for tracking threads being traced under |
| 280 | // same process user id. |
| 281 | llvm::DenseSet<lldb::tid_t> m_pt_traced_thread_group; |
| 282 | |
| 283 | lldb::user_id_t m_pt_proces_trace_id; |
| 284 | TraceOptions m_pt_process_trace_config; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 285 | }; |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 286 | |
| 287 | } // namespace process_linux |
| 288 | } // namespace lldb_private |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 289 | |
| 290 | #endif // #ifndef liblldb_NativeProcessLinux_H_ |