]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp
MFV ntp 4.2.8p1 (r258945, r275970, r276091, r276092, r276093, r278284)
[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 //++
11 // File:        MICmnMIOutOfBandRecord.h
12 //
13 // Overview:    CMICmnMIOutOfBandRecord implementation.
14 //
15 // Environment: Compilers:  Visual C++ 12.
16 //                          gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 //              Libraries:  See MIReadmetxt.
18 //
19 // Copyright:   None.
20 //--
21
22 // In-house headers:
23 #include "MICmnMIOutOfBandRecord.h"
24 #include "MICmnResources.h"
25
26 // Instantiations:
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, "="}};
53
54 //++ ------------------------------------------------------------------------------------
55 // Details: CMICmnMIOutOfBandRecord constructor.
56 // Type:    Method.
57 // Args:    None.
58 // Return:  None.
59 // Throws:  None.
60 //--
61 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(void)
62     : m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
63 {
64 }
65
66 //++ ------------------------------------------------------------------------------------
67 // Details: CMICmnMIOutOfBandRecord constructor.
68 // Type:    Method.
69 // Args:    veType      - (R) A MI Out-of-Bound enumeration.
70 // Return:  None.
71 // Throws:  None.
72 //--
73 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(const OutOfBand_e veType)
74     : m_eResultAsyncRecordClass(veType)
75     , m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION))
76 {
77     BuildAsyncRecord();
78 }
79
80 //++ ------------------------------------------------------------------------------------
81 // Details: CMICmnMIOutOfBandRecord constructor.
82 // Type:    Method.
83 // Args:    veType      - (R) A MI Out-of-Bound enumeration.
84 //          vMIResult   - (R) A MI result object.
85 // Return:  None.
86 // Throws:  None.
87 //--
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)
92 {
93     BuildAsyncRecord();
94     Add(m_partResult);
95 }
96
97 //++ ------------------------------------------------------------------------------------
98 // Details: CMICmnMIOutOfBandRecord destructor.
99 // Type:    Overrideable.
100 // Args:    None.
101 // Return:  None.
102 // Throws:  None.
103 //--
104 CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord(void)
105 {
106 }
107
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.
113 // Type:    Method.
114 // Args:    None.
115 // Return:  CMIUtilString & - MI output text.
116 // Throws:  None.
117 //--
118 const CMIUtilString &
119 CMICmnMIOutOfBandRecord::GetString(void) const
120 {
121     return m_strAsyncRecord;
122 }
123
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.
127 // Type:    Method.
128 // Args:    None.
129 // Return:  MIstatus::success - Functional succeeded.
130 //          MIstatus::failure - Functional failed.
131 // Throws:  None.
132 //--
133 bool
134 CMICmnMIOutOfBandRecord::BuildAsyncRecord(void)
135 {
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());
140
141     return MIstatus::success;
142 }
143
144 //++ ------------------------------------------------------------------------------------
145 // Details: Add to *this Out-of-band record additional information.
146 // Type:    Method.
147 // Args:    vMIValue    - (R) A MI value derived object.
148 // Return:  MIstatus::success - Functional succeeded.
149 //          MIstatus::failure - Functional failed.
150 // Throws:  None.
151 //--
152 bool
153 CMICmnMIOutOfBandRecord::Add(const CMICmnMIValue &vMIValue)
154 {
155     m_strAsyncRecord += ",";
156     m_strAsyncRecord += vMIValue.GetString();
157
158     return MIstatus::success;
159 }