Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- SBProcess.cpp -------------------------------------------*- 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 | |
Daniel Malea | 93a6430 | 2012-12-05 00:20:57 +0000 | [diff] [blame] | 10 | #include "lldb/lldb-python.h" |
| 11 | |
Eli Friedman | 4c5de69 | 2010-06-09 07:44:37 +0000 | [diff] [blame] | 12 | #include "lldb/API/SBProcess.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 13 | |
Virgile Bello | bdae378 | 2013-08-28 12:14:27 +0000 | [diff] [blame] | 14 | // C Includes |
| 15 | #include <inttypes.h> |
| 16 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 17 | #include "lldb/lldb-defines.h" |
| 18 | #include "lldb/lldb-types.h" |
| 19 | |
Jim Ingham | 40af72e | 2010-06-15 19:49:27 +0000 | [diff] [blame] | 20 | #include "lldb/Interpreter/Args.h" |
Greg Clayton | 5d5028b | 2010-10-06 03:53:16 +0000 | [diff] [blame] | 21 | #include "lldb/Core/Debugger.h" |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 22 | #include "lldb/Core/Log.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 23 | #include "lldb/Core/Module.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 24 | #include "lldb/Core/State.h" |
| 25 | #include "lldb/Core/Stream.h" |
| 26 | #include "lldb/Core/StreamFile.h" |
| 27 | #include "lldb/Target/Process.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 28 | #include "lldb/Target/RegisterContext.h" |
Jason Molenda | 8c71337 | 2013-11-05 11:00:35 +0000 | [diff] [blame] | 29 | #include "lldb/Target/SystemRuntime.h" |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 30 | #include "lldb/Target/Target.h" |
| 31 | #include "lldb/Target/Thread.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 32 | |
| 33 | // Project includes |
| 34 | |
Eli Friedman | 4c5de69 | 2010-06-09 07:44:37 +0000 | [diff] [blame] | 35 | #include "lldb/API/SBBroadcaster.h" |
Eli Friedman | 4c5de69 | 2010-06-09 07:44:37 +0000 | [diff] [blame] | 36 | #include "lldb/API/SBCommandReturnObject.h" |
Greg Clayton | 0e61568 | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 37 | #include "lldb/API/SBDebugger.h" |
Eli Friedman | 4c5de69 | 2010-06-09 07:44:37 +0000 | [diff] [blame] | 38 | #include "lldb/API/SBEvent.h" |
Greg Clayton | 0e61568 | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 39 | #include "lldb/API/SBFileSpec.h" |
Eli Friedman | 4c5de69 | 2010-06-09 07:44:37 +0000 | [diff] [blame] | 40 | #include "lldb/API/SBThread.h" |
Kuba Brecka | a51ea38 | 2014-09-06 01:33:13 +0000 | [diff] [blame] | 41 | #include "lldb/API/SBThreadCollection.h" |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 42 | #include "lldb/API/SBStream.h" |
Eli Friedman | 4c5de69 | 2010-06-09 07:44:37 +0000 | [diff] [blame] | 43 | #include "lldb/API/SBStringList.h" |
Todd Fiala | 802dc402 | 2014-06-23 19:30:49 +0000 | [diff] [blame] | 44 | #include "lldb/API/SBUnixSignals.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 45 | |
| 46 | using namespace lldb; |
| 47 | using namespace lldb_private; |
| 48 | |
| 49 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 50 | SBProcess::SBProcess () : |
Greg Clayton | 4e0fe8a | 2012-07-12 20:32:19 +0000 | [diff] [blame] | 51 | m_opaque_wp() |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 52 | { |
| 53 | } |
| 54 | |
| 55 | |
| 56 | //---------------------------------------------------------------------- |
| 57 | // SBProcess constructor |
| 58 | //---------------------------------------------------------------------- |
| 59 | |
| 60 | SBProcess::SBProcess (const SBProcess& rhs) : |
Greg Clayton | 4e0fe8a | 2012-07-12 20:32:19 +0000 | [diff] [blame] | 61 | m_opaque_wp (rhs.m_opaque_wp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 62 | { |
| 63 | } |
| 64 | |
| 65 | |
| 66 | SBProcess::SBProcess (const lldb::ProcessSP &process_sp) : |
Greg Clayton | 4e0fe8a | 2012-07-12 20:32:19 +0000 | [diff] [blame] | 67 | m_opaque_wp (process_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 68 | { |
| 69 | } |
| 70 | |
Greg Clayton | efabb12 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 71 | const SBProcess& |
| 72 | SBProcess::operator = (const SBProcess& rhs) |
| 73 | { |
| 74 | if (this != &rhs) |
Greg Clayton | 4e0fe8a | 2012-07-12 20:32:19 +0000 | [diff] [blame] | 75 | m_opaque_wp = rhs.m_opaque_wp; |
Greg Clayton | efabb12 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 76 | return *this; |
| 77 | } |
| 78 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 79 | //---------------------------------------------------------------------- |
| 80 | // Destructor |
| 81 | //---------------------------------------------------------------------- |
| 82 | SBProcess::~SBProcess() |
| 83 | { |
| 84 | } |
| 85 | |
Jim Ingham | 4bddaeb | 2012-02-16 06:50:00 +0000 | [diff] [blame] | 86 | const char * |
| 87 | SBProcess::GetBroadcasterClassName () |
| 88 | { |
| 89 | return Process::GetStaticBroadcasterClass().AsCString(); |
| 90 | } |
| 91 | |
Jim Ingham | d7b30ef | 2012-10-26 19:18:04 +0000 | [diff] [blame] | 92 | const char * |
| 93 | SBProcess::GetPluginName () |
| 94 | { |
| 95 | ProcessSP process_sp(GetSP()); |
| 96 | if (process_sp) |
| 97 | { |
Greg Clayton | 57abc5d | 2013-05-10 21:47:16 +0000 | [diff] [blame] | 98 | return process_sp->GetPluginName().GetCString(); |
Jim Ingham | d7b30ef | 2012-10-26 19:18:04 +0000 | [diff] [blame] | 99 | } |
| 100 | return "<Unknown>"; |
| 101 | } |
| 102 | |
| 103 | const char * |
| 104 | SBProcess::GetShortPluginName () |
| 105 | { |
| 106 | ProcessSP process_sp(GetSP()); |
| 107 | if (process_sp) |
| 108 | { |
Greg Clayton | 57abc5d | 2013-05-10 21:47:16 +0000 | [diff] [blame] | 109 | return process_sp->GetPluginName().GetCString(); |
Jim Ingham | d7b30ef | 2012-10-26 19:18:04 +0000 | [diff] [blame] | 110 | } |
| 111 | return "<Unknown>"; |
| 112 | } |
| 113 | |
| 114 | |
Greg Clayton | b9556ac | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 115 | lldb::ProcessSP |
| 116 | SBProcess::GetSP() const |
| 117 | { |
Greg Clayton | 4e0fe8a | 2012-07-12 20:32:19 +0000 | [diff] [blame] | 118 | return m_opaque_wp.lock(); |
Greg Clayton | b9556ac | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 119 | } |
| 120 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 121 | void |
Greg Clayton | b9556ac | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 122 | SBProcess::SetSP (const ProcessSP &process_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 123 | { |
Greg Clayton | 4e0fe8a | 2012-07-12 20:32:19 +0000 | [diff] [blame] | 124 | m_opaque_wp = process_sp; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | void |
| 128 | SBProcess::Clear () |
| 129 | { |
Greg Clayton | 4e0fe8a | 2012-07-12 20:32:19 +0000 | [diff] [blame] | 130 | m_opaque_wp.reset(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | |
| 134 | bool |
| 135 | SBProcess::IsValid() const |
| 136 | { |
Jim Ingham | 4fc6cb9 | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 137 | ProcessSP process_sp(m_opaque_wp.lock()); |
| 138 | return ((bool) process_sp && process_sp->IsValid()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 139 | } |
| 140 | |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 141 | bool |
| 142 | SBProcess::RemoteLaunch (char const **argv, |
| 143 | char const **envp, |
| 144 | const char *stdin_path, |
| 145 | const char *stdout_path, |
| 146 | const char *stderr_path, |
| 147 | const char *working_directory, |
| 148 | uint32_t launch_flags, |
| 149 | bool stop_at_entry, |
| 150 | lldb::SBError& error) |
| 151 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 152 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 153 | if (log) |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 154 | log->Printf ("SBProcess(%p)::RemoteLaunch (argv=%p, envp=%p, stdin=%s, stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, stop_at_entry=%i, &error (%p))...", |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 155 | static_cast<void*>(m_opaque_wp.lock().get()), |
| 156 | static_cast<void*>(argv), static_cast<void*>(envp), |
| 157 | stdin_path ? stdin_path : "NULL", |
| 158 | stdout_path ? stdout_path : "NULL", |
| 159 | stderr_path ? stderr_path : "NULL", |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 160 | working_directory ? working_directory : "NULL", |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 161 | launch_flags, stop_at_entry, |
| 162 | static_cast<void*>(error.get())); |
| 163 | |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 164 | ProcessSP process_sp(GetSP()); |
| 165 | if (process_sp) |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 166 | { |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 167 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 168 | if (process_sp->GetState() == eStateConnected) |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 169 | { |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 170 | if (stop_at_entry) |
| 171 | launch_flags |= eLaunchFlagStopAtEntry; |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 172 | ProcessLaunchInfo launch_info (stdin_path, |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 173 | stdout_path, |
| 174 | stderr_path, |
| 175 | working_directory, |
| 176 | launch_flags); |
| 177 | Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer(); |
| 178 | if (exe_module) |
Greg Clayton | 14715c6 | 2013-06-29 00:10:32 +0000 | [diff] [blame] | 179 | launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 180 | if (argv) |
| 181 | launch_info.GetArguments().AppendArguments (argv); |
| 182 | if (envp) |
| 183 | launch_info.GetEnvironmentEntries ().SetArguments (envp); |
| 184 | error.SetError (process_sp->Launch (launch_info)); |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 185 | } |
| 186 | else |
| 187 | { |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 188 | error.SetErrorString ("must be in eStateConnected to call RemoteLaunch"); |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | else |
| 192 | { |
| 193 | error.SetErrorString ("unable to attach pid"); |
| 194 | } |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 195 | |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 196 | if (log) { |
| 197 | SBStream sstr; |
| 198 | error.GetDescription (sstr); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 199 | log->Printf ("SBProcess(%p)::RemoteLaunch (...) => SBError (%p): %s", |
| 200 | static_cast<void*>(process_sp.get()), |
| 201 | static_cast<void*>(error.get()), sstr.GetData()); |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 202 | } |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 203 | |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 204 | return error.Success(); |
| 205 | } |
| 206 | |
| 207 | bool |
| 208 | SBProcess::RemoteAttachToProcessWithID (lldb::pid_t pid, lldb::SBError& error) |
| 209 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 210 | ProcessSP process_sp(GetSP()); |
| 211 | if (process_sp) |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 212 | { |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 213 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 214 | if (process_sp->GetState() == eStateConnected) |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 215 | { |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 216 | ProcessAttachInfo attach_info; |
| 217 | attach_info.SetProcessID (pid); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 218 | error.SetError (process_sp->Attach (attach_info)); |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 219 | } |
| 220 | else |
| 221 | { |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 222 | error.SetErrorString ("must be in eStateConnected to call RemoteAttachToProcessWithID"); |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 223 | } |
| 224 | } |
| 225 | else |
| 226 | { |
| 227 | error.SetErrorString ("unable to attach pid"); |
| 228 | } |
| 229 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 230 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 231 | if (log) { |
| 232 | SBStream sstr; |
| 233 | error.GetDescription (sstr); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 234 | log->Printf ("SBProcess(%p)::RemoteAttachToProcessWithID (%" PRIu64 ") => SBError (%p): %s", |
| 235 | static_cast<void*>(process_sp.get()), pid, |
| 236 | static_cast<void*>(error.get()), sstr.GetData()); |
James McIlree | 9631aae | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | return error.Success(); |
| 240 | } |
| 241 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 242 | |
| 243 | uint32_t |
| 244 | SBProcess::GetNumThreads () |
| 245 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 246 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 247 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 248 | uint32_t num_threads = 0; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 249 | ProcessSP process_sp(GetSP()); |
| 250 | if (process_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 251 | { |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 252 | Process::StopLocker stop_locker; |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 253 | |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 254 | const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 255 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 256 | num_threads = process_sp->GetThreadList().GetSize(can_update); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 257 | } |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 258 | |
| 259 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 260 | log->Printf ("SBProcess(%p)::GetNumThreads () => %d", |
| 261 | static_cast<void*>(process_sp.get()), num_threads); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 262 | |
| 263 | return num_threads; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | SBThread |
Jim Ingham | 2976d00 | 2010-08-26 21:32:51 +0000 | [diff] [blame] | 267 | SBProcess::GetSelectedThread () const |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 268 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 269 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 270 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 271 | SBThread sb_thread; |
Greg Clayton | 17a6ad0 | 2012-01-30 02:53:15 +0000 | [diff] [blame] | 272 | ThreadSP thread_sp; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 273 | ProcessSP process_sp(GetSP()); |
| 274 | if (process_sp) |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 275 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 276 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 277 | thread_sp = process_sp->GetThreadList().GetSelectedThread(); |
Greg Clayton | 17a6ad0 | 2012-01-30 02:53:15 +0000 | [diff] [blame] | 278 | sb_thread.SetThread (thread_sp); |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 279 | } |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 280 | |
| 281 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 282 | log->Printf ("SBProcess(%p)::GetSelectedThread () => SBThread(%p)", |
| 283 | static_cast<void*>(process_sp.get()), |
| 284 | static_cast<void*>(thread_sp.get())); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 285 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 286 | return sb_thread; |
| 287 | } |
| 288 | |
Greg Clayton | a4d8747 | 2013-01-18 23:41:08 +0000 | [diff] [blame] | 289 | SBThread |
| 290 | SBProcess::CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context) |
| 291 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 292 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 293 | |
Greg Clayton | a4d8747 | 2013-01-18 23:41:08 +0000 | [diff] [blame] | 294 | SBThread sb_thread; |
| 295 | ThreadSP thread_sp; |
| 296 | ProcessSP process_sp(GetSP()); |
| 297 | if (process_sp) |
| 298 | { |
| 299 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 300 | thread_sp = process_sp->CreateOSPluginThread(tid, context); |
| 301 | sb_thread.SetThread (thread_sp); |
| 302 | } |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 303 | |
Greg Clayton | a4d8747 | 2013-01-18 23:41:08 +0000 | [diff] [blame] | 304 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 305 | log->Printf ("SBProcess(%p)::CreateOSPluginThread (tid=0x%" PRIx64 ", context=0x%" PRIx64 ") => SBThread(%p)", |
| 306 | static_cast<void*>(process_sp.get()), tid, context, |
| 307 | static_cast<void*>(thread_sp.get())); |
| 308 | |
Greg Clayton | a4d8747 | 2013-01-18 23:41:08 +0000 | [diff] [blame] | 309 | return sb_thread; |
| 310 | } |
| 311 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 312 | SBTarget |
| 313 | SBProcess::GetTarget() const |
| 314 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 315 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 316 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 317 | SBTarget sb_target; |
Greg Clayton | b9556ac | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 318 | TargetSP target_sp; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 319 | ProcessSP process_sp(GetSP()); |
| 320 | if (process_sp) |
Greg Clayton | b9556ac | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 321 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 322 | target_sp = process_sp->GetTarget().shared_from_this(); |
Greg Clayton | b9556ac | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 323 | sb_target.SetSP (target_sp); |
| 324 | } |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 325 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 326 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 327 | log->Printf ("SBProcess(%p)::GetTarget () => SBTarget(%p)", |
| 328 | static_cast<void*>(process_sp.get()), |
| 329 | static_cast<void*>(target_sp.get())); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 330 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 331 | return sb_target; |
| 332 | } |
| 333 | |
| 334 | |
| 335 | size_t |
| 336 | SBProcess::PutSTDIN (const char *src, size_t src_len) |
| 337 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 338 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 339 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 340 | size_t ret_val = 0; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 341 | ProcessSP process_sp(GetSP()); |
| 342 | if (process_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 343 | { |
| 344 | Error error; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 345 | ret_val = process_sp->PutSTDIN (src, src_len, error); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 346 | } |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 347 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 348 | if (log) |
Greg Clayton | 6fea17e | 2014-03-03 19:15:20 +0000 | [diff] [blame] | 349 | log->Printf("SBProcess(%p)::PutSTDIN (src=\"%s\", src_len=%" PRIu64 ") => %" PRIu64, |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 350 | static_cast<void*>(process_sp.get()), src, |
| 351 | static_cast<uint64_t>(src_len), |
| 352 | static_cast<uint64_t>(ret_val)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 353 | |
| 354 | return ret_val; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | size_t |
| 358 | SBProcess::GetSTDOUT (char *dst, size_t dst_len) const |
| 359 | { |
Greg Clayton | cfd1ace | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 360 | size_t bytes_read = 0; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 361 | ProcessSP process_sp(GetSP()); |
| 362 | if (process_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 363 | { |
| 364 | Error error; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 365 | bytes_read = process_sp->GetSTDOUT (dst, dst_len, error); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 366 | } |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 367 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 368 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 369 | if (log) |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 370 | log->Printf ("SBProcess(%p)::GetSTDOUT (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64, |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 371 | static_cast<void*>(process_sp.get()), |
| 372 | static_cast<int>(bytes_read), dst, |
| 373 | static_cast<uint64_t>(dst_len), |
| 374 | static_cast<uint64_t>(bytes_read)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 375 | |
Greg Clayton | cfd1ace | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 376 | return bytes_read; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | size_t |
| 380 | SBProcess::GetSTDERR (char *dst, size_t dst_len) const |
| 381 | { |
Greg Clayton | cfd1ace | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 382 | size_t bytes_read = 0; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 383 | ProcessSP process_sp(GetSP()); |
| 384 | if (process_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 385 | { |
| 386 | Error error; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 387 | bytes_read = process_sp->GetSTDERR (dst, dst_len, error); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 388 | } |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 389 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 390 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 391 | if (log) |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 392 | log->Printf ("SBProcess(%p)::GetSTDERR (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64, |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 393 | static_cast<void*>(process_sp.get()), |
| 394 | static_cast<int>(bytes_read), dst, |
| 395 | static_cast<uint64_t>(dst_len), |
| 396 | static_cast<uint64_t>(bytes_read)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 397 | |
Greg Clayton | cfd1ace | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 398 | return bytes_read; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 399 | } |
| 400 | |
Han Ming Ong | ab3b8b2 | 2012-11-17 00:21:04 +0000 | [diff] [blame] | 401 | size_t |
| 402 | SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const |
| 403 | { |
| 404 | size_t bytes_read = 0; |
| 405 | ProcessSP process_sp(GetSP()); |
| 406 | if (process_sp) |
| 407 | { |
| 408 | Error error; |
| 409 | bytes_read = process_sp->GetAsyncProfileData (dst, dst_len, error); |
| 410 | } |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 411 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 412 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Han Ming Ong | ab3b8b2 | 2012-11-17 00:21:04 +0000 | [diff] [blame] | 413 | if (log) |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 414 | log->Printf ("SBProcess(%p)::GetProfileData (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64, |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 415 | static_cast<void*>(process_sp.get()), |
| 416 | static_cast<int>(bytes_read), dst, |
| 417 | static_cast<uint64_t>(dst_len), |
| 418 | static_cast<uint64_t>(bytes_read)); |
| 419 | |
Han Ming Ong | ab3b8b2 | 2012-11-17 00:21:04 +0000 | [diff] [blame] | 420 | return bytes_read; |
| 421 | } |
| 422 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 423 | void |
Jim Ingham | 2976d00 | 2010-08-26 21:32:51 +0000 | [diff] [blame] | 424 | SBProcess::ReportEventState (const SBEvent &event, FILE *out) const |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 425 | { |
| 426 | if (out == NULL) |
| 427 | return; |
| 428 | |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 429 | ProcessSP process_sp(GetSP()); |
| 430 | if (process_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 431 | { |
| 432 | const StateType event_state = SBProcess::GetStateFromEvent (event); |
| 433 | char message[1024]; |
| 434 | int message_len = ::snprintf (message, |
| 435 | sizeof (message), |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 436 | "Process %" PRIu64 " %s\n", |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 437 | process_sp->GetID(), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 438 | SBDebugger::StateAsCString (event_state)); |
| 439 | |
| 440 | if (message_len > 0) |
| 441 | ::fwrite (message, 1, message_len, out); |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | void |
Jim Ingham | 2976d00 | 2010-08-26 21:32:51 +0000 | [diff] [blame] | 446 | SBProcess::AppendEventStateReport (const SBEvent &event, SBCommandReturnObject &result) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 447 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 448 | ProcessSP process_sp(GetSP()); |
| 449 | if (process_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 450 | { |
| 451 | const StateType event_state = SBProcess::GetStateFromEvent (event); |
| 452 | char message[1024]; |
| 453 | ::snprintf (message, |
| 454 | sizeof (message), |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 455 | "Process %" PRIu64 " %s\n", |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 456 | process_sp->GetID(), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 457 | SBDebugger::StateAsCString (event_state)); |
| 458 | |
| 459 | result.AppendMessage (message); |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | bool |
Jim Ingham | 2976d00 | 2010-08-26 21:32:51 +0000 | [diff] [blame] | 464 | SBProcess::SetSelectedThread (const SBThread &thread) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 465 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 466 | ProcessSP process_sp(GetSP()); |
| 467 | if (process_sp) |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 468 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 469 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 470 | return process_sp->GetThreadList().SetSelectedThreadByID (thread.GetThreadID()); |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 471 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 472 | return false; |
| 473 | } |
| 474 | |
| 475 | bool |
Greg Clayton | ea561dc | 2012-10-12 23:32:11 +0000 | [diff] [blame] | 476 | SBProcess::SetSelectedThreadByID (lldb::tid_t tid) |
| 477 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 478 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 479 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 480 | bool ret_val = false; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 481 | ProcessSP process_sp(GetSP()); |
| 482 | if (process_sp) |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 483 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 484 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 485 | ret_val = process_sp->GetThreadList().SetSelectedThreadByID (tid); |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 486 | } |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 487 | |
| 488 | if (log) |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 489 | log->Printf ("SBProcess(%p)::SetSelectedThreadByID (tid=0x%4.4" PRIx64 ") => %s", |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 490 | static_cast<void*>(process_sp.get()), tid, |
| 491 | (ret_val ? "true" : "false")); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 492 | |
| 493 | return ret_val; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 494 | } |
| 495 | |
Jim Ingham | 18b4689 | 2012-07-13 20:18:18 +0000 | [diff] [blame] | 496 | bool |
| 497 | SBProcess::SetSelectedThreadByIndexID (uint32_t index_id) |
| 498 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 499 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Jim Ingham | 18b4689 | 2012-07-13 20:18:18 +0000 | [diff] [blame] | 500 | |
| 501 | bool ret_val = false; |
| 502 | ProcessSP process_sp(GetSP()); |
| 503 | if (process_sp) |
| 504 | { |
| 505 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 506 | ret_val = process_sp->GetThreadList().SetSelectedThreadByIndexID (index_id); |
| 507 | } |
| 508 | |
| 509 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 510 | log->Printf ("SBProcess(%p)::SetSelectedThreadByID (tid=0x%x) => %s", |
| 511 | static_cast<void*>(process_sp.get()), index_id, |
| 512 | (ret_val ? "true" : "false")); |
Jim Ingham | 18b4689 | 2012-07-13 20:18:18 +0000 | [diff] [blame] | 513 | |
| 514 | return ret_val; |
| 515 | } |
| 516 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 517 | SBThread |
| 518 | SBProcess::GetThreadAtIndex (size_t index) |
| 519 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 520 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 521 | |
Greg Clayton | 17a6ad0 | 2012-01-30 02:53:15 +0000 | [diff] [blame] | 522 | SBThread sb_thread; |
| 523 | ThreadSP thread_sp; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 524 | ProcessSP process_sp(GetSP()); |
| 525 | if (process_sp) |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 526 | { |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 527 | Process::StopLocker stop_locker; |
| 528 | const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 529 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 530 | thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, can_update); |
Greg Clayton | 17a6ad0 | 2012-01-30 02:53:15 +0000 | [diff] [blame] | 531 | sb_thread.SetThread (thread_sp); |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 532 | } |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 533 | |
| 534 | if (log) |
Greg Clayton | 93aa84e | 2010-10-29 04:59:35 +0000 | [diff] [blame] | 535 | log->Printf ("SBProcess(%p)::GetThreadAtIndex (index=%d) => SBThread(%p)", |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 536 | static_cast<void*>(process_sp.get()), |
| 537 | static_cast<uint32_t>(index), |
| 538 | static_cast<void*>(thread_sp.get())); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 539 | |
Greg Clayton | 17a6ad0 | 2012-01-30 02:53:15 +0000 | [diff] [blame] | 540 | return sb_thread; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 541 | } |
| 542 | |
Jim Ingham | bf2956a2 | 2013-01-08 23:22:42 +0000 | [diff] [blame] | 543 | uint32_t |
Jason Molenda | 5e8dce4 | 2013-12-13 00:29:16 +0000 | [diff] [blame] | 544 | SBProcess::GetNumQueues () |
| 545 | { |
| 546 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 547 | |
| 548 | uint32_t num_queues = 0; |
| 549 | ProcessSP process_sp(GetSP()); |
| 550 | if (process_sp) |
| 551 | { |
| 552 | Process::StopLocker stop_locker; |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 553 | |
Jason Molenda | 5e8dce4 | 2013-12-13 00:29:16 +0000 | [diff] [blame] | 554 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 555 | num_queues = process_sp->GetQueueList().GetSize(); |
| 556 | } |
| 557 | |
| 558 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 559 | log->Printf ("SBProcess(%p)::GetNumQueues () => %d", |
| 560 | static_cast<void*>(process_sp.get()), num_queues); |
Jason Molenda | 5e8dce4 | 2013-12-13 00:29:16 +0000 | [diff] [blame] | 561 | |
| 562 | return num_queues; |
| 563 | } |
| 564 | |
| 565 | SBQueue |
| 566 | SBProcess::GetQueueAtIndex (size_t index) |
| 567 | { |
| 568 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 569 | |
| 570 | SBQueue sb_queue; |
| 571 | QueueSP queue_sp; |
| 572 | ProcessSP process_sp(GetSP()); |
| 573 | if (process_sp) |
| 574 | { |
| 575 | Process::StopLocker stop_locker; |
| 576 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 577 | queue_sp = process_sp->GetQueueList().GetQueueAtIndex(index); |
| 578 | sb_queue.SetQueue (queue_sp); |
| 579 | } |
| 580 | |
| 581 | if (log) |
Jason Molenda | 5e8dce4 | 2013-12-13 00:29:16 +0000 | [diff] [blame] | 582 | log->Printf ("SBProcess(%p)::GetQueueAtIndex (index=%d) => SBQueue(%p)", |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 583 | static_cast<void*>(process_sp.get()), |
| 584 | static_cast<uint32_t>(index), |
| 585 | static_cast<void*>(queue_sp.get())); |
Jason Molenda | 5e8dce4 | 2013-12-13 00:29:16 +0000 | [diff] [blame] | 586 | |
| 587 | return sb_queue; |
| 588 | } |
| 589 | |
| 590 | |
| 591 | uint32_t |
Jim Ingham | bf2956a2 | 2013-01-08 23:22:42 +0000 | [diff] [blame] | 592 | SBProcess::GetStopID(bool include_expression_stops) |
| 593 | { |
| 594 | ProcessSP process_sp(GetSP()); |
| 595 | if (process_sp) |
| 596 | { |
| 597 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 598 | if (include_expression_stops) |
| 599 | return process_sp->GetStopID(); |
| 600 | else |
| 601 | return process_sp->GetLastNaturalStopID(); |
| 602 | } |
| 603 | return 0; |
| 604 | } |
| 605 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 606 | StateType |
| 607 | SBProcess::GetState () |
| 608 | { |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 609 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 610 | StateType ret_val = eStateInvalid; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 611 | ProcessSP process_sp(GetSP()); |
| 612 | if (process_sp) |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 613 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 614 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 615 | ret_val = process_sp->GetState(); |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 616 | } |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 617 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 618 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 619 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 620 | log->Printf ("SBProcess(%p)::GetState () => %s", |
| 621 | static_cast<void*>(process_sp.get()), |
Caroline Tice | 750cd17 | 2010-10-26 23:49:36 +0000 | [diff] [blame] | 622 | lldb_private::StateAsCString (ret_val)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 623 | |
| 624 | return ret_val; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 625 | } |
| 626 | |
| 627 | |
| 628 | int |
| 629 | SBProcess::GetExitStatus () |
| 630 | { |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 631 | int exit_status = 0; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 632 | ProcessSP process_sp(GetSP()); |
| 633 | if (process_sp) |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 634 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 635 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 636 | exit_status = process_sp->GetExitStatus (); |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 637 | } |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 638 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 639 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 640 | log->Printf ("SBProcess(%p)::GetExitStatus () => %i (0x%8.8x)", |
| 641 | static_cast<void*>(process_sp.get()), exit_status, |
| 642 | exit_status); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 643 | |
| 644 | return exit_status; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | const char * |
| 648 | SBProcess::GetExitDescription () |
| 649 | { |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 650 | const char *exit_desc = NULL; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 651 | ProcessSP process_sp(GetSP()); |
| 652 | if (process_sp) |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 653 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 654 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 655 | exit_desc = process_sp->GetExitDescription (); |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 656 | } |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 657 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 658 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 659 | log->Printf ("SBProcess(%p)::GetExitDescription () => %s", |
| 660 | static_cast<void*>(process_sp.get()), exit_desc); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 661 | return exit_desc; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | lldb::pid_t |
| 665 | SBProcess::GetProcessID () |
| 666 | { |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 667 | lldb::pid_t ret_val = LLDB_INVALID_PROCESS_ID; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 668 | ProcessSP process_sp(GetSP()); |
| 669 | if (process_sp) |
| 670 | ret_val = process_sp->GetID(); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 671 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 672 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 673 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 674 | log->Printf ("SBProcess(%p)::GetProcessID () => %" PRIu64, |
| 675 | static_cast<void*>(process_sp.get()), ret_val); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 676 | |
| 677 | return ret_val; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 678 | } |
| 679 | |
Greg Clayton | 949e822 | 2013-01-16 17:29:04 +0000 | [diff] [blame] | 680 | uint32_t |
| 681 | SBProcess::GetUniqueID() |
| 682 | { |
| 683 | uint32_t ret_val = 0; |
| 684 | ProcessSP process_sp(GetSP()); |
| 685 | if (process_sp) |
| 686 | ret_val = process_sp->GetUniqueID(); |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 687 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 949e822 | 2013-01-16 17:29:04 +0000 | [diff] [blame] | 688 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 689 | log->Printf ("SBProcess(%p)::GetUniqueID () => %" PRIu32, |
| 690 | static_cast<void*>(process_sp.get()), ret_val); |
Greg Clayton | 949e822 | 2013-01-16 17:29:04 +0000 | [diff] [blame] | 691 | return ret_val; |
| 692 | } |
| 693 | |
Johnny Chen | cf386e2 | 2011-03-01 22:56:31 +0000 | [diff] [blame] | 694 | ByteOrder |
| 695 | SBProcess::GetByteOrder () const |
| 696 | { |
| 697 | ByteOrder byteOrder = eByteOrderInvalid; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 698 | ProcessSP process_sp(GetSP()); |
| 699 | if (process_sp) |
| 700 | byteOrder = process_sp->GetTarget().GetArchitecture().GetByteOrder(); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 701 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 702 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Johnny Chen | cf386e2 | 2011-03-01 22:56:31 +0000 | [diff] [blame] | 703 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 704 | log->Printf ("SBProcess(%p)::GetByteOrder () => %d", |
| 705 | static_cast<void*>(process_sp.get()), byteOrder); |
Johnny Chen | cf386e2 | 2011-03-01 22:56:31 +0000 | [diff] [blame] | 706 | |
| 707 | return byteOrder; |
| 708 | } |
| 709 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 710 | uint32_t |
| 711 | SBProcess::GetAddressByteSize () const |
| 712 | { |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 713 | uint32_t size = 0; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 714 | ProcessSP process_sp(GetSP()); |
| 715 | if (process_sp) |
| 716 | size = process_sp->GetTarget().GetArchitecture().GetAddressByteSize(); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 717 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 718 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 719 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 720 | log->Printf ("SBProcess(%p)::GetAddressByteSize () => %d", |
| 721 | static_cast<void*>(process_sp.get()), size); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 722 | |
| 723 | return size; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 724 | } |
| 725 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 726 | SBError |
| 727 | SBProcess::Continue () |
| 728 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 729 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 730 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 731 | SBError sb_error; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 732 | ProcessSP process_sp(GetSP()); |
| 733 | |
| 734 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 735 | log->Printf ("SBProcess(%p)::Continue ()...", |
| 736 | static_cast<void*>(process_sp.get())); |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 737 | |
| 738 | if (process_sp) |
Greg Clayton | 5d5028b | 2010-10-06 03:53:16 +0000 | [diff] [blame] | 739 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 740 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 741 | |
Greg Clayton | dc6224e | 2014-10-21 01:00:42 +0000 | [diff] [blame] | 742 | if (process_sp->GetTarget().GetDebugger().GetAsyncExecution ()) |
| 743 | sb_error.ref() = process_sp->Resume (); |
| 744 | else |
| 745 | sb_error.ref() = process_sp->ResumeSynchronous (NULL); |
Greg Clayton | 5d5028b | 2010-10-06 03:53:16 +0000 | [diff] [blame] | 746 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 747 | else |
| 748 | sb_error.SetErrorString ("SBProcess is invalid"); |
| 749 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 750 | if (log) |
| 751 | { |
| 752 | SBStream sstr; |
| 753 | sb_error.GetDescription (sstr); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 754 | log->Printf ("SBProcess(%p)::Continue () => SBError (%p): %s", |
| 755 | static_cast<void*>(process_sp.get()), |
| 756 | static_cast<void*>(sb_error.get()), sstr.GetData()); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 757 | } |
| 758 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 759 | return sb_error; |
| 760 | } |
| 761 | |
| 762 | |
| 763 | SBError |
| 764 | SBProcess::Destroy () |
| 765 | { |
| 766 | SBError sb_error; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 767 | ProcessSP process_sp(GetSP()); |
| 768 | if (process_sp) |
Greg Clayton | 6779606a | 2011-01-22 23:43:18 +0000 | [diff] [blame] | 769 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 770 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
Jason Molenda | ede3193 | 2015-04-17 05:01:58 +0000 | [diff] [blame] | 771 | sb_error.SetError(process_sp->Destroy(false)); |
Greg Clayton | 6779606a | 2011-01-22 23:43:18 +0000 | [diff] [blame] | 772 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 773 | else |
| 774 | sb_error.SetErrorString ("SBProcess is invalid"); |
| 775 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 776 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 777 | if (log) |
| 778 | { |
| 779 | SBStream sstr; |
| 780 | sb_error.GetDescription (sstr); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 781 | log->Printf ("SBProcess(%p)::Destroy () => SBError (%p): %s", |
| 782 | static_cast<void*>(process_sp.get()), |
| 783 | static_cast<void*>(sb_error.get()), sstr.GetData()); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 784 | } |
| 785 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 786 | return sb_error; |
| 787 | } |
| 788 | |
| 789 | |
| 790 | SBError |
| 791 | SBProcess::Stop () |
| 792 | { |
| 793 | SBError sb_error; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 794 | ProcessSP process_sp(GetSP()); |
| 795 | if (process_sp) |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 796 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 797 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 798 | sb_error.SetError (process_sp->Halt()); |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 799 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 800 | else |
| 801 | sb_error.SetErrorString ("SBProcess is invalid"); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 802 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 803 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 804 | if (log) |
| 805 | { |
| 806 | SBStream sstr; |
| 807 | sb_error.GetDescription (sstr); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 808 | log->Printf ("SBProcess(%p)::Stop () => SBError (%p): %s", |
| 809 | static_cast<void*>(process_sp.get()), |
| 810 | static_cast<void*>(sb_error.get()), sstr.GetData()); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 811 | } |
| 812 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 813 | return sb_error; |
| 814 | } |
| 815 | |
| 816 | SBError |
| 817 | SBProcess::Kill () |
| 818 | { |
| 819 | SBError sb_error; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 820 | ProcessSP process_sp(GetSP()); |
| 821 | if (process_sp) |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 822 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 823 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
Jason Molenda | ede3193 | 2015-04-17 05:01:58 +0000 | [diff] [blame] | 824 | sb_error.SetError (process_sp->Destroy(true)); |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 825 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 826 | else |
| 827 | sb_error.SetErrorString ("SBProcess is invalid"); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 828 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 829 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 830 | if (log) |
| 831 | { |
| 832 | SBStream sstr; |
| 833 | sb_error.GetDescription (sstr); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 834 | log->Printf ("SBProcess(%p)::Kill () => SBError (%p): %s", |
| 835 | static_cast<void*>(process_sp.get()), |
| 836 | static_cast<void*>(sb_error.get()), sstr.GetData()); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 837 | } |
| 838 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 839 | return sb_error; |
| 840 | } |
| 841 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 842 | SBError |
| 843 | SBProcess::Detach () |
| 844 | { |
Jim Ingham | acff895 | 2013-05-02 00:27:30 +0000 | [diff] [blame] | 845 | // FIXME: This should come from a process default. |
| 846 | bool keep_stopped = false; |
| 847 | return Detach (keep_stopped); |
| 848 | } |
| 849 | |
| 850 | SBError |
| 851 | SBProcess::Detach (bool keep_stopped) |
| 852 | { |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 853 | SBError sb_error; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 854 | ProcessSP process_sp(GetSP()); |
| 855 | if (process_sp) |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 856 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 857 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
Jim Ingham | acff895 | 2013-05-02 00:27:30 +0000 | [diff] [blame] | 858 | sb_error.SetError (process_sp->Detach(keep_stopped)); |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 859 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 860 | else |
| 861 | sb_error.SetErrorString ("SBProcess is invalid"); |
| 862 | |
| 863 | return sb_error; |
| 864 | } |
| 865 | |
| 866 | SBError |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 867 | SBProcess::Signal (int signo) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 868 | { |
| 869 | SBError sb_error; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 870 | ProcessSP process_sp(GetSP()); |
| 871 | if (process_sp) |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 872 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 873 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 874 | sb_error.SetError (process_sp->Signal (signo)); |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 875 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 876 | else |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 877 | sb_error.SetErrorString ("SBProcess is invalid"); |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 878 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 879 | if (log) |
| 880 | { |
| 881 | SBStream sstr; |
| 882 | sb_error.GetDescription (sstr); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 883 | log->Printf ("SBProcess(%p)::Signal (signo=%i) => SBError (%p): %s", |
| 884 | static_cast<void*>(process_sp.get()), signo, |
| 885 | static_cast<void*>(sb_error.get()), sstr.GetData()); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 886 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 887 | return sb_error; |
| 888 | } |
| 889 | |
Todd Fiala | 802dc402 | 2014-06-23 19:30:49 +0000 | [diff] [blame] | 890 | SBUnixSignals |
| 891 | SBProcess::GetUnixSignals() |
| 892 | { |
| 893 | SBUnixSignals sb_unix_signals; |
| 894 | ProcessSP process_sp(GetSP()); |
| 895 | if (process_sp) |
| 896 | { |
| 897 | sb_unix_signals.SetSP(process_sp); |
| 898 | } |
| 899 | |
| 900 | return sb_unix_signals; |
| 901 | } |
| 902 | |
Jim Ingham | cfc0935 | 2012-07-27 23:57:19 +0000 | [diff] [blame] | 903 | void |
| 904 | SBProcess::SendAsyncInterrupt () |
| 905 | { |
| 906 | ProcessSP process_sp(GetSP()); |
| 907 | if (process_sp) |
| 908 | { |
| 909 | process_sp->SendAsyncInterrupt (); |
| 910 | } |
| 911 | } |
| 912 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 913 | SBThread |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 914 | SBProcess::GetThreadByID (tid_t tid) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 915 | { |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 916 | SBThread sb_thread; |
Greg Clayton | 17a6ad0 | 2012-01-30 02:53:15 +0000 | [diff] [blame] | 917 | ThreadSP thread_sp; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 918 | ProcessSP process_sp(GetSP()); |
| 919 | if (process_sp) |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 920 | { |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 921 | Process::StopLocker stop_locker; |
| 922 | const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); |
Hafiz Abid Qadeer | 5bf72c4 | 2015-02-11 16:37:17 +0000 | [diff] [blame] | 923 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 924 | thread_sp = process_sp->GetThreadList().FindThreadByID (tid, can_update); |
Greg Clayton | 17a6ad0 | 2012-01-30 02:53:15 +0000 | [diff] [blame] | 925 | sb_thread.SetThread (thread_sp); |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 926 | } |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 927 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 928 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 929 | if (log) |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 930 | log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%4.4" PRIx64 ") => SBThread (%p)", |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 931 | static_cast<void*>(process_sp.get()), tid, |
| 932 | static_cast<void*>(thread_sp.get())); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 933 | |
| 934 | return sb_thread; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 935 | } |
| 936 | |
Jim Ingham | 18b4689 | 2012-07-13 20:18:18 +0000 | [diff] [blame] | 937 | SBThread |
| 938 | SBProcess::GetThreadByIndexID (uint32_t index_id) |
| 939 | { |
| 940 | SBThread sb_thread; |
| 941 | ThreadSP thread_sp; |
| 942 | ProcessSP process_sp(GetSP()); |
| 943 | if (process_sp) |
| 944 | { |
Jim Ingham | 18b4689 | 2012-07-13 20:18:18 +0000 | [diff] [blame] | 945 | Process::StopLocker stop_locker; |
| 946 | const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); |
Hafiz Abid Qadeer | 5bf72c4 | 2015-02-11 16:37:17 +0000 | [diff] [blame] | 947 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
Jim Ingham | 18b4689 | 2012-07-13 20:18:18 +0000 | [diff] [blame] | 948 | thread_sp = process_sp->GetThreadList().FindThreadByIndexID (index_id, can_update); |
| 949 | sb_thread.SetThread (thread_sp); |
| 950 | } |
| 951 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 952 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Jim Ingham | 18b4689 | 2012-07-13 20:18:18 +0000 | [diff] [blame] | 953 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 954 | log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%x) => SBThread (%p)", |
| 955 | static_cast<void*>(process_sp.get()), index_id, |
| 956 | static_cast<void*>(thread_sp.get())); |
Jim Ingham | 18b4689 | 2012-07-13 20:18:18 +0000 | [diff] [blame] | 957 | |
| 958 | return sb_thread; |
| 959 | } |
| 960 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 961 | StateType |
| 962 | SBProcess::GetStateFromEvent (const SBEvent &event) |
| 963 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 964 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 965 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 966 | StateType ret_val = Process::ProcessEventData::GetStateFromEvent (event.get()); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 967 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 968 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 969 | log->Printf ("SBProcess::GetStateFromEvent (event.sp=%p) => %s", |
| 970 | static_cast<void*>(event.get()), |
Caroline Tice | 750cd17 | 2010-10-26 23:49:36 +0000 | [diff] [blame] | 971 | lldb_private::StateAsCString (ret_val)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 972 | |
| 973 | return ret_val; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 974 | } |
| 975 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 976 | bool |
| 977 | SBProcess::GetRestartedFromEvent (const SBEvent &event) |
| 978 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 979 | return Process::ProcessEventData::GetRestartedFromEvent (event.get()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 980 | } |
| 981 | |
Jim Ingham | 0161b49 | 2013-02-09 01:29:05 +0000 | [diff] [blame] | 982 | size_t |
| 983 | SBProcess::GetNumRestartedReasonsFromEvent (const lldb::SBEvent &event) |
| 984 | { |
| 985 | return Process::ProcessEventData::GetNumRestartedReasons(event.get()); |
| 986 | } |
| 987 | |
| 988 | const char * |
| 989 | SBProcess::GetRestartedReasonAtIndexFromEvent (const lldb::SBEvent &event, size_t idx) |
| 990 | { |
| 991 | return Process::ProcessEventData::GetRestartedReasonAtIndex(event.get(), idx); |
| 992 | } |
| 993 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 994 | SBProcess |
| 995 | SBProcess::GetProcessFromEvent (const SBEvent &event) |
| 996 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 997 | SBProcess process(Process::ProcessEventData::GetProcessFromEvent (event.get())); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 998 | return process; |
| 999 | } |
| 1000 | |
Jim Ingham | e6bc6cb | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 1001 | bool |
Ilia K | 06d2855 | 2015-05-15 09:29:09 +0000 | [diff] [blame^] | 1002 | SBProcess::GetInterruptedFromEvent (const SBEvent &event) |
| 1003 | { |
| 1004 | return Process::ProcessEventData::GetInterruptedFromEvent(event.get()); |
| 1005 | } |
| 1006 | |
| 1007 | bool |
Jim Ingham | e6bc6cb | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 1008 | SBProcess::EventIsProcessEvent (const SBEvent &event) |
| 1009 | { |
Ilia K | f9e5dc1 | 2015-03-21 11:11:07 +0000 | [diff] [blame] | 1010 | return event.GetBroadcasterClass() == SBProcess::GetBroadcasterClass(); |
Jim Ingham | e6bc6cb | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 1011 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1012 | |
| 1013 | SBBroadcaster |
| 1014 | SBProcess::GetBroadcaster () const |
| 1015 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1016 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1017 | |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1018 | ProcessSP process_sp(GetSP()); |
| 1019 | |
| 1020 | SBBroadcaster broadcaster(process_sp.get(), false); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1021 | |
| 1022 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1023 | log->Printf ("SBProcess(%p)::GetBroadcaster () => SBBroadcaster (%p)", |
| 1024 | static_cast<void*>(process_sp.get()), |
| 1025 | static_cast<void*>(broadcaster.get())); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1026 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1027 | return broadcaster; |
| 1028 | } |
| 1029 | |
Jim Ingham | 4bddaeb | 2012-02-16 06:50:00 +0000 | [diff] [blame] | 1030 | const char * |
| 1031 | SBProcess::GetBroadcasterClass () |
| 1032 | { |
| 1033 | return Process::GetStaticBroadcasterClass().AsCString(); |
| 1034 | } |
| 1035 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1036 | size_t |
| 1037 | SBProcess::ReadMemory (addr_t addr, void *dst, size_t dst_len, SBError &sb_error) |
| 1038 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1039 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1040 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1041 | size_t bytes_read = 0; |
| 1042 | |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1043 | ProcessSP process_sp(GetSP()); |
| 1044 | |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 1045 | if (log) |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 1046 | log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%" PRIx64 ", dst=%p, dst_len=%" PRIu64 ", SBError (%p))...", |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1047 | static_cast<void*>(process_sp.get()), addr, |
| 1048 | static_cast<void*>(dst), static_cast<uint64_t>(dst_len), |
| 1049 | static_cast<void*>(sb_error.get())); |
| 1050 | |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1051 | if (process_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1052 | { |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1053 | Process::StopLocker stop_locker; |
| 1054 | if (stop_locker.TryLock(&process_sp->GetRunLock())) |
| 1055 | { |
| 1056 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 1057 | bytes_read = process_sp->ReadMemory (addr, dst, dst_len, sb_error.ref()); |
| 1058 | } |
| 1059 | else |
| 1060 | { |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1061 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1062 | log->Printf ("SBProcess(%p)::ReadMemory() => error: process is running", |
| 1063 | static_cast<void*>(process_sp.get())); |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1064 | sb_error.SetErrorString("process is running"); |
| 1065 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1066 | } |
| 1067 | else |
| 1068 | { |
| 1069 | sb_error.SetErrorString ("SBProcess is invalid"); |
| 1070 | } |
| 1071 | |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1072 | if (log) |
Greg Clayton | 93aa84e | 2010-10-29 04:59:35 +0000 | [diff] [blame] | 1073 | { |
| 1074 | SBStream sstr; |
| 1075 | sb_error.GetDescription (sstr); |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 1076 | log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%" PRIx64 ", dst=%p, dst_len=%" PRIu64 ", SBError (%p): %s) => %" PRIu64, |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1077 | static_cast<void*>(process_sp.get()), addr, |
| 1078 | static_cast<void*>(dst), static_cast<uint64_t>(dst_len), |
| 1079 | static_cast<void*>(sb_error.get()), sstr.GetData(), |
| 1080 | static_cast<uint64_t>(bytes_read)); |
Greg Clayton | 93aa84e | 2010-10-29 04:59:35 +0000 | [diff] [blame] | 1081 | } |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1082 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1083 | return bytes_read; |
| 1084 | } |
| 1085 | |
| 1086 | size_t |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 1087 | SBProcess::ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &sb_error) |
| 1088 | { |
| 1089 | size_t bytes_read = 0; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1090 | ProcessSP process_sp(GetSP()); |
| 1091 | if (process_sp) |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 1092 | { |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1093 | Process::StopLocker stop_locker; |
| 1094 | if (stop_locker.TryLock(&process_sp->GetRunLock())) |
| 1095 | { |
| 1096 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 1097 | bytes_read = process_sp->ReadCStringFromMemory (addr, (char *)buf, size, sb_error.ref()); |
| 1098 | } |
| 1099 | else |
| 1100 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1101 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1102 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1103 | log->Printf ("SBProcess(%p)::ReadCStringFromMemory() => error: process is running", |
| 1104 | static_cast<void*>(process_sp.get())); |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1105 | sb_error.SetErrorString("process is running"); |
| 1106 | } |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 1107 | } |
| 1108 | else |
| 1109 | { |
| 1110 | sb_error.SetErrorString ("SBProcess is invalid"); |
| 1111 | } |
| 1112 | return bytes_read; |
| 1113 | } |
| 1114 | |
| 1115 | uint64_t |
| 1116 | SBProcess::ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &sb_error) |
| 1117 | { |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1118 | uint64_t value = 0; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1119 | ProcessSP process_sp(GetSP()); |
| 1120 | if (process_sp) |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 1121 | { |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1122 | Process::StopLocker stop_locker; |
| 1123 | if (stop_locker.TryLock(&process_sp->GetRunLock())) |
| 1124 | { |
| 1125 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 1126 | value = process_sp->ReadUnsignedIntegerFromMemory (addr, byte_size, 0, sb_error.ref()); |
| 1127 | } |
| 1128 | else |
| 1129 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1130 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1131 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1132 | log->Printf ("SBProcess(%p)::ReadUnsignedFromMemory() => error: process is running", |
| 1133 | static_cast<void*>(process_sp.get())); |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1134 | sb_error.SetErrorString("process is running"); |
| 1135 | } |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 1136 | } |
| 1137 | else |
| 1138 | { |
| 1139 | sb_error.SetErrorString ("SBProcess is invalid"); |
| 1140 | } |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1141 | return value; |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 1142 | } |
| 1143 | |
| 1144 | lldb::addr_t |
| 1145 | SBProcess::ReadPointerFromMemory (addr_t addr, lldb::SBError &sb_error) |
| 1146 | { |
| 1147 | lldb::addr_t ptr = LLDB_INVALID_ADDRESS; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1148 | ProcessSP process_sp(GetSP()); |
| 1149 | if (process_sp) |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 1150 | { |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1151 | Process::StopLocker stop_locker; |
| 1152 | if (stop_locker.TryLock(&process_sp->GetRunLock())) |
| 1153 | { |
| 1154 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 1155 | ptr = process_sp->ReadPointerFromMemory (addr, sb_error.ref()); |
| 1156 | } |
| 1157 | else |
| 1158 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1159 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1160 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1161 | log->Printf ("SBProcess(%p)::ReadPointerFromMemory() => error: process is running", |
| 1162 | static_cast<void*>(process_sp.get())); |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1163 | sb_error.SetErrorString("process is running"); |
| 1164 | } |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 1165 | } |
| 1166 | else |
| 1167 | { |
| 1168 | sb_error.SetErrorString ("SBProcess is invalid"); |
| 1169 | } |
| 1170 | return ptr; |
| 1171 | } |
| 1172 | |
| 1173 | size_t |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1174 | SBProcess::WriteMemory (addr_t addr, const void *src, size_t src_len, SBError &sb_error) |
| 1175 | { |
| 1176 | size_t bytes_written = 0; |
| 1177 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1178 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1179 | |
| 1180 | ProcessSP process_sp(GetSP()); |
| 1181 | |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 1182 | if (log) |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 1183 | log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%" PRIx64 ", src=%p, src_len=%" PRIu64 ", SBError (%p))...", |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1184 | static_cast<void*>(process_sp.get()), addr, |
| 1185 | static_cast<const void*>(src), |
| 1186 | static_cast<uint64_t>(src_len), |
| 1187 | static_cast<void*>(sb_error.get())); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 1188 | |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1189 | if (process_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1190 | { |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1191 | Process::StopLocker stop_locker; |
| 1192 | if (stop_locker.TryLock(&process_sp->GetRunLock())) |
| 1193 | { |
| 1194 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 1195 | bytes_written = process_sp->WriteMemory (addr, src, src_len, sb_error.ref()); |
| 1196 | } |
| 1197 | else |
| 1198 | { |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1199 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1200 | log->Printf ("SBProcess(%p)::WriteMemory() => error: process is running", |
| 1201 | static_cast<void*>(process_sp.get())); |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1202 | sb_error.SetErrorString("process is running"); |
| 1203 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1204 | } |
| 1205 | |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 1206 | if (log) |
| 1207 | { |
| 1208 | SBStream sstr; |
| 1209 | sb_error.GetDescription (sstr); |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 1210 | log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%" PRIx64 ", src=%p, src_len=%" PRIu64 ", SBError (%p): %s) => %" PRIu64, |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1211 | static_cast<void*>(process_sp.get()), addr, |
| 1212 | static_cast<const void*>(src), |
| 1213 | static_cast<uint64_t>(src_len), |
| 1214 | static_cast<void*>(sb_error.get()), sstr.GetData(), |
| 1215 | static_cast<uint64_t>(bytes_written)); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 1216 | } |
| 1217 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1218 | return bytes_written; |
| 1219 | } |
| 1220 | |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 1221 | bool |
| 1222 | SBProcess::GetDescription (SBStream &description) |
| 1223 | { |
Greg Clayton | da7bc7d | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 1224 | Stream &strm = description.ref(); |
| 1225 | |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1226 | ProcessSP process_sp(GetSP()); |
| 1227 | if (process_sp) |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 1228 | { |
| 1229 | char path[PATH_MAX]; |
| 1230 | GetTarget().GetExecutable().GetPath (path, sizeof(path)); |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1231 | Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer(); |
Greg Clayton | 1d27316 | 2010-10-06 03:09:58 +0000 | [diff] [blame] | 1232 | const char *exe_name = NULL; |
| 1233 | if (exe_module) |
| 1234 | exe_name = exe_module->GetFileSpec().GetFilename().AsCString(); |
| 1235 | |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 1236 | strm.Printf ("SBProcess: pid = %" PRIu64 ", state = %s, threads = %d%s%s", |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1237 | process_sp->GetID(), |
Greg Clayton | da7bc7d | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 1238 | lldb_private::StateAsCString (GetState()), |
| 1239 | GetNumThreads(), |
| 1240 | exe_name ? ", executable = " : "", |
| 1241 | exe_name ? exe_name : ""); |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 1242 | } |
| 1243 | else |
Greg Clayton | da7bc7d | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 1244 | strm.PutCString ("No value"); |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 1245 | |
| 1246 | return true; |
| 1247 | } |
Greg Clayton | 8f343b0 | 2010-11-04 01:54:29 +0000 | [diff] [blame] | 1248 | |
| 1249 | uint32_t |
Johnny Chen | f9ef60d | 2012-05-23 22:34:34 +0000 | [diff] [blame] | 1250 | SBProcess::GetNumSupportedHardwareWatchpoints (lldb::SBError &sb_error) const |
| 1251 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1252 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Johnny Chen | f9ef60d | 2012-05-23 22:34:34 +0000 | [diff] [blame] | 1253 | |
| 1254 | uint32_t num = 0; |
| 1255 | ProcessSP process_sp(GetSP()); |
| 1256 | if (process_sp) |
| 1257 | { |
| 1258 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 1259 | sb_error.SetError(process_sp->GetWatchpointSupportInfo (num)); |
Johnny Chen | f9ef60d | 2012-05-23 22:34:34 +0000 | [diff] [blame] | 1260 | if (log) |
| 1261 | log->Printf ("SBProcess(%p)::GetNumSupportedHardwareWatchpoints () => %u", |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1262 | static_cast<void*>(process_sp.get()), num); |
Johnny Chen | f9ef60d | 2012-05-23 22:34:34 +0000 | [diff] [blame] | 1263 | } |
| 1264 | else |
| 1265 | { |
| 1266 | sb_error.SetErrorString ("SBProcess is invalid"); |
| 1267 | } |
| 1268 | return num; |
| 1269 | } |
| 1270 | |
| 1271 | uint32_t |
Greg Clayton | 8f343b0 | 2010-11-04 01:54:29 +0000 | [diff] [blame] | 1272 | SBProcess::LoadImage (lldb::SBFileSpec &sb_image_spec, lldb::SBError &sb_error) |
| 1273 | { |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1274 | ProcessSP process_sp(GetSP()); |
| 1275 | if (process_sp) |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1276 | { |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1277 | Process::StopLocker stop_locker; |
| 1278 | if (stop_locker.TryLock(&process_sp->GetRunLock())) |
| 1279 | { |
| 1280 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 1281 | return process_sp->LoadImage (*sb_image_spec, sb_error.ref()); |
| 1282 | } |
| 1283 | else |
| 1284 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1285 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1286 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1287 | log->Printf ("SBProcess(%p)::LoadImage() => error: process is running", |
| 1288 | static_cast<void*>(process_sp.get())); |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1289 | sb_error.SetErrorString("process is running"); |
| 1290 | } |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1291 | } |
Greg Clayton | 8f343b0 | 2010-11-04 01:54:29 +0000 | [diff] [blame] | 1292 | return LLDB_INVALID_IMAGE_TOKEN; |
| 1293 | } |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1294 | |
Greg Clayton | 8f343b0 | 2010-11-04 01:54:29 +0000 | [diff] [blame] | 1295 | lldb::SBError |
| 1296 | SBProcess::UnloadImage (uint32_t image_token) |
| 1297 | { |
| 1298 | lldb::SBError sb_error; |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1299 | ProcessSP process_sp(GetSP()); |
| 1300 | if (process_sp) |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1301 | { |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1302 | Process::StopLocker stop_locker; |
| 1303 | if (stop_locker.TryLock(&process_sp->GetRunLock())) |
| 1304 | { |
| 1305 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 1306 | sb_error.SetError (process_sp->UnloadImage (image_token)); |
| 1307 | } |
| 1308 | else |
| 1309 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1310 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | c9858e4 | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1311 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1312 | log->Printf ("SBProcess(%p)::UnloadImage() => error: process is running", |
| 1313 | static_cast<void*>(process_sp.get())); |
Greg Clayton | 7fdf9ef | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1314 | sb_error.SetErrorString("process is running"); |
| 1315 | } |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1316 | } |
Greg Clayton | 8f343b0 | 2010-11-04 01:54:29 +0000 | [diff] [blame] | 1317 | else |
| 1318 | sb_error.SetErrorString("invalid process"); |
| 1319 | return sb_error; |
| 1320 | } |
Jason Molenda | 8c71337 | 2013-11-05 11:00:35 +0000 | [diff] [blame] | 1321 | |
Jason Molenda | a332978 | 2014-03-29 18:54:20 +0000 | [diff] [blame] | 1322 | lldb::SBError |
| 1323 | SBProcess::SendEventData (const char *event_data) |
| 1324 | { |
| 1325 | lldb::SBError sb_error; |
| 1326 | ProcessSP process_sp(GetSP()); |
| 1327 | if (process_sp) |
| 1328 | { |
| 1329 | Process::StopLocker stop_locker; |
| 1330 | if (stop_locker.TryLock(&process_sp->GetRunLock())) |
| 1331 | { |
| 1332 | Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); |
| 1333 | sb_error.SetError (process_sp->SendEventData (event_data)); |
| 1334 | } |
| 1335 | else |
| 1336 | { |
| 1337 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1338 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1339 | log->Printf ("SBProcess(%p)::SendEventData() => error: process is running", |
| 1340 | static_cast<void*>(process_sp.get())); |
Jason Molenda | a332978 | 2014-03-29 18:54:20 +0000 | [diff] [blame] | 1341 | sb_error.SetErrorString("process is running"); |
| 1342 | } |
| 1343 | } |
| 1344 | else |
| 1345 | sb_error.SetErrorString("invalid process"); |
| 1346 | return sb_error; |
| 1347 | } |
| 1348 | |
Jason Molenda | 8c71337 | 2013-11-05 11:00:35 +0000 | [diff] [blame] | 1349 | uint32_t |
Jason Molenda | 95d005c | 2013-11-06 03:07:33 +0000 | [diff] [blame] | 1350 | SBProcess::GetNumExtendedBacktraceTypes () |
Jason Molenda | 8c71337 | 2013-11-05 11:00:35 +0000 | [diff] [blame] | 1351 | { |
| 1352 | ProcessSP process_sp(GetSP()); |
| 1353 | if (process_sp && process_sp->GetSystemRuntime()) |
| 1354 | { |
| 1355 | SystemRuntime *runtime = process_sp->GetSystemRuntime(); |
Jason Molenda | 95d005c | 2013-11-06 03:07:33 +0000 | [diff] [blame] | 1356 | return runtime->GetExtendedBacktraceTypes().size(); |
Jason Molenda | 8c71337 | 2013-11-05 11:00:35 +0000 | [diff] [blame] | 1357 | } |
| 1358 | return 0; |
| 1359 | } |
| 1360 | |
| 1361 | const char * |
Jason Molenda | 95d005c | 2013-11-06 03:07:33 +0000 | [diff] [blame] | 1362 | SBProcess::GetExtendedBacktraceTypeAtIndex (uint32_t idx) |
Jason Molenda | 8c71337 | 2013-11-05 11:00:35 +0000 | [diff] [blame] | 1363 | { |
| 1364 | ProcessSP process_sp(GetSP()); |
| 1365 | if (process_sp && process_sp->GetSystemRuntime()) |
| 1366 | { |
| 1367 | SystemRuntime *runtime = process_sp->GetSystemRuntime(); |
Jason Molenda | 008c45f | 2013-11-12 23:33:32 +0000 | [diff] [blame] | 1368 | const std::vector<ConstString> &names = runtime->GetExtendedBacktraceTypes(); |
Jason Molenda | 8c71337 | 2013-11-05 11:00:35 +0000 | [diff] [blame] | 1369 | if (idx < names.size()) |
| 1370 | { |
| 1371 | return names[idx].AsCString(); |
| 1372 | } |
| 1373 | else |
| 1374 | { |
| 1375 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1376 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 1377 | log->Printf("SBProcess(%p)::GetExtendedBacktraceTypeAtIndex() => error: requested extended backtrace name out of bounds", |
| 1378 | static_cast<void*>(process_sp.get())); |
Jason Molenda | 8c71337 | 2013-11-05 11:00:35 +0000 | [diff] [blame] | 1379 | } |
| 1380 | } |
| 1381 | return NULL; |
| 1382 | } |
Kuba Brecka | a51ea38 | 2014-09-06 01:33:13 +0000 | [diff] [blame] | 1383 | |
| 1384 | SBThreadCollection |
| 1385 | SBProcess::GetHistoryThreads (addr_t addr) |
| 1386 | { |
| 1387 | ProcessSP process_sp(GetSP()); |
| 1388 | SBThreadCollection threads; |
| 1389 | if (process_sp) |
| 1390 | { |
| 1391 | threads = SBThreadCollection(process_sp->GetHistoryThreads(addr)); |
| 1392 | } |
| 1393 | return threads; |
| 1394 | } |
Kuba Brecka | 6392754 | 2014-10-11 01:59:32 +0000 | [diff] [blame] | 1395 | |
| 1396 | bool |
| 1397 | SBProcess::IsInstrumentationRuntimePresent(InstrumentationRuntimeType type) |
| 1398 | { |
| 1399 | ProcessSP process_sp(GetSP()); |
| 1400 | if (! process_sp) |
| 1401 | return false; |
| 1402 | |
| 1403 | InstrumentationRuntimeSP runtime_sp = process_sp->GetInstrumentationRuntime(type); |
| 1404 | |
| 1405 | if (! runtime_sp.get()) |
| 1406 | return false; |
| 1407 | |
| 1408 | return runtime_sp->IsActive(); |
| 1409 | } |