1 //===-- MICmnMIOutOfBandRecord.cpp ------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Third Party Headers:
14 #include "MICmnMIOutOfBandRecord.h"
15 #include "MICmnResources.h"
19 MapOutOfBandToText(CMICmnMIOutOfBandRecord::OutOfBand_e veType) {
21 case CMICmnMIOutOfBandRecord::eOutOfBand_Running:
23 case CMICmnMIOutOfBandRecord::eOutOfBand_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:
52 assert(false && "unknown CMICmnMIOutofBandRecord::OutOfBand_e");
57 MapOutOfBandToToken(CMICmnMIOutOfBandRecord::OutOfBand_e veType) {
59 case CMICmnMIOutOfBandRecord::eOutOfBand_Running:
61 case CMICmnMIOutOfBandRecord::eOutOfBand_Stopped:
63 case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated:
65 case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified:
67 case CMICmnMIOutOfBandRecord::eOutOfBand_Thread:
69 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded:
71 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited:
73 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved:
75 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted:
77 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated:
79 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited:
81 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected:
83 case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded:
85 case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded:
87 case CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput:
90 assert(false && "unknown CMICmnMIOutofBandRecord::OutOfBand_e");
95 //------------------------------------------------------------------------------------
96 // Details: Build the Out-of-band record's mandatory data part. The part up to
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.
104 BuildAsyncRecord(CMICmnMIOutOfBandRecord::OutOfBand_e veType) {
105 return CMIUtilString::Format("%s%s", MapOutOfBandToToken(veType),
106 MapOutOfBandToText(veType));
110 //------------------------------------------------------------------------------------
111 // Details: CMICmnMIOutOfBandRecord constructor.
117 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord()
118 : m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION)) {}
121 //------------------------------------------------------------------------------------
122 // Details: CMICmnMIOutOfBandRecord constructor.
124 // Args: veType - (R) A MI Out-of-Bound enumeration.
128 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(OutOfBand_e veType)
129 : m_strAsyncRecord(BuildAsyncRecord(veType)) {}
132 //------------------------------------------------------------------------------------
133 // Details: CMICmnMIOutOfBandRecord constructor.
135 // Args: veType - (R) A MI Out-of-Bound enumeration.
136 // vConst - (R) A MI const object.
140 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(
141 OutOfBand_e veType, const CMICmnMIValueConst &vConst)
142 : m_strAsyncRecord(BuildAsyncRecord(veType)) {
143 m_strAsyncRecord += vConst.GetString();
147 //------------------------------------------------------------------------------------
148 // Details: CMICmnMIOutOfBandRecord constructor.
150 // Args: veType - (R) A MI Out-of-Bound enumeration.
151 // vResult - (R) A MI result object.
155 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(
156 OutOfBand_e veType, const CMICmnMIValueResult &vResult)
157 : m_strAsyncRecord(BuildAsyncRecord(veType)) {
162 //------------------------------------------------------------------------------------
163 // Details: CMICmnMIOutOfBandRecord destructor.
164 // Type: Overrideable.
169 CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord() {}
172 //------------------------------------------------------------------------------------
173 // Details: Return the MI Out-of-band record as a string. The string is a direct
175 // work done on *this Out-of-band record so if not enough data is added
177 // possible to return a malformed Out-of-band record. If nothing has
179 // added to *this MI Out-of-band record object then text "<Invalid>"
183 // Return: CMIUtilString & - MI output text.
186 const CMIUtilString &CMICmnMIOutOfBandRecord::GetString() const {
187 return m_strAsyncRecord;
191 //------------------------------------------------------------------------------------
192 // Details: Add to *this Out-of-band record additional information.
194 // Args: vResult - (R) A MI result object.
198 void CMICmnMIOutOfBandRecord::Add(const CMICmnMIValueResult &vResult) {
199 m_strAsyncRecord += ",";
200 m_strAsyncRecord += vResult.GetString();