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 // File: MICmnMIOutOfBandRecord.h
13 // Overview: CMICmnMIOutOfBandRecord implementation.
15 // Environment: Compilers: Visual C++ 12.
16 // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 // Libraries: See MIReadmetxt.
23 #include "MICmnMIOutOfBandRecord.h"
24 #include "MICmnResources.h"
27 CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_MapOutOfBandToOutOfBandText = {
28 {CMICmnMIOutOfBandRecord::eOutOfBand_Running, "running"},
29 {CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "stopped"},
30 {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "breakpoint-created"},
31 {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "breakpoint-modified"},
32 {CMICmnMIOutOfBandRecord::eOutOfBand_Thread, ""}, // "" Meant to be empty
33 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "thread-group-added"},
34 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, "thread-group-exited"},
35 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved, "thread-group-removed"},
36 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, "thread-group-started"},
37 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, "thread-created"},
38 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, "thread-exited"},
39 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, "thread-selected"}};
40 CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_constMapAsyncRecordTextToToken = {
41 {CMICmnMIOutOfBandRecord::eOutOfBand_Running, "*"},
42 {CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "*"},
43 {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "="},
44 {CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "="},
45 {CMICmnMIOutOfBandRecord::eOutOfBand_Thread, "@"},
46 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "="},
47 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, "="},
48 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved, "="},
49 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, "="},
50 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, "="},
51 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, "="},
52 {CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, "="}};
54 //++ ------------------------------------------------------------------------------------
55 // Details: CMICmnMIOutOfBandRecord constructor.
61 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(void)
62 : m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
66 //++ ------------------------------------------------------------------------------------
67 // Details: CMICmnMIOutOfBandRecord constructor.
69 // Args: veType - (R) A MI Out-of-Bound enumeration.
73 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType)
74 : m_eResultAsyncRecordClass(veType)
75 , m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
80 //++ ------------------------------------------------------------------------------------
81 // Details: CMICmnMIOutOfBandRecord constructor.
83 // Args: veType - (R) A MI Out-of-Bound enumeration.
84 // vMIResult - (R) A MI result object.
88 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType, const CMICmnMIValueResult &vValue)
89 : m_eResultAsyncRecordClass(veType)
90 , m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
91 , m_partResult(vValue)
97 //++ ------------------------------------------------------------------------------------
98 // Details: CMICmnMIOutOfBandRecord destructor.
99 // Type: Overrideable.
104 CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord(void)
108 //++ ------------------------------------------------------------------------------------
109 // Details: Return the MI Out-of-band record as a string. The string is a direct result of
110 // work done on *this Out-of-band record so if not enough data is added then it is
111 // possible to return a malformed Out-of-band record. If nothing has been set or
112 // added to *this MI Out-of-band record object then text "<Invalid>" will be returned.
115 // Return: CMIUtilString & - MI output text.
118 const CMIUtilString &
119 CMICmnMIOutOfBandRecord::GetString(void) const
121 return m_strAsyncRecord;
124 //++ ------------------------------------------------------------------------------------
125 // Details: Build the Out-of-band record's mandatory data part. The part up to the first
126 // (additional) result i.e. async-record ==> "*" type.
129 // Return: MIstatus::success - Functional succeeded.
130 // MIstatus::failure - Functional failed.
134 CMICmnMIOutOfBandRecord::BuildAsyncRecord(void)
136 const MIchar *pFormat = "%s%s";
137 const CMIUtilString &rStrAsyncRecord(ms_MapOutOfBandToOutOfBandText[m_eResultAsyncRecordClass]);
138 const CMIUtilString &rStrToken(ms_constMapAsyncRecordTextToToken[m_eResultAsyncRecordClass]);
139 m_strAsyncRecord = CMIUtilString::Format(pFormat, rStrToken.c_str(), rStrAsyncRecord.c_str());
141 return MIstatus::success;
144 //++ ------------------------------------------------------------------------------------
145 // Details: Add to *this Out-of-band record additional information.
147 // Args: vMIValue - (R) A MI value derived object.
148 // Return: MIstatus::success - Functional succeeded.
149 // MIstatus::failure - Functional failed.
153 CMICmnMIOutOfBandRecord::Add(const CMICmnMIValue &vMIValue)
155 m_strAsyncRecord += ",";
156 m_strAsyncRecord += vMIValue.GetString();
158 return MIstatus::success;