]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp
Merge ^/head r275715 through r275748.
[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 {
29         { CMICmnMIOutOfBandRecord::eOutOfBand_Running, "running" },
30         { CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "stopped" },
31         { CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "breakpoint-created" },
32         { CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "breakpoint-modified" },
33         { CMICmnMIOutOfBandRecord::eOutOfBand_Thread, "" }, // "" Meant to be empty
34         { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "thread-group-added" },
35         { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, "thread-group-exited" },
36         { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved, "thread-group-removed" },
37         { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, "thread-group-started" },
38         { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, "thread-created" },
39         { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, "thread-exited" },
40         { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, "thread-selected" }
41 };
42 CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_constMapAsyncRecordTextToToken = 
43 {
44         { CMICmnMIOutOfBandRecord::eOutOfBand_Running, "*" },
45         { CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "*" },
46         { CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "=" },
47         { CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "=" },
48         { CMICmnMIOutOfBandRecord::eOutOfBand_Thread, "@" },
49         { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "=" },
50         { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, "=" },
51         { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved, "=" },
52         { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, "=" },
53         { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, "=" },
54         { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, "=" },
55         { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, "=" }
56 };
57                 
58 //++ ------------------------------------------------------------------------------------
59 // Details:     CMICmnMIOutOfBandRecord constructor.
60 // Type:        Method.
61 // Args:        None.
62 // Return:      None.
63 // Throws:      None.
64 //--
65 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord( void )
66 :       m_strAsyncRecord( MIRSRC( IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION ) )
67 {
68 }
69
70 //++ ------------------------------------------------------------------------------------
71 // Details:     CMICmnMIOutOfBandRecord constructor.
72 // Type:        Method.
73 // Args:        veType  - (R) A MI Out-of-Bound enumeration.
74 // Return:      None.
75 // Throws:      None.
76 //--
77 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord( const OutOfBand_e veType )
78 :       m_eResultAsyncRecordClass( veType )
79 ,       m_strAsyncRecord( MIRSRC( IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION ) )
80 {
81         BuildAsyncRecord();
82 }
83
84 //++ ------------------------------------------------------------------------------------
85 // Details:     CMICmnMIOutOfBandRecord constructor.
86 // Type:        Method.
87 // Args:        veType          - (R) A MI Out-of-Bound enumeration.
88 //                      vMIResult       - (R) A MI result object.
89 // Return:      None.
90 // Throws:      None.
91 //--
92 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord( const OutOfBand_e veType, const CMICmnMIValueResult & vValue )
93 :       m_eResultAsyncRecordClass( veType )
94 ,       m_strAsyncRecord( MIRSRC( IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION ) )
95 ,       m_partResult( vValue )  
96 {
97         BuildAsyncRecord();
98         Add( m_partResult );
99 }
100
101 //++ ------------------------------------------------------------------------------------
102 // Details:     CMICmnMIOutOfBandRecord destructor.
103 // Type:        Overrideable.
104 // Args:        None.
105 // Return:      None.
106 // Throws:      None.
107 //--
108 CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord( void )
109 {
110 }
111
112 //++ ------------------------------------------------------------------------------------
113 // Details:     Return the MI Out-of-band record as a string. The string is a direct result of
114 //                      work done on *this Out-of-band record so if not enough data is added then it is
115 //                      possible to return a malformed Out-of-band record. If nothing has been set or 
116 //                      added to *this MI Out-of-band record object then text "<Invalid>" will be returned.
117 // Type:        Method.
118 // Args:        None.
119 // Return:      CMIUtilString & - MI output text.
120 // Throws:      None.
121 //--
122 const CMIUtilString & CMICmnMIOutOfBandRecord::GetString( void ) const
123 {
124         return m_strAsyncRecord;
125 }
126         
127 //++ ------------------------------------------------------------------------------------
128 // Details:     Build the Out-of-band record's mandatory data part. The part up to the first
129 //                      (additional) result i.e. async-record ==>  "*" type.
130 // Type:        Method.
131 // Args:        None.
132 // Return:      MIstatus::success - Functional succeeded.
133 //                      MIstatus::failure - Functional failed.
134 // Throws:      None.
135 //--
136 bool CMICmnMIOutOfBandRecord::BuildAsyncRecord( void )
137 {
138         const MIchar * pFormat = "%s%s";
139         const CMIUtilString & rStrAsyncRecord( ms_MapOutOfBandToOutOfBandText[ m_eResultAsyncRecordClass ] );
140         const CMIUtilString & rStrToken( ms_constMapAsyncRecordTextToToken[ m_eResultAsyncRecordClass ] );
141         m_strAsyncRecord = CMIUtilString::Format( pFormat, rStrToken.c_str(), rStrAsyncRecord.c_str() );
142
143         return MIstatus::success;
144 }
145
146 //++ ------------------------------------------------------------------------------------
147 // Details:     Add to *this Out-of-band record additional information.
148 // Type:        Method.
149 // Args:        vMIValue        - (R) A MI value derived object.
150 // Return:      MIstatus::success - Functional succeeded.
151 //                      MIstatus::failure - Functional failed.
152 // Throws:      None.
153 //--
154 bool CMICmnMIOutOfBandRecord::Add( const CMICmnMIValue & vMIValue )
155 {
156         m_strAsyncRecord += ",";
157         m_strAsyncRecord += vMIValue.GetString();       
158
159         return MIstatus::success;
160 }
161