]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp
Upgrade to OpenSSH 6.7p1, retaining libwrap support (which has been removed
[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 // In-house headers:
11 #include "MICmnMIOutOfBandRecord.h"
12 #include "MICmnResources.h"
13
14 // Instantiations:
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, "@"}};
47
48 //++ ------------------------------------------------------------------------------------
49 // Details: CMICmnMIOutOfBandRecord constructor.
50 // Type:    Method.
51 // Args:    None.
52 // Return:  None.
53 // Throws:  None.
54 //--
55 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(void)
56     : m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
57 {
58 }
59
60 //++ ------------------------------------------------------------------------------------
61 // Details: CMICmnMIOutOfBandRecord constructor.
62 // Type:    Method.
63 // Args:    veType      - (R) A MI Out-of-Bound enumeration.
64 // Return:  None.
65 // Throws:  None.
66 //--
67 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType)
68     : m_eResultAsyncRecordClass(veType)
69     , m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
70 {
71     BuildAsyncRecord();
72 }
73
74 //++ ------------------------------------------------------------------------------------
75 // Details: CMICmnMIOutOfBandRecord constructor.
76 // Type:    Method.
77 // Args:    veType      - (R) A MI Out-of-Bound enumeration.
78 //          vConst      - (R) A MI const object.
79 // Return:  None.
80 // Throws:  None.
81 //--
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))
85 {
86     BuildAsyncRecord();
87     m_strAsyncRecord += vConst.GetString();
88 }
89
90 //++ ------------------------------------------------------------------------------------
91 // Details: CMICmnMIOutOfBandRecord constructor.
92 // Type:    Method.
93 // Args:    veType      - (R) A MI Out-of-Bound enumeration.
94 //          vResult     - (R) A MI result object.
95 // Return:  None.
96 // Throws:  None.
97 //--
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)
102 {
103     BuildAsyncRecord();
104     Add(m_partResult);
105 }
106
107 //++ ------------------------------------------------------------------------------------
108 // Details: CMICmnMIOutOfBandRecord destructor.
109 // Type:    Overrideable.
110 // Args:    None.
111 // Return:  None.
112 // Throws:  None.
113 //--
114 CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord(void)
115 {
116 }
117
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.
123 // Type:    Method.
124 // Args:    None.
125 // Return:  CMIUtilString & - MI output text.
126 // Throws:  None.
127 //--
128 const CMIUtilString &
129 CMICmnMIOutOfBandRecord::GetString(void) const
130 {
131     return m_strAsyncRecord;
132 }
133
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.
137 // Type:    Method.
138 // Args:    None.
139 // Return:  MIstatus::success - Functional succeeded.
140 //          MIstatus::failure - Functional failed.
141 // Throws:  None.
142 //--
143 bool
144 CMICmnMIOutOfBandRecord::BuildAsyncRecord(void)
145 {
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());
150
151     return MIstatus::success;
152 }
153
154 //++ ------------------------------------------------------------------------------------
155 // Details: Add to *this Out-of-band record additional information.
156 // Type:    Method.
157 // Args:    vResult           - (R) A MI result object.
158 // Return:  MIstatus::success - Functional succeeded.
159 //          MIstatus::failure - Functional failed.
160 // Throws:  None.
161 //--
162 bool
163 CMICmnMIOutOfBandRecord::Add(const CMICmnMIValueResult &vResult)
164 {
165     m_strAsyncRecord += ",";
166     m_strAsyncRecord += vResult.GetString();
167
168     return MIstatus::success;
169 }