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 //===----------------------------------------------------------------------===//
11 #include "MICmnMIOutOfBandRecord.h"
12 #include "MICmnResources.h"
15 CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_MapOutOfBandToOutOfBandText = {
16 {CMICmnMIOutOfBandRecord::eOutOfBand_Running, "running"},
17 {CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "stopped"},
18 {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "breakpoint-created"},
19 {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "breakpoint-modified"},
20 {CMICmnMIOutOfBandRecord::eOutOfBand_Thread, ""}, // "" Meant to be empty
21 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "thread-group-added"},
22 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, "thread-group-exited"},
23 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved, "thread-group-removed"},
24 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, "thread-group-started"},
25 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, "thread-created"},
26 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, "thread-exited"},
27 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, "thread-selected"},
28 {CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded, "library-loaded"},
29 {CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded, "library-unloaded"},
30 {CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, ""}};
31 CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_constMapAsyncRecordTextToToken = {
32 {CMICmnMIOutOfBandRecord::eOutOfBand_Running, "*"},
33 {CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "*"},
34 {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "="},
35 {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "="},
36 {CMICmnMIOutOfBandRecord::eOutOfBand_Thread, "@"},
37 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "="},
38 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, "="},
39 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved, "="},
40 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, "="},
41 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, "="},
42 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, "="},
43 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, "="},
44 {CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded, "="},
45 {CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleUnloaded, "="},
46 {CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, "@"}};
48 //++ ------------------------------------------------------------------------------------
49 // Details: CMICmnMIOutOfBandRecord constructor.
55 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(void)
56 : m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
60 //++ ------------------------------------------------------------------------------------
61 // Details: CMICmnMIOutOfBandRecord constructor.
63 // Args: veType - (R) A MI Out-of-Bound enumeration.
67 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType)
68 : m_eResultAsyncRecordClass(veType)
69 , m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
74 //++ ------------------------------------------------------------------------------------
75 // Details: CMICmnMIOutOfBandRecord constructor.
77 // Args: veType - (R) A MI Out-of-Bound enumeration.
78 // vConst - (R) A MI const object.
82 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const CMICmnMIValueConst &vConst)
83 : m_eResultAsyncRecordClass(veType)
84 , m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
87 m_strAsyncRecord += vConst.GetString();
90 //++ ------------------------------------------------------------------------------------
91 // Details: CMICmnMIOutOfBandRecord constructor.
93 // Args: veType - (R) A MI Out-of-Bound enumeration.
94 // vResult - (R) A MI result object.
98 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const CMICmnMIValueResult &vResult)
99 : m_eResultAsyncRecordClass(veType)
100 , m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
101 , m_partResult(vResult)
107 //++ ------------------------------------------------------------------------------------
108 // Details: CMICmnMIOutOfBandRecord destructor.
109 // Type: Overrideable.
114 CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord(void)
118 //++ ------------------------------------------------------------------------------------
119 // Details: Return the MI Out-of-band record as a string. The string is a direct result of
120 // work done on *this Out-of-band record so if not enough data is added then it is
121 // possible to return a malformed Out-of-band record. If nothing has been set or
122 // added to *this MI Out-of-band record object then text "<Invalid>" will be returned.
125 // Return: CMIUtilString & - MI output text.
128 const CMIUtilString &
129 CMICmnMIOutOfBandRecord::GetString(void) const
131 return m_strAsyncRecord;
134 //++ ------------------------------------------------------------------------------------
135 // Details: Build the Out-of-band record's mandatory data part. The part up to the first
136 // (additional) result i.e. async-record ==> "*" type.
139 // Return: MIstatus::success - Functional succeeded.
140 // MIstatus::failure - Functional failed.
144 CMICmnMIOutOfBandRecord::BuildAsyncRecord(void)
146 const char *pFormat = "%s%s";
147 const CMIUtilString &rStrAsyncRecord(ms_MapOutOfBandToOutOfBandText[m_eResultAsyncRecordClass]);
148 const CMIUtilString &rStrToken(ms_constMapAsyncRecordTextToToken[m_eResultAsyncRecordClass]);
149 m_strAsyncRecord = CMIUtilString::Format(pFormat, rStrToken.c_str(), rStrAsyncRecord.c_str());
151 return MIstatus::success;
154 //++ ------------------------------------------------------------------------------------
155 // Details: Add to *this Out-of-band record additional information.
157 // Args: vResult - (R) A MI result object.
158 // Return: MIstatus::success - Functional succeeded.
159 // MIstatus::failure - Functional failed.
163 CMICmnMIOutOfBandRecord::Add(const CMICmnMIValueResult &vResult)
165 m_strAsyncRecord += ",";
166 m_strAsyncRecord += vResult.GetString();
168 return MIstatus::success;