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)
23 case CMICmnMIOutOfBandRecord::eOutOfBand_Running:
25 case CMICmnMIOutOfBandRecord::eOutOfBand_Stopped:
27 case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated:
28 return "breakpoint-created";
29 case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified:
30 return "breakpoint-modified";
31 case CMICmnMIOutOfBandRecord::eOutOfBand_Thread:
32 return ""; // "" Meant to be empty
33 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded:
34 return "thread-group-added";
35 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited:
36 return "thread-group-exited";
37 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved:
38 return "thread-group-removed";
39 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted:
40 return "thread-group-started";
41 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated:
42 return "thread-created";
43 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited:
44 return "thread-exited";
45 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected:
46 return "thread-selected";
47 case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded:
48 return "library-loaded";
49 case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded:
50 return "library-unloaded";
51 case CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput:
54 assert(false && "unknown CMICmnMIOutofBandRecord::OutOfBand_e");
59 MapOutOfBandToToken(CMICmnMIOutOfBandRecord::OutOfBand_e veType)
63 case CMICmnMIOutOfBandRecord::eOutOfBand_Running:
65 case CMICmnMIOutOfBandRecord::eOutOfBand_Stopped:
67 case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated:
69 case CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified:
71 case CMICmnMIOutOfBandRecord::eOutOfBand_Thread:
73 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded:
75 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited:
77 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved:
79 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted:
81 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated:
83 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited:
85 case CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected:
87 case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded:
89 case CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded:
91 case CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput:
94 assert(false && "unknown CMICmnMIOutofBandRecord::OutOfBand_e");
98 //++ ------------------------------------------------------------------------------------
99 // Details: Build the Out-of-band record's mandatory data part. The part up to the first
100 // (additional) result i.e. async-record ==> "*" type.
101 // Args: veType - (R) A MI Out-of-Band enumeration.
102 // Return: CMIUtilString - The async record text.
106 BuildAsyncRecord(CMICmnMIOutOfBandRecord::OutOfBand_e veType)
108 return CMIUtilString::Format("%s%s", MapOutOfBandToToken(veType), MapOutOfBandToText(veType));
111 //++ ------------------------------------------------------------------------------------
112 // Details: CMICmnMIOutOfBandRecord constructor.
118 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord()
119 : m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
123 //++ ------------------------------------------------------------------------------------
124 // Details: CMICmnMIOutOfBandRecord constructor.
126 // Args: veType - (R) A MI Out-of-Bound enumeration.
130 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(OutOfBand_e veType)
131 : m_strAsyncRecord(BuildAsyncRecord(veType))
135 //++ ------------------------------------------------------------------------------------
136 // Details: CMICmnMIOutOfBandRecord constructor.
138 // Args: veType - (R) A MI Out-of-Bound enumeration.
139 // vConst - (R) A MI const object.
143 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(OutOfBand_e veType, const CMICmnMIValueConst &vConst)
144 : m_strAsyncRecord(BuildAsyncRecord(veType))
146 m_strAsyncRecord += vConst.GetString();
149 //++ ------------------------------------------------------------------------------------
150 // Details: CMICmnMIOutOfBandRecord constructor.
152 // Args: veType - (R) A MI Out-of-Bound enumeration.
153 // vResult - (R) A MI result object.
157 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(OutOfBand_e veType, const CMICmnMIValueResult &vResult)
158 : m_strAsyncRecord(BuildAsyncRecord(veType))
163 //++ ------------------------------------------------------------------------------------
164 // Details: CMICmnMIOutOfBandRecord destructor.
165 // Type: Overrideable.
170 CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord()
174 //++ ------------------------------------------------------------------------------------
175 // Details: Return the MI Out-of-band record as a string. The string is a direct result of
176 // work done on *this Out-of-band record so if not enough data is added then it is
177 // possible to return a malformed Out-of-band record. If nothing has been set or
178 // added to *this MI Out-of-band record object then text "<Invalid>" will be returned.
181 // Return: CMIUtilString & - MI output text.
184 const CMIUtilString &
185 CMICmnMIOutOfBandRecord::GetString() const
187 return m_strAsyncRecord;
190 //++ ------------------------------------------------------------------------------------
191 // Details: Add to *this Out-of-band record additional information.
193 // Args: vResult - (R) A MI result object.
198 CMICmnMIOutOfBandRecord::Add(const CMICmnMIValueResult &vResult)
200 m_strAsyncRecord += ",";
201 m_strAsyncRecord += vResult.GetString();