LLDB  mainline
State.cpp
Go to the documentation of this file.
1 //===-- State.cpp -----------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/Utility/State.h"
10 
11 using namespace lldb;
12 using namespace lldb_private;
13 
15  switch (state) {
16  case eStateInvalid:
17  return "invalid";
18  case eStateUnloaded:
19  return "unloaded";
20  case eStateConnected:
21  return "connected";
22  case eStateAttaching:
23  return "attaching";
24  case eStateLaunching:
25  return "launching";
26  case eStateStopped:
27  return "stopped";
28  case eStateRunning:
29  return "running";
30  case eStateStepping:
31  return "stepping";
32  case eStateCrashed:
33  return "crashed";
34  case eStateDetached:
35  return "detached";
36  case eStateExited:
37  return "exited";
38  case eStateSuspended:
39  return "suspended";
40  }
41  return "unknown";
42 }
43 
45  switch (permissions) {
46  case 0:
47  return "---";
48  case ePermissionsWritable:
49  return "-w-";
50  case ePermissionsReadable:
51  return "r--";
52  case ePermissionsExecutable:
53  return "--x";
54  case ePermissionsReadable | ePermissionsWritable:
55  return "rw-";
56  case ePermissionsReadable | ePermissionsExecutable:
57  return "r-x";
58  case ePermissionsWritable | ePermissionsExecutable:
59  return "-wx";
60  case ePermissionsReadable | ePermissionsWritable | ePermissionsExecutable:
61  return "rwx";
62  default:
63  break;
64  }
65  return "???";
66 }
67 
69  switch (state) {
70  case eStateAttaching:
71  case eStateLaunching:
72  case eStateRunning:
73  case eStateStepping:
74  return true;
75 
76  case eStateConnected:
77  case eStateDetached:
78  case eStateInvalid:
79  case eStateUnloaded:
80  case eStateStopped:
81  case eStateCrashed:
82  case eStateExited:
83  case eStateSuspended:
84  break;
85  }
86  return false;
87 }
88 
89 bool lldb_private::StateIsStoppedState(StateType state, bool must_exist) {
90  switch (state) {
91  case eStateInvalid:
92  case eStateConnected:
93  case eStateAttaching:
94  case eStateLaunching:
95  case eStateRunning:
96  case eStateStepping:
97  case eStateDetached:
98  break;
99 
100  case eStateUnloaded:
101  case eStateExited:
102  return !must_exist;
103 
104  case eStateStopped:
105  case eStateCrashed:
106  case eStateSuspended:
107  return true;
108  }
109  return false;
110 }
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
Definition: State.cpp:14
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
Process is currently trying to attach.
const char * GetPermissionsAsCString(uint32_t permissions)
Definition: State.cpp:44
Process or thread is stopped and can be examined.
Process or thread has crashed and can be examined.
Process has exited and can't be examined.
bool StateIsRunningState(lldb::StateType state)
Check if a state represents a state where the process or thread is running.
Definition: State.cpp:68
bool StateIsStoppedState(lldb::StateType state, bool must_exist)
Check if a state represents a state where the process or thread is stopped.
Definition: State.cpp:89
Process is connected to remote debug services, but not launched or attached to anything yet...
Process has been detached and can't be examined.
Process is in the process of launching.
Process or thread is in the process of stepping and can not be examined.
Process is object is valid, but not currently loaded.
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
Definition: SBAddress.h:15
Process or thread is running and can't be examined.