Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 1 | //===-- ProcessPOSIX.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 | d891f9b | 2012-12-05 00:20:57 +0000 | [diff] [blame] | 10 | #include "lldb/lldb-python.h" |
| 11 | |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 12 | // C Includes |
| 13 | #include <errno.h> |
| 14 | |
| 15 | // C++ Includes |
| 16 | // Other libraries and framework includes |
Matt Kopec | 3d4d51c | 2013-05-07 19:29:28 +0000 | [diff] [blame] | 17 | #include "lldb/Breakpoint/Watchpoint.h" |
Greg Clayton | 8ac035d | 2012-09-04 14:55:50 +0000 | [diff] [blame] | 18 | #include "lldb/Core/Module.h" |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 19 | #include "lldb/Core/PluginManager.h" |
| 20 | #include "lldb/Core/State.h" |
Daniel Malea | 1e44fdd | 2013-01-08 14:49:22 +0000 | [diff] [blame] | 21 | #include "lldb/Host/FileSpec.h" |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 22 | #include "lldb/Host/Host.h" |
| 23 | #include "lldb/Symbol/ObjectFile.h" |
| 24 | #include "lldb/Target/DynamicLoader.h" |
Andrew Kaylor | 6c1a8cf | 2013-05-07 22:46:38 +0000 | [diff] [blame] | 25 | #include "lldb/Target/Platform.h" |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 26 | #include "lldb/Target/Target.h" |
| 27 | |
| 28 | #include "ProcessPOSIX.h" |
| 29 | #include "ProcessPOSIXLog.h" |
| 30 | #include "Plugins/Process/Utility/InferiorCallPOSIX.h" |
| 31 | #include "ProcessMonitor.h" |
| 32 | #include "POSIXThread.h" |
| 33 | |
| 34 | using namespace lldb; |
| 35 | using namespace lldb_private; |
| 36 | |
| 37 | //------------------------------------------------------------------------------ |
| 38 | // Static functions. |
| 39 | #if 0 |
| 40 | Process* |
| 41 | ProcessPOSIX::CreateInstance(Target& target, Listener &listener) |
| 42 | { |
| 43 | return new ProcessPOSIX(target, listener); |
| 44 | } |
| 45 | |
| 46 | |
| 47 | void |
| 48 | ProcessPOSIX::Initialize() |
| 49 | { |
| 50 | static bool g_initialized = false; |
| 51 | |
| 52 | if (!g_initialized) |
| 53 | { |
| 54 | g_initialized = true; |
| 55 | PluginManager::RegisterPlugin(GetPluginNameStatic(), |
| 56 | GetPluginDescriptionStatic(), |
| 57 | CreateInstance); |
| 58 | |
| 59 | Log::Callbacks log_callbacks = { |
| 60 | ProcessPOSIXLog::DisableLog, |
| 61 | ProcessPOSIXLog::EnableLog, |
| 62 | ProcessPOSIXLog::ListLogCategories |
| 63 | }; |
| 64 | |
| 65 | Log::RegisterLogChannel (ProcessPOSIX::GetPluginNameStatic(), log_callbacks); |
| 66 | } |
| 67 | } |
| 68 | #endif |
| 69 | |
| 70 | //------------------------------------------------------------------------------ |
| 71 | // Constructors and destructors. |
| 72 | |
| 73 | ProcessPOSIX::ProcessPOSIX(Target& target, Listener &listener) |
| 74 | : Process(target, listener), |
Johnny Chen | 78dae82 | 2012-04-14 00:54:42 +0000 | [diff] [blame] | 75 | m_byte_order(lldb::endian::InlHostByteOrder()), |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 76 | m_monitor(NULL), |
| 77 | m_module(NULL), |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 78 | m_message_mutex (Mutex::eMutexTypeRecursive), |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 79 | m_exit_now(false) |
| 80 | { |
| 81 | // FIXME: Putting this code in the ctor and saving the byte order in a |
| 82 | // member variable is a hack to avoid const qual issues in GetByteOrder. |
Johnny Chen | 78dae82 | 2012-04-14 00:54:42 +0000 | [diff] [blame] | 83 | lldb::ModuleSP module = GetTarget().GetExecutableModule(); |
Michael Sartain | a807cee | 2013-07-01 19:45:50 +0000 | [diff] [blame^] | 84 | if (module && module->GetObjectFile()) |
Johnny Chen | 78dae82 | 2012-04-14 00:54:42 +0000 | [diff] [blame] | 85 | m_byte_order = module->GetObjectFile()->GetByteOrder(); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | ProcessPOSIX::~ProcessPOSIX() |
| 89 | { |
| 90 | delete m_monitor; |
| 91 | } |
| 92 | |
| 93 | //------------------------------------------------------------------------------ |
| 94 | // Process protocol. |
| 95 | |
| 96 | bool |
| 97 | ProcessPOSIX::CanDebug(Target &target, bool plugin_specified_by_name) |
| 98 | { |
| 99 | // For now we are just making sure the file exists for a given module |
| 100 | ModuleSP exe_module_sp(target.GetExecutableModule()); |
| 101 | if (exe_module_sp.get()) |
| 102 | return exe_module_sp->GetFileSpec().Exists(); |
Andrew Kaylor | 6c1a8cf | 2013-05-07 22:46:38 +0000 | [diff] [blame] | 103 | // If there is no executable module, we return true since we might be preparing to attach. |
| 104 | return true; |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | Error |
| 108 | ProcessPOSIX::DoAttachToProcessWithID(lldb::pid_t pid) |
| 109 | { |
| 110 | Error error; |
| 111 | assert(m_monitor == NULL); |
| 112 | |
Ashok Thirumurthi | d8f6b64 | 2013-03-28 16:02:31 +0000 | [diff] [blame] | 113 | Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS)); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 114 | if (log && log->GetMask().Test(POSIX_LOG_VERBOSE)) |
Daniel Malea | 5f35a4b | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 115 | log->Printf ("ProcessPOSIX::%s(pid = %" PRIi64 ")", __FUNCTION__, GetID()); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 116 | |
| 117 | m_monitor = new ProcessMonitor(this, pid, error); |
| 118 | |
| 119 | if (!error.Success()) |
| 120 | return error; |
| 121 | |
Andrew Kaylor | 6c1a8cf | 2013-05-07 22:46:38 +0000 | [diff] [blame] | 122 | PlatformSP platform_sp (m_target.GetPlatform ()); |
| 123 | assert (platform_sp.get()); |
| 124 | if (!platform_sp) |
| 125 | return error; // FIXME: Detatch? |
| 126 | |
| 127 | // Find out what we can about this process |
| 128 | ProcessInstanceInfo process_info; |
| 129 | platform_sp->GetProcessInfo (pid, process_info); |
| 130 | |
| 131 | // Resolve the executable module |
| 132 | ModuleSP exe_module_sp; |
| 133 | FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths()); |
| 134 | error = platform_sp->ResolveExecutable(process_info.GetExecutableFile(), |
| 135 | m_target.GetArchitecture(), |
| 136 | exe_module_sp, |
| 137 | executable_search_paths.GetSize() ? &executable_search_paths : NULL); |
| 138 | |
| 139 | // Fix the target architecture if necessary |
| 140 | const ArchSpec &module_arch = exe_module_sp->GetArchitecture(); |
| 141 | if (module_arch.IsValid() && !m_target.GetArchitecture().IsExactMatch(module_arch)) |
| 142 | m_target.SetArchitecture(module_arch); |
| 143 | |
| 144 | // Initialize the target module list |
| 145 | m_target.SetExecutableModule (exe_module_sp, true); |
| 146 | |
| 147 | if (!error.Success()) |
| 148 | return error; |
| 149 | |
| 150 | SetSTDIOFileDescriptor(m_monitor->GetTerminalFD()); |
| 151 | |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 152 | SetID(pid); |
Andrew Kaylor | 6c1a8cf | 2013-05-07 22:46:38 +0000 | [diff] [blame] | 153 | |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 154 | return error; |
| 155 | } |
| 156 | |
| 157 | Error |
Greg Clayton | c643077 | 2012-09-07 17:51:47 +0000 | [diff] [blame] | 158 | ProcessPOSIX::DoAttachToProcessWithID (lldb::pid_t pid, const ProcessAttachInfo &attach_info) |
| 159 | { |
| 160 | return DoAttachToProcessWithID(pid); |
| 161 | } |
| 162 | |
| 163 | Error |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 164 | ProcessPOSIX::WillLaunch(Module* module) |
| 165 | { |
| 166 | Error error; |
| 167 | return error; |
| 168 | } |
| 169 | |
| 170 | const char * |
| 171 | ProcessPOSIX::GetFilePath( |
| 172 | const lldb_private::ProcessLaunchInfo::FileAction *file_action, |
| 173 | const char *default_path) |
| 174 | { |
| 175 | const char *pts_name = "/dev/pts/"; |
| 176 | const char *path = NULL; |
| 177 | |
| 178 | if (file_action) |
| 179 | { |
| 180 | if (file_action->GetAction () == ProcessLaunchInfo::FileAction::eFileActionOpen) |
| 181 | path = file_action->GetPath(); |
| 182 | // By default the stdio paths passed in will be pseudo-terminal |
| 183 | // (/dev/pts). If so, convert to using a different default path |
| 184 | // instead to redirect I/O to the debugger console. This should |
| 185 | // also handle user overrides to /dev/null or a different file. |
| 186 | if (::strncmp(path, pts_name, ::strlen(pts_name)) == 0) |
| 187 | path = default_path; |
| 188 | } |
| 189 | |
| 190 | return path; |
| 191 | } |
| 192 | |
| 193 | Error |
| 194 | ProcessPOSIX::DoLaunch (Module *module, |
| 195 | const ProcessLaunchInfo &launch_info) |
| 196 | { |
| 197 | Error error; |
| 198 | assert(m_monitor == NULL); |
| 199 | |
Daniel Malea | 1e44fdd | 2013-01-08 14:49:22 +0000 | [diff] [blame] | 200 | const char* working_dir = launch_info.GetWorkingDirectory(); |
| 201 | if (working_dir) { |
| 202 | FileSpec WorkingDir(working_dir, true); |
| 203 | if (!WorkingDir || WorkingDir.GetFileType() != FileSpec::eFileTypeDirectory) |
| 204 | { |
| 205 | error.SetErrorStringWithFormat("No such file or directory: %s", working_dir); |
| 206 | return error; |
| 207 | } |
| 208 | } |
| 209 | |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 210 | SetPrivateState(eStateLaunching); |
| 211 | |
| 212 | const lldb_private::ProcessLaunchInfo::FileAction *file_action; |
| 213 | |
| 214 | // Default of NULL will mean to use existing open file descriptors |
| 215 | const char *stdin_path = NULL; |
| 216 | const char *stdout_path = NULL; |
| 217 | const char *stderr_path = NULL; |
Daniel Malea | 1e44fdd | 2013-01-08 14:49:22 +0000 | [diff] [blame] | 218 | |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 219 | file_action = launch_info.GetFileActionForFD (STDIN_FILENO); |
| 220 | stdin_path = GetFilePath(file_action, stdin_path); |
| 221 | |
| 222 | file_action = launch_info.GetFileActionForFD (STDOUT_FILENO); |
| 223 | stdout_path = GetFilePath(file_action, stdout_path); |
| 224 | |
| 225 | file_action = launch_info.GetFileActionForFD (STDERR_FILENO); |
| 226 | stderr_path = GetFilePath(file_action, stderr_path); |
| 227 | |
| 228 | m_monitor = new ProcessMonitor (this, |
| 229 | module, |
| 230 | launch_info.GetArguments().GetConstArgumentVector(), |
| 231 | launch_info.GetEnvironmentEntries().GetConstArgumentVector(), |
| 232 | stdin_path, |
| 233 | stdout_path, |
| 234 | stderr_path, |
Daniel Malea | 1e44fdd | 2013-01-08 14:49:22 +0000 | [diff] [blame] | 235 | working_dir, |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 236 | error); |
| 237 | |
| 238 | m_module = module; |
| 239 | |
| 240 | if (!error.Success()) |
| 241 | return error; |
| 242 | |
Matt Kopec | a7cd95d | 2013-03-14 21:35:26 +0000 | [diff] [blame] | 243 | SetSTDIOFileDescriptor(m_monitor->GetTerminalFD()); |
| 244 | |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 245 | SetID(m_monitor->GetPID()); |
| 246 | return error; |
| 247 | } |
| 248 | |
| 249 | void |
| 250 | ProcessPOSIX::DidLaunch() |
| 251 | { |
| 252 | } |
| 253 | |
| 254 | Error |
| 255 | ProcessPOSIX::DoResume() |
| 256 | { |
| 257 | StateType state = GetPrivateState(); |
| 258 | |
Matt Kopec | 52b8b75 | 2013-06-26 18:46:08 +0000 | [diff] [blame] | 259 | assert(state == eStateStopped); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 260 | |
Matt Kopec | 52b8b75 | 2013-06-26 18:46:08 +0000 | [diff] [blame] | 261 | SetPrivateState(eStateRunning); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 262 | |
| 263 | bool did_resume = false; |
| 264 | uint32_t thread_count = m_thread_list.GetSize(false); |
| 265 | for (uint32_t i = 0; i < thread_count; ++i) |
| 266 | { |
| 267 | POSIXThread *thread = static_cast<POSIXThread*>( |
| 268 | m_thread_list.GetThreadAtIndex(i, false).get()); |
| 269 | did_resume = thread->Resume() || did_resume; |
| 270 | } |
| 271 | assert(did_resume && "Process resume failed!"); |
| 272 | |
| 273 | return Error(); |
| 274 | } |
| 275 | |
| 276 | addr_t |
| 277 | ProcessPOSIX::GetImageInfoAddress() |
| 278 | { |
| 279 | Target *target = &GetTarget(); |
| 280 | ObjectFile *obj_file = target->GetExecutableModule()->GetObjectFile(); |
| 281 | Address addr = obj_file->GetImageInfoAddress(); |
| 282 | |
| 283 | if (addr.IsValid()) |
| 284 | return addr.GetLoadAddress(target); |
| 285 | else |
| 286 | return LLDB_INVALID_ADDRESS; |
| 287 | } |
| 288 | |
| 289 | Error |
| 290 | ProcessPOSIX::DoHalt(bool &caused_stop) |
| 291 | { |
| 292 | Error error; |
| 293 | |
| 294 | if (IsStopped()) |
| 295 | { |
| 296 | caused_stop = false; |
| 297 | } |
| 298 | else if (kill(GetID(), SIGSTOP)) |
| 299 | { |
| 300 | caused_stop = false; |
| 301 | error.SetErrorToErrno(); |
| 302 | } |
| 303 | else |
| 304 | { |
| 305 | caused_stop = true; |
| 306 | } |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 307 | return error; |
| 308 | } |
| 309 | |
| 310 | Error |
Jim Ingham | 761afb8 | 2013-05-02 00:27:30 +0000 | [diff] [blame] | 311 | ProcessPOSIX::DoDetach(bool keep_stopped) |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 312 | { |
| 313 | Error error; |
Jim Ingham | 761afb8 | 2013-05-02 00:27:30 +0000 | [diff] [blame] | 314 | if (keep_stopped) |
| 315 | { |
| 316 | // FIXME: If you want to implement keep_stopped on Linux, |
| 317 | // this would be the place to do it. |
| 318 | error.SetErrorString("Detaching with keep_stopped true is not currently supported on Linux."); |
| 319 | return error; |
| 320 | } |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 321 | |
Matt Kopec | c350e13 | 2013-05-31 22:00:07 +0000 | [diff] [blame] | 322 | uint32_t thread_count = m_thread_list.GetSize(false); |
| 323 | for (uint32_t i = 0; i < thread_count; ++i) |
| 324 | { |
| 325 | POSIXThread *thread = static_cast<POSIXThread*>( |
| 326 | m_thread_list.GetThreadAtIndex(i, false).get()); |
| 327 | error = m_monitor->Detach(thread->GetID()); |
| 328 | } |
| 329 | |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 330 | if (error.Success()) |
| 331 | SetPrivateState(eStateDetached); |
| 332 | |
| 333 | return error; |
| 334 | } |
| 335 | |
| 336 | Error |
| 337 | ProcessPOSIX::DoSignal(int signal) |
| 338 | { |
| 339 | Error error; |
| 340 | |
| 341 | if (kill(GetID(), signal)) |
| 342 | error.SetErrorToErrno(); |
| 343 | |
| 344 | return error; |
| 345 | } |
| 346 | |
| 347 | Error |
| 348 | ProcessPOSIX::DoDestroy() |
| 349 | { |
| 350 | Error error; |
| 351 | |
| 352 | if (!HasExited()) |
| 353 | { |
| 354 | // Drive the exit event to completion (do not keep the inferior in |
| 355 | // limbo). |
| 356 | m_exit_now = true; |
| 357 | |
Greg Clayton | 972c438 | 2012-03-30 19:56:32 +0000 | [diff] [blame] | 358 | if ((m_monitor == NULL || kill(m_monitor->GetPID(), SIGKILL)) && error.Success()) |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 359 | { |
| 360 | error.SetErrorToErrno(); |
| 361 | return error; |
| 362 | } |
| 363 | |
| 364 | SetPrivateState(eStateExited); |
| 365 | } |
| 366 | |
| 367 | return error; |
| 368 | } |
| 369 | |
| 370 | void |
| 371 | ProcessPOSIX::SendMessage(const ProcessMessage &message) |
| 372 | { |
| 373 | Mutex::Locker lock(m_message_mutex); |
| 374 | |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 375 | POSIXThread *thread = static_cast<POSIXThread*>( |
| 376 | m_thread_list.FindThreadByID(message.GetTID(), false).get()); |
| 377 | |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 378 | switch (message.GetKind()) |
| 379 | { |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 380 | case ProcessMessage::eInvalidMessage: |
| 381 | return; |
| 382 | |
| 383 | case ProcessMessage::eLimboMessage: |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 384 | assert(thread); |
| 385 | thread->SetState(eStateStopped); |
| 386 | if (message.GetTID() == GetID()) |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 387 | { |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 388 | m_exit_status = message.GetExitStatus(); |
| 389 | if (m_exit_now) |
| 390 | { |
| 391 | SetPrivateState(eStateExited); |
Matt Kopec | c350e13 | 2013-05-31 22:00:07 +0000 | [diff] [blame] | 392 | m_monitor->Detach(GetID()); |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 393 | } |
| 394 | else |
| 395 | { |
| 396 | StopAllThreads(message.GetTID()); |
| 397 | SetPrivateState(eStateStopped); |
| 398 | } |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 399 | } |
| 400 | else |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 401 | { |
| 402 | StopAllThreads(message.GetTID()); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 403 | SetPrivateState(eStateStopped); |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 404 | } |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 405 | break; |
| 406 | |
| 407 | case ProcessMessage::eExitMessage: |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 408 | assert(thread); |
| 409 | thread->SetState(eStateExited); |
| 410 | // FIXME: I'm not sure we need to do this. |
| 411 | if (message.GetTID() == GetID()) |
| 412 | { |
| 413 | m_exit_status = message.GetExitStatus(); |
| 414 | SetExitStatus(m_exit_status, NULL); |
| 415 | } |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 416 | break; |
| 417 | |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 418 | case ProcessMessage::eBreakpointMessage: |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 419 | case ProcessMessage::eTraceMessage: |
Matt Kopec | 3d4d51c | 2013-05-07 19:29:28 +0000 | [diff] [blame] | 420 | case ProcessMessage::eWatchpointMessage: |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 421 | case ProcessMessage::eNewThreadMessage: |
| 422 | case ProcessMessage::eCrashMessage: |
| 423 | assert(thread); |
| 424 | thread->SetState(eStateStopped); |
| 425 | StopAllThreads(message.GetTID()); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 426 | SetPrivateState(eStateStopped); |
| 427 | break; |
| 428 | |
| 429 | case ProcessMessage::eSignalMessage: |
| 430 | case ProcessMessage::eSignalDeliveredMessage: |
Matt Kopec | f1fda37 | 2013-01-08 16:30:18 +0000 | [diff] [blame] | 431 | { |
| 432 | lldb::tid_t tid = message.GetTID(); |
| 433 | lldb::tid_t pid = GetID(); |
| 434 | if (tid == pid) { |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 435 | assert(thread); |
| 436 | thread->SetState(eStateStopped); |
| 437 | StopAllThreads(message.GetTID()); |
Matt Kopec | f1fda37 | 2013-01-08 16:30:18 +0000 | [diff] [blame] | 438 | SetPrivateState(eStateStopped); |
| 439 | break; |
| 440 | } else { |
| 441 | // FIXME: Ignore any signals generated by children. |
| 442 | return; |
| 443 | } |
| 444 | } |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 445 | |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | m_message_queue.push(message); |
| 449 | } |
| 450 | |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 451 | void |
| 452 | ProcessPOSIX::StopAllThreads(lldb::tid_t stop_tid) |
| 453 | { |
| 454 | // FIXME: Will this work the same way on FreeBSD and Linux? |
| 455 | } |
| 456 | |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 457 | void |
| 458 | ProcessPOSIX::RefreshStateAfterStop() |
| 459 | { |
Ashok Thirumurthi | d8f6b64 | 2013-03-28 16:02:31 +0000 | [diff] [blame] | 460 | Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS)); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 461 | if (log && log->GetMask().Test(POSIX_LOG_VERBOSE)) |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 462 | log->Printf ("ProcessPOSIX::%s(), message_queue size = %d", __FUNCTION__, (int)m_message_queue.size()); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 463 | |
| 464 | Mutex::Locker lock(m_message_mutex); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 465 | |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 466 | // This method used to only handle one message. Changing it to loop allows |
| 467 | // it to handle the case where we hit a breakpoint while handling a different |
| 468 | // breakpoint. |
| 469 | while (!m_message_queue.empty()) |
| 470 | { |
| 471 | ProcessMessage &message = m_message_queue.front(); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 472 | |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 473 | // Resolve the thread this message corresponds to and pass it along. |
| 474 | lldb::tid_t tid = message.GetTID(); |
| 475 | if (log) |
| 476 | log->Printf ("ProcessPOSIX::%s(), message_queue size = %d, pid = %" PRIi64, __FUNCTION__, (int)m_message_queue.size(), tid); |
| 477 | POSIXThread *thread = static_cast<POSIXThread*>( |
| 478 | GetThreadList().FindThreadByID(tid, false).get()); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 479 | |
Andrew Kaylor | 3bd2ebd | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 480 | if (message.GetKind() == ProcessMessage::eNewThreadMessage) |
| 481 | { |
| 482 | if (log) |
| 483 | log->Printf ("ProcessPOSIX::%s() adding thread, tid = %" PRIi64, __FUNCTION__, message.GetChildTID()); |
| 484 | ThreadSP thread_sp; |
| 485 | thread_sp.reset(new POSIXThread(*this, message.GetChildTID())); |
| 486 | m_thread_list.AddThread(thread_sp); |
| 487 | } |
| 488 | |
| 489 | m_thread_list.RefreshStateAfterStop(); |
| 490 | |
| 491 | if (thread) |
| 492 | thread->Notify(message); |
| 493 | |
| 494 | if (message.GetKind() == ProcessMessage::eExitMessage) |
| 495 | { |
| 496 | // FIXME: We should tell the user about this, but the limbo message is probably better for that. |
| 497 | if (log) |
| 498 | log->Printf ("ProcessPOSIX::%s() removing thread, tid = %" PRIi64, __FUNCTION__, tid); |
| 499 | ThreadSP thread_sp = m_thread_list.RemoveThreadByID(tid, false); |
| 500 | thread_sp.reset(); |
| 501 | } |
| 502 | |
| 503 | m_message_queue.pop(); |
Matt Kopec | f1fda37 | 2013-01-08 16:30:18 +0000 | [diff] [blame] | 504 | } |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | bool |
| 508 | ProcessPOSIX::IsAlive() |
| 509 | { |
| 510 | StateType state = GetPrivateState(); |
Daniel Malea | 0247cf5 | 2013-04-01 19:48:37 +0000 | [diff] [blame] | 511 | return state != eStateDetached |
| 512 | && state != eStateExited |
| 513 | && state != eStateInvalid |
| 514 | && state != eStateUnloaded; |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | size_t |
| 518 | ProcessPOSIX::DoReadMemory(addr_t vm_addr, |
| 519 | void *buf, size_t size, Error &error) |
| 520 | { |
| 521 | assert(m_monitor); |
| 522 | return m_monitor->ReadMemory(vm_addr, buf, size, error); |
| 523 | } |
| 524 | |
| 525 | size_t |
| 526 | ProcessPOSIX::DoWriteMemory(addr_t vm_addr, const void *buf, size_t size, |
| 527 | Error &error) |
| 528 | { |
| 529 | assert(m_monitor); |
| 530 | return m_monitor->WriteMemory(vm_addr, buf, size, error); |
| 531 | } |
| 532 | |
| 533 | addr_t |
| 534 | ProcessPOSIX::DoAllocateMemory(size_t size, uint32_t permissions, |
| 535 | Error &error) |
| 536 | { |
| 537 | addr_t allocated_addr = LLDB_INVALID_ADDRESS; |
| 538 | |
| 539 | unsigned prot = 0; |
| 540 | if (permissions & lldb::ePermissionsReadable) |
| 541 | prot |= eMmapProtRead; |
| 542 | if (permissions & lldb::ePermissionsWritable) |
| 543 | prot |= eMmapProtWrite; |
| 544 | if (permissions & lldb::ePermissionsExecutable) |
| 545 | prot |= eMmapProtExec; |
| 546 | |
| 547 | if (InferiorCallMmap(this, allocated_addr, 0, size, prot, |
| 548 | eMmapFlagsAnon | eMmapFlagsPrivate, -1, 0)) { |
| 549 | m_addr_to_mmap_size[allocated_addr] = size; |
| 550 | error.Clear(); |
| 551 | } else { |
| 552 | allocated_addr = LLDB_INVALID_ADDRESS; |
| 553 | error.SetErrorStringWithFormat("unable to allocate %zu bytes of memory with permissions %s", size, GetPermissionsAsCString (permissions)); |
| 554 | } |
| 555 | |
| 556 | return allocated_addr; |
| 557 | } |
| 558 | |
| 559 | Error |
| 560 | ProcessPOSIX::DoDeallocateMemory(lldb::addr_t addr) |
| 561 | { |
| 562 | Error error; |
| 563 | MMapMap::iterator pos = m_addr_to_mmap_size.find(addr); |
| 564 | if (pos != m_addr_to_mmap_size.end() && |
| 565 | InferiorCallMunmap(this, addr, pos->second)) |
| 566 | m_addr_to_mmap_size.erase (pos); |
| 567 | else |
Daniel Malea | 5f35a4b | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 568 | error.SetErrorStringWithFormat("unable to deallocate memory at 0x%" PRIx64, addr); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 569 | |
| 570 | return error; |
| 571 | } |
| 572 | |
Matt Kopec | 4f9103f | 2013-02-27 20:13:38 +0000 | [diff] [blame] | 573 | addr_t |
| 574 | ProcessPOSIX::ResolveIndirectFunction(const Address *address, Error &error) |
| 575 | { |
| 576 | addr_t function_addr = LLDB_INVALID_ADDRESS; |
| 577 | if (address == NULL) { |
| 578 | error.SetErrorStringWithFormat("unable to determine direct function call for NULL address"); |
| 579 | } else if (!InferiorCall(this, address, function_addr)) { |
| 580 | function_addr = LLDB_INVALID_ADDRESS; |
Matt Kopec | 7012548 | 2013-03-01 17:44:31 +0000 | [diff] [blame] | 581 | error.SetErrorStringWithFormat("unable to determine direct function call for indirect function %s", |
| 582 | address->CalculateSymbolContextSymbol()->GetName().AsCString()); |
Matt Kopec | 4f9103f | 2013-02-27 20:13:38 +0000 | [diff] [blame] | 583 | } |
| 584 | return function_addr; |
| 585 | } |
| 586 | |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 587 | size_t |
| 588 | ProcessPOSIX::GetSoftwareBreakpointTrapOpcode(BreakpointSite* bp_site) |
| 589 | { |
| 590 | static const uint8_t g_i386_opcode[] = { 0xCC }; |
| 591 | |
| 592 | ArchSpec arch = GetTarget().GetArchitecture(); |
| 593 | const uint8_t *opcode = NULL; |
| 594 | size_t opcode_size = 0; |
| 595 | |
| 596 | switch (arch.GetCore()) |
| 597 | { |
| 598 | default: |
| 599 | assert(false && "CPU type not supported!"); |
| 600 | break; |
| 601 | |
| 602 | case ArchSpec::eCore_x86_32_i386: |
| 603 | case ArchSpec::eCore_x86_64_x86_64: |
| 604 | opcode = g_i386_opcode; |
| 605 | opcode_size = sizeof(g_i386_opcode); |
| 606 | break; |
| 607 | } |
| 608 | |
| 609 | bp_site->SetTrapOpcode(opcode, opcode_size); |
| 610 | return opcode_size; |
| 611 | } |
| 612 | |
| 613 | Error |
Daniel Malea | 52d8dd9 | 2013-02-15 20:23:25 +0000 | [diff] [blame] | 614 | ProcessPOSIX::EnableBreakpointSite(BreakpointSite *bp_site) |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 615 | { |
| 616 | return EnableSoftwareBreakpoint(bp_site); |
| 617 | } |
| 618 | |
| 619 | Error |
Daniel Malea | 52d8dd9 | 2013-02-15 20:23:25 +0000 | [diff] [blame] | 620 | ProcessPOSIX::DisableBreakpointSite(BreakpointSite *bp_site) |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 621 | { |
| 622 | return DisableSoftwareBreakpoint(bp_site); |
| 623 | } |
| 624 | |
Matt Kopec | 3d4d51c | 2013-05-07 19:29:28 +0000 | [diff] [blame] | 625 | Error |
| 626 | ProcessPOSIX::EnableWatchpoint(Watchpoint *wp, bool notify) |
| 627 | { |
| 628 | Error error; |
| 629 | if (wp) |
| 630 | { |
| 631 | user_id_t watchID = wp->GetID(); |
| 632 | addr_t addr = wp->GetLoadAddress(); |
| 633 | Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS)); |
| 634 | if (log) |
| 635 | log->Printf ("ProcessPOSIX::EnableWatchpoint(watchID = %" PRIu64 ")", |
| 636 | watchID); |
| 637 | if (wp->IsEnabled()) |
| 638 | { |
| 639 | if (log) |
| 640 | log->Printf("ProcessPOSIX::EnableWatchpoint(watchID = %" PRIu64 |
| 641 | ") addr = 0x%8.8" PRIx64 ": watchpoint already enabled.", |
| 642 | watchID, (uint64_t)addr); |
| 643 | return error; |
| 644 | } |
| 645 | |
Matt Kopec | 12c5bf3 | 2013-06-03 17:40:20 +0000 | [diff] [blame] | 646 | // Try to find a vacant watchpoint slot in the inferiors' main thread |
| 647 | uint32_t wp_hw_index = LLDB_INVALID_INDEX32; |
| 648 | POSIXThread *thread = static_cast<POSIXThread*>( |
| 649 | m_thread_list.GetThreadAtIndex(0, false).get()); |
| 650 | |
| 651 | if (thread) |
| 652 | wp_hw_index = thread->FindVacantWatchpointIndex(); |
| 653 | |
| 654 | if (wp_hw_index == LLDB_INVALID_INDEX32) |
Matt Kopec | 3d4d51c | 2013-05-07 19:29:28 +0000 | [diff] [blame] | 655 | { |
Matt Kopec | 12c5bf3 | 2013-06-03 17:40:20 +0000 | [diff] [blame] | 656 | error.SetErrorString("Setting hardware watchpoint failed."); |
Matt Kopec | 3d4d51c | 2013-05-07 19:29:28 +0000 | [diff] [blame] | 657 | } |
| 658 | else |
| 659 | { |
Matt Kopec | 12c5bf3 | 2013-06-03 17:40:20 +0000 | [diff] [blame] | 660 | wp->SetHardwareIndex(wp_hw_index); |
| 661 | bool wp_enabled = true; |
| 662 | uint32_t thread_count = m_thread_list.GetSize(false); |
| 663 | for (uint32_t i = 0; i < thread_count; ++i) |
| 664 | { |
| 665 | thread = static_cast<POSIXThread*>( |
| 666 | m_thread_list.GetThreadAtIndex(i, false).get()); |
| 667 | if (thread) |
| 668 | wp_enabled &= thread->EnableHardwareWatchpoint(wp); |
| 669 | else |
| 670 | wp_enabled = false; |
| 671 | } |
| 672 | if (wp_enabled) |
| 673 | { |
| 674 | wp->SetEnabled(true, notify); |
| 675 | return error; |
| 676 | } |
| 677 | else |
| 678 | { |
| 679 | // Watchpoint enabling failed on at least one |
| 680 | // of the threads so roll back all of them |
| 681 | DisableWatchpoint(wp, false); |
| 682 | error.SetErrorString("Setting hardware watchpoint failed"); |
| 683 | } |
Matt Kopec | 3d4d51c | 2013-05-07 19:29:28 +0000 | [diff] [blame] | 684 | } |
| 685 | } |
| 686 | else |
| 687 | error.SetErrorString("Watchpoint argument was NULL."); |
| 688 | return error; |
| 689 | } |
| 690 | |
| 691 | Error |
| 692 | ProcessPOSIX::DisableWatchpoint(Watchpoint *wp, bool notify) |
| 693 | { |
| 694 | Error error; |
| 695 | if (wp) |
| 696 | { |
| 697 | user_id_t watchID = wp->GetID(); |
| 698 | addr_t addr = wp->GetLoadAddress(); |
| 699 | Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS)); |
| 700 | if (log) |
| 701 | log->Printf("ProcessPOSIX::DisableWatchpoint(watchID = %" PRIu64 ")", |
| 702 | watchID); |
| 703 | if (!wp->IsEnabled()) |
| 704 | { |
| 705 | if (log) |
| 706 | log->Printf("ProcessPOSIX::DisableWatchpoint(watchID = %" PRIu64 |
| 707 | ") addr = 0x%8.8" PRIx64 ": watchpoint already disabled.", |
| 708 | watchID, (uint64_t)addr); |
| 709 | // This is needed (for now) to keep watchpoints disabled correctly |
| 710 | wp->SetEnabled(false, notify); |
| 711 | return error; |
| 712 | } |
| 713 | |
| 714 | if (wp->IsHardware()) |
| 715 | { |
| 716 | bool wp_disabled = true; |
| 717 | uint32_t thread_count = m_thread_list.GetSize(false); |
| 718 | for (uint32_t i = 0; i < thread_count; ++i) |
| 719 | { |
| 720 | POSIXThread *thread = static_cast<POSIXThread*>( |
| 721 | m_thread_list.GetThreadAtIndex(i, false).get()); |
| 722 | if (thread) |
| 723 | wp_disabled &= thread->DisableHardwareWatchpoint(wp); |
| 724 | else |
| 725 | wp_disabled = false; |
| 726 | } |
| 727 | if (wp_disabled) |
| 728 | { |
Matt Kopec | 12c5bf3 | 2013-06-03 17:40:20 +0000 | [diff] [blame] | 729 | wp->SetHardwareIndex(LLDB_INVALID_INDEX32); |
Matt Kopec | 3d4d51c | 2013-05-07 19:29:28 +0000 | [diff] [blame] | 730 | wp->SetEnabled(false, notify); |
| 731 | return error; |
| 732 | } |
| 733 | else |
| 734 | error.SetErrorString("Disabling hardware watchpoint failed"); |
| 735 | } |
| 736 | } |
| 737 | else |
| 738 | error.SetErrorString("Watchpoint argument was NULL."); |
| 739 | return error; |
| 740 | } |
| 741 | |
| 742 | Error |
| 743 | ProcessPOSIX::GetWatchpointSupportInfo(uint32_t &num) |
| 744 | { |
| 745 | Error error; |
| 746 | POSIXThread *thread = static_cast<POSIXThread*>( |
| 747 | m_thread_list.GetThreadAtIndex(0, false).get()); |
| 748 | if (thread) |
| 749 | num = thread->NumSupportedHardwareWatchpoints(); |
| 750 | else |
| 751 | error.SetErrorString("Process does not exist."); |
| 752 | return error; |
| 753 | } |
| 754 | |
| 755 | Error |
| 756 | ProcessPOSIX::GetWatchpointSupportInfo(uint32_t &num, bool &after) |
| 757 | { |
| 758 | Error error = GetWatchpointSupportInfo(num); |
| 759 | // Watchpoints trigger and halt the inferior after |
| 760 | // the corresponding instruction has been executed. |
| 761 | after = true; |
| 762 | return error; |
| 763 | } |
| 764 | |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 765 | uint32_t |
| 766 | ProcessPOSIX::UpdateThreadListIfNeeded() |
| 767 | { |
| 768 | // Do not allow recursive updates. |
| 769 | return m_thread_list.GetSize(false); |
| 770 | } |
| 771 | |
Greg Clayton | c8dd570 | 2012-04-12 19:04:34 +0000 | [diff] [blame] | 772 | bool |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 773 | ProcessPOSIX::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) |
| 774 | { |
Ashok Thirumurthi | d8f6b64 | 2013-03-28 16:02:31 +0000 | [diff] [blame] | 775 | Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD)); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 776 | if (log && log->GetMask().Test(POSIX_LOG_VERBOSE)) |
Daniel Malea | 5f35a4b | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 777 | log->Printf ("ProcessPOSIX::%s() (pid = %" PRIi64 ")", __FUNCTION__, GetID()); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 778 | |
| 779 | // Update the process thread list with this new thread. |
| 780 | // FIXME: We should be using tid, not pid. |
| 781 | assert(m_monitor); |
| 782 | ThreadSP thread_sp (old_thread_list.FindThreadByID (GetID(), false)); |
Greg Clayton | e5eaa30 | 2012-02-21 18:40:07 +0000 | [diff] [blame] | 783 | if (!thread_sp) { |
Greg Clayton | 5e91e37 | 2012-10-12 16:23:23 +0000 | [diff] [blame] | 784 | thread_sp.reset(new POSIXThread(*this, GetID())); |
Greg Clayton | e5eaa30 | 2012-02-21 18:40:07 +0000 | [diff] [blame] | 785 | } |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 786 | |
| 787 | if (log && log->GetMask().Test(POSIX_LOG_VERBOSE)) |
Daniel Malea | 5f35a4b | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 788 | log->Printf ("ProcessPOSIX::%s() updated pid = %" PRIi64, __FUNCTION__, GetID()); |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 789 | new_thread_list.AddThread(thread_sp); |
| 790 | |
Greg Clayton | c8dd570 | 2012-04-12 19:04:34 +0000 | [diff] [blame] | 791 | return new_thread_list.GetSize(false) > 0; |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 792 | } |
| 793 | |
| 794 | ByteOrder |
| 795 | ProcessPOSIX::GetByteOrder() const |
| 796 | { |
| 797 | // FIXME: We should be able to extract this value directly. See comment in |
| 798 | // ProcessPOSIX(). |
| 799 | return m_byte_order; |
| 800 | } |
| 801 | |
| 802 | size_t |
| 803 | ProcessPOSIX::PutSTDIN(const char *buf, size_t len, Error &error) |
| 804 | { |
| 805 | ssize_t status; |
| 806 | if ((status = write(m_monitor->GetTerminalFD(), buf, len)) < 0) |
| 807 | { |
| 808 | error.SetErrorToErrno(); |
| 809 | return 0; |
| 810 | } |
| 811 | return status; |
| 812 | } |
| 813 | |
Johnny Chen | 2341d35 | 2012-01-05 21:48:15 +0000 | [diff] [blame] | 814 | UnixSignals & |
| 815 | ProcessPOSIX::GetUnixSignals() |
| 816 | { |
| 817 | return m_signals; |
| 818 | } |
| 819 | |
| 820 | //------------------------------------------------------------------------------ |
| 821 | // Utility functions. |
| 822 | |
| 823 | bool |
| 824 | ProcessPOSIX::HasExited() |
| 825 | { |
| 826 | switch (GetPrivateState()) |
| 827 | { |
| 828 | default: |
| 829 | break; |
| 830 | |
| 831 | case eStateDetached: |
| 832 | case eStateExited: |
| 833 | return true; |
| 834 | } |
| 835 | |
| 836 | return false; |
| 837 | } |
| 838 | |
| 839 | bool |
| 840 | ProcessPOSIX::IsStopped() |
| 841 | { |
| 842 | switch (GetPrivateState()) |
| 843 | { |
| 844 | default: |
| 845 | break; |
| 846 | |
| 847 | case eStateStopped: |
| 848 | case eStateCrashed: |
| 849 | case eStateSuspended: |
| 850 | return true; |
| 851 | } |
| 852 | |
| 853 | return false; |
| 854 | } |