LLDB  mainline
State.cpp
Go to the documentation of this file.
1 //===-- State.cpp ---------------------------------------------------------===//
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 }
lldb::eStateAttaching
@ eStateAttaching
Process is currently trying to attach.
Definition: lldb-enumerations.h:78
lldb_private::StateAsCString
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
Definition: State.cpp:14
lldb_private::StateIsRunningState
bool StateIsRunningState(lldb::StateType state)
Check if a state represents a state where the process or thread is running.
Definition: State.cpp:68
lldb_private::GetPermissionsAsCString
const char * GetPermissionsAsCString(uint32_t permissions)
Definition: State.cpp:44
lldb::eStateExited
@ eStateExited
Process has exited and can't be examined.
Definition: lldb-enumerations.h:90
lldb::eStateStopped
@ eStateStopped
Process or thread is stopped and can be examined.
Definition: lldb-enumerations.h:84
lldb::eStateCrashed
@ eStateCrashed
Process or thread has crashed and can be examined.
Definition: lldb-enumerations.h:88
lldb_private::StateIsStoppedState
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
lldb::eStateConnected
@ eStateConnected
Process is connected to remote debug services, but not launched or attached to anything yet.
Definition: lldb-enumerations.h:76
lldb::eStateLaunching
@ eStateLaunching
Process is in the process of launching.
Definition: lldb-enumerations.h:79
lldb::eStateDetached
@ eStateDetached
Process has been detached and can't be examined.
Definition: lldb-enumerations.h:89
lldb::eStateUnloaded
@ eStateUnloaded
Process is object is valid, but not currently loaded.
Definition: lldb-enumerations.h:75
lldb::eStateStepping
@ eStateStepping
Process or thread is in the process of stepping and can not be examined.
Definition: lldb-enumerations.h:86
lldb::eStateSuspended
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
Definition: lldb-enumerations.h:91
uint32_t
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb::eStateInvalid
@ eStateInvalid
Definition: lldb-enumerations.h:74
State.h
lldb::StateType
StateType
Process and Thread States.
Definition: lldb-enumerations.h:73
lldb
Definition: SBAddress.h:15
lldb::eStateRunning
@ eStateRunning
Process or thread is running and can't be examined.
Definition: lldb-enumerations.h:85