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