]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp
Merge ^/head r311132 through r311305.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / tools / lldb-mi / MICmnMIOutOfBandRecord.cpp
1 //===-- MICmnMIOutOfBandRecord.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 // Third Party Headers:
11 #include <assert.h>
12
13 // In-house headers:
14 #include "MICmnMIOutOfBandRecord.h"
15 #include "MICmnResources.h"
16
17 // Instantiations:
18 static const char *
19 MapOutOfBandToText(CMICmnMIOutOfBandRecord::OutOfBand_e veType) {
20   switch (veType) {
21   case CMICmnMIOutOfBandRecord::eOutOfBand_Running:
22     return "running";
23   case CMICmnMIOutOfBandRecord::eOutOfBand_Stopped:
24     return "stopped";
25   case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated:
26     return "breakpoint-created";
27   case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified:
28     return "breakpoint-modified";
29   case CMICmnMIOutOfBandRecord::eOutOfBand_Thread:
30     return ""; // "" Meant to be empty
31   case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded:
32     return "thread-group-added";
33   case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited:
34     return "thread-group-exited";
35   case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved:
36     return "thread-group-removed";
37   case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted:
38     return "thread-group-started";
39   case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated:
40     return "thread-created";
41   case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited:
42     return "thread-exited";
43   case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected:
44     return "thread-selected";
45   case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded:
46     return "library-loaded";
47   case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded:
48     return "library-unloaded";
49   case CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput:
50     return "";
51   }
52   assert(false && "unknown CMICmnMIOutofBandRecord::OutOfBand_e");
53   return NULL;
54 }
55
56 static const char *
57 MapOutOfBandToToken(CMICmnMIOutOfBandRecord::OutOfBand_e veType) {
58   switch (veType) {
59   case CMICmnMIOutOfBandRecord::eOutOfBand_Running:
60     return "*";
61   case CMICmnMIOutOfBandRecord::eOutOfBand_Stopped:
62     return "*";
63   case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated:
64     return "=";
65   case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified:
66     return "=";
67   case CMICmnMIOutOfBandRecord::eOutOfBand_Thread:
68     return "@";
69   case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded:
70     return "=";
71   case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited:
72     return "=";
73   case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved:
74     return "=";
75   case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted:
76     return "=";
77   case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated:
78     return "=";
79   case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited:
80     return "=";
81   case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected:
82     return "=";
83   case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded:
84     return "=";
85   case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded:
86     return "=";
87   case CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput:
88     return "@";
89   }
90   assert(false && "unknown CMICmnMIOutofBandRecord::OutOfBand_e");
91   return NULL;
92 }
93
94 //++
95 //------------------------------------------------------------------------------------
96 // Details: Build the Out-of-band record's mandatory data part. The part up to
97 // the first
98 //          (additional) result i.e. async-record ==>  "*" type.
99 // Args:    veType      - (R) A MI Out-of-Band enumeration.
100 // Return:  CMIUtilString - The async record text.
101 // Throws:  None.
102 //--
103 static CMIUtilString
104 BuildAsyncRecord(CMICmnMIOutOfBandRecord::OutOfBand_e veType) {
105   return CMIUtilString::Format("%s%s", MapOutOfBandToToken(veType),
106                                MapOutOfBandToText(veType));
107 }
108
109 //++
110 //------------------------------------------------------------------------------------
111 // Details: CMICmnMIOutOfBandRecord constructor.
112 // Type:    Method.
113 // Args:    None.
114 // Return:  None.
115 // Throws:  None.
116 //--
117 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord()
118     : m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION)) {}
119
120 //++
121 //------------------------------------------------------------------------------------
122 // Details: CMICmnMIOutOfBandRecord constructor.
123 // Type:    Method.
124 // Args:    veType      - (R) A MI Out-of-Bound enumeration.
125 // Return:  None.
126 // Throws:  None.
127 //--
128 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(OutOfBand_e veType)
129     : m_strAsyncRecord(BuildAsyncRecord(veType)) {}
130
131 //++
132 //------------------------------------------------------------------------------------
133 // Details: CMICmnMIOutOfBandRecord constructor.
134 // Type:    Method.
135 // Args:    veType      - (R) A MI Out-of-Bound enumeration.
136 //          vConst      - (R) A MI const object.
137 // Return:  None.
138 // Throws:  None.
139 //--
140 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(
141     OutOfBand_e veType, const CMICmnMIValueConst &vConst)
142     : m_strAsyncRecord(BuildAsyncRecord(veType)) {
143   m_strAsyncRecord += vConst.GetString();
144 }
145
146 //++
147 //------------------------------------------------------------------------------------
148 // Details: CMICmnMIOutOfBandRecord constructor.
149 // Type:    Method.
150 // Args:    veType      - (R) A MI Out-of-Bound enumeration.
151 //          vResult     - (R) A MI result object.
152 // Return:  None.
153 // Throws:  None.
154 //--
155 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(
156     OutOfBand_e veType, const CMICmnMIValueResult &vResult)
157     : m_strAsyncRecord(BuildAsyncRecord(veType)) {
158   Add(vResult);
159 }
160
161 //++
162 //------------------------------------------------------------------------------------
163 // Details: CMICmnMIOutOfBandRecord destructor.
164 // Type:    Overrideable.
165 // Args:    None.
166 // Return:  None.
167 // Throws:  None.
168 //--
169 CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord() {}
170
171 //++
172 //------------------------------------------------------------------------------------
173 // Details: Return the MI Out-of-band record as a string. The string is a direct
174 // result of
175 //          work done on *this Out-of-band record so if not enough data is added
176 //          then it is
177 //          possible to return a malformed Out-of-band record. If nothing has
178 //          been set or
179 //          added to *this MI Out-of-band record object then text "<Invalid>"
180 //          will be returned.
181 // Type:    Method.
182 // Args:    None.
183 // Return:  CMIUtilString & - MI output text.
184 // Throws:  None.
185 //--
186 const CMIUtilString &CMICmnMIOutOfBandRecord::GetString() const {
187   return m_strAsyncRecord;
188 }
189
190 //++
191 //------------------------------------------------------------------------------------
192 // Details: Add to *this Out-of-band record additional information.
193 // Type:    Method.
194 // Args:    vResult           - (R) A MI result object.
195 // Return:  None.
196 // Throws:  None.
197 //--
198 void CMICmnMIOutOfBandRecord::Add(const CMICmnMIValueResult &vResult) {
199   m_strAsyncRecord += ",";
200   m_strAsyncRecord += vResult.GetString();
201 }