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