blob: c660477f1c456ba64a518d392ce9de6dd3da04b1 [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"
Eli Friedman88966972010-06-09 08:50:27 +000015#include <stdio.h>
Chris Lattner30fdc8d2010-06-08 16:52:24 +000016
17using namespace lldb;
18using namespace lldb_private;
19
20const char *
21lldb_private::StateAsCString (StateType state)
22{
23 switch (state)
24 {
Greg Clayton19388cf2010-10-18 01:45:30 +000025 case eStateInvalid: return "invalid";
26 case eStateUnloaded: return "unloaded";
Greg Claytonb766a732011-02-04 01:58:07 +000027 case eStateConnected: return "connected";
Greg Clayton19388cf2010-10-18 01:45:30 +000028 case eStateAttaching: return "attaching";
29 case eStateLaunching: return "launching";
30 case eStateStopped: return "stopped";
31 case eStateRunning: return "running";
32 case eStateStepping: return "stepping";
33 case eStateCrashed: return "crashed";
34 case eStateDetached: return "detached";
35 case eStateExited: return "exited";
36 case eStateSuspended: return "suspended";
Chris Lattner30fdc8d2010-06-08 16:52:24 +000037 }
38 static char unknown_state_string[64];
39 snprintf(unknown_state_string, sizeof (unknown_state_string), "StateType = %i", state);
40 return unknown_state_string;
41}
42
Greg Clayton84c39662011-04-27 22:04:39 +000043const char *
Greg Claytond495c532011-05-17 03:37:42 +000044lldb_private::GetPermissionsAsCString (uint32_t permissions)
45{
46 switch (permissions)
47 {
48 case 0: return "---";
49 case ePermissionsWritable: return "-w-";
50 case ePermissionsReadable: return "r--";
51 case ePermissionsExecutable: return "--x";
52 case ePermissionsReadable |
53 ePermissionsWritable: return "rw-";
54 case ePermissionsReadable |
55 ePermissionsExecutable: return "r-x";
56 case ePermissionsWritable |
57 ePermissionsExecutable: return "-wx";
58 case ePermissionsReadable |
59 ePermissionsWritable |
60 ePermissionsExecutable: return "rwx";
61 default:
62 break;
63 }
64 return "???";
65}
66
Chris Lattner30fdc8d2010-06-08 16:52:24 +000067bool
68lldb_private::StateIsRunningState (StateType state)
69{
70 switch (state)
71 {
72 case eStateAttaching:
73 case eStateLaunching:
74 case eStateRunning:
75 case eStateStepping:
76 return true;
77
Greg Claytonb766a732011-02-04 01:58:07 +000078 case eStateConnected:
Chris Lattner30fdc8d2010-06-08 16:52:24 +000079 case eStateDetached:
80 case eStateInvalid:
81 case eStateUnloaded:
82 case eStateStopped:
83 case eStateCrashed:
84 case eStateExited:
85 case eStateSuspended:
86 default:
87 break;
88 }
89 return false;
90}
91
92bool
Greg Clayton2637f822011-11-17 01:23:07 +000093lldb_private::StateIsStoppedState (StateType state, bool must_exist)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000094{
95 switch (state)
96 {
97 case eStateInvalid:
Greg Claytonb766a732011-02-04 01:58:07 +000098 case eStateConnected:
Chris Lattner30fdc8d2010-06-08 16:52:24 +000099 case eStateAttaching:
100 case eStateLaunching:
101 case eStateRunning:
102 case eStateStepping:
103 case eStateDetached:
104 default:
105 break;
106
107 case eStateUnloaded:
Greg Clayton2637f822011-11-17 01:23:07 +0000108 case eStateExited:
109 return !must_exist;
110
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000111 case eStateStopped:
112 case eStateCrashed:
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000113 case eStateSuspended:
114 return true;
115 }
116 return false;
117}