blob: 4697ca4b5f17633faf140c55d31bdfe2c568319e [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- State.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
10// C Includes
11// C++ Includes
12// Other libraries and framework includes
13// Project includes
14#include "lldb/Core/State.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000015
16using namespace lldb;
17using namespace lldb_private;
18
Kate Stoneb9c1b512016-09-06 20:57:50 +000019const char *lldb_private::StateAsCString(StateType state) {
20 switch (state) {
21 case eStateInvalid:
22 return "invalid";
23 case eStateUnloaded:
24 return "unloaded";
25 case eStateConnected:
26 return "connected";
27 case eStateAttaching:
28 return "attaching";
29 case eStateLaunching:
30 return "launching";
31 case eStateStopped:
32 return "stopped";
33 case eStateRunning:
34 return "running";
35 case eStateStepping:
36 return "stepping";
37 case eStateCrashed:
38 return "crashed";
39 case eStateDetached:
40 return "detached";
41 case eStateExited:
42 return "exited";
43 case eStateSuspended:
44 return "suspended";
45 }
Pavel Labath8198db32017-01-24 11:48:25 +000046 return "unknown";
Chris Lattner30fdc8d2010-06-08 16:52:24 +000047}
48
Kate Stoneb9c1b512016-09-06 20:57:50 +000049const char *lldb_private::GetPermissionsAsCString(uint32_t permissions) {
50 switch (permissions) {
51 case 0:
52 return "---";
53 case ePermissionsWritable:
54 return "-w-";
55 case ePermissionsReadable:
56 return "r--";
57 case ePermissionsExecutable:
58 return "--x";
59 case ePermissionsReadable | ePermissionsWritable:
60 return "rw-";
61 case ePermissionsReadable | ePermissionsExecutable:
62 return "r-x";
63 case ePermissionsWritable | ePermissionsExecutable:
64 return "-wx";
65 case ePermissionsReadable | ePermissionsWritable | ePermissionsExecutable:
66 return "rwx";
67 default:
68 break;
69 }
70 return "???";
Greg Claytond495c532011-05-17 03:37:42 +000071}
72
Kate Stoneb9c1b512016-09-06 20:57:50 +000073bool lldb_private::StateIsRunningState(StateType state) {
74 switch (state) {
75 case eStateAttaching:
76 case eStateLaunching:
77 case eStateRunning:
78 case eStateStepping:
79 return true;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000080
Kate Stoneb9c1b512016-09-06 20:57:50 +000081 case eStateConnected:
82 case eStateDetached:
83 case eStateInvalid:
84 case eStateUnloaded:
85 case eStateStopped:
86 case eStateCrashed:
87 case eStateExited:
88 case eStateSuspended:
89 break;
90 }
91 return false;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000092}
93
Kate Stoneb9c1b512016-09-06 20:57:50 +000094bool lldb_private::StateIsStoppedState(StateType state, bool must_exist) {
95 switch (state) {
96 case eStateInvalid:
97 case eStateConnected:
98 case eStateAttaching:
99 case eStateLaunching:
100 case eStateRunning:
101 case eStateStepping:
102 case eStateDetached:
103 break;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000104
Kate Stoneb9c1b512016-09-06 20:57:50 +0000105 case eStateUnloaded:
106 case eStateExited:
107 return !must_exist;
Greg Clayton2637f822011-11-17 01:23:07 +0000108
Kate Stoneb9c1b512016-09-06 20:57:50 +0000109 case eStateStopped:
110 case eStateCrashed:
111 case eStateSuspended:
112 return true;
113 }
114 return false;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000115}