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
10
11using namespace lldb;
12using 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
44const char *lldb_private::GetPermissionsAsCString(uint32_t permissions) {
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
89bool 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}
A class that represents a running process on the host machine.
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
bool StateIsRunningState(lldb::StateType state)
Check if a state represents a state where the process or thread is running.
Definition: State.cpp:68
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
Definition: State.cpp:14
const char * GetPermissionsAsCString(uint32_t permissions)
Definition: State.cpp:44
Definition: SBAddress.h:15
StateType
Process and Thread States.
@ eStateUnloaded
Process is object is valid, but not currently loaded.
@ eStateConnected
Process is connected to remote debug services, but not launched or attached to anything yet.
@ eStateDetached
Process has been detached and can't be examined.
@ eStateStopped
Process or thread is stopped and can be examined.
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
@ eStateRunning
Process or thread is running and can't be examined.
@ eStateLaunching
Process is in the process of launching.
@ eStateAttaching
Process is currently trying to attach.
@ eStateExited
Process has exited and can't be examined.
@ eStateStepping
Process or thread is in the process of stepping and can not be examined.
@ eStateCrashed
Process or thread has crashed and can be examined.