]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Utility/State.cpp
MFC r345805: Unify SCSI_STATUS_BUSY retry handling with other cases.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Utility / State.cpp
1 //===-- 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 #include "lldb/Utility/State.h"
11
12 using namespace lldb;
13 using namespace lldb_private;
14
15 const char *lldb_private::StateAsCString(StateType state) {
16   switch (state) {
17   case eStateInvalid:
18     return "invalid";
19   case eStateUnloaded:
20     return "unloaded";
21   case eStateConnected:
22     return "connected";
23   case eStateAttaching:
24     return "attaching";
25   case eStateLaunching:
26     return "launching";
27   case eStateStopped:
28     return "stopped";
29   case eStateRunning:
30     return "running";
31   case eStateStepping:
32     return "stepping";
33   case eStateCrashed:
34     return "crashed";
35   case eStateDetached:
36     return "detached";
37   case eStateExited:
38     return "exited";
39   case eStateSuspended:
40     return "suspended";
41   }
42   return "unknown";
43 }
44
45 const char *lldb_private::GetPermissionsAsCString(uint32_t permissions) {
46   switch (permissions) {
47   case 0:
48     return "---";
49   case ePermissionsWritable:
50     return "-w-";
51   case ePermissionsReadable:
52     return "r--";
53   case ePermissionsExecutable:
54     return "--x";
55   case ePermissionsReadable | ePermissionsWritable:
56     return "rw-";
57   case ePermissionsReadable | ePermissionsExecutable:
58     return "r-x";
59   case ePermissionsWritable | ePermissionsExecutable:
60     return "-wx";
61   case ePermissionsReadable | ePermissionsWritable | ePermissionsExecutable:
62     return "rwx";
63   default:
64     break;
65   }
66   return "???";
67 }
68
69 bool lldb_private::StateIsRunningState(StateType state) {
70   switch (state) {
71   case eStateAttaching:
72   case eStateLaunching:
73   case eStateRunning:
74   case eStateStepping:
75     return true;
76
77   case eStateConnected:
78   case eStateDetached:
79   case eStateInvalid:
80   case eStateUnloaded:
81   case eStateStopped:
82   case eStateCrashed:
83   case eStateExited:
84   case eStateSuspended:
85     break;
86   }
87   return false;
88 }
89
90 bool lldb_private::StateIsStoppedState(StateType state, bool must_exist) {
91   switch (state) {
92   case eStateInvalid:
93   case eStateConnected:
94   case eStateAttaching:
95   case eStateLaunching:
96   case eStateRunning:
97   case eStateStepping:
98   case eStateDetached:
99     break;
100
101   case eStateUnloaded:
102   case eStateExited:
103     return !must_exist;
104
105   case eStateStopped:
106   case eStateCrashed:
107   case eStateSuspended:
108     return true;
109   }
110   return false;
111 }