aboutsummaryrefslogtreecommitdiff
path: root/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp
blob: c3826f01ae85d57c5d3a0cf56f4b29e197b107f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//===-- MICmnMIOutOfBandRecord.cpp --------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

//++
// File:		MICmnMIOutOfBandRecord.h
//
// Overview:	CMICmnMIOutOfBandRecord implementation.
//
// Environment:	Compilers:	Visual C++ 12.
//							gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
//				Libraries:	See MIReadmetxt. 
//
// Copyright:	None.
//--

// In-house headers:
#include "MICmnMIOutOfBandRecord.h"
#include "MICmnResources.h"

// Instantiations:
CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_MapOutOfBandToOutOfBandText = 
{
	{ CMICmnMIOutOfBandRecord::eOutOfBand_Running, "running" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "stopped" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "breakpoint-created" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "breakpoint-modified" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_Thread, "" }, // "" Meant to be empty
	{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "thread-group-added" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, "thread-group-exited" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved, "thread-group-removed" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, "thread-group-started" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, "thread-created" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, "thread-exited" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, "thread-selected" }
};
CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_constMapAsyncRecordTextToToken = 
{
	{ CMICmnMIOutOfBandRecord::eOutOfBand_Running, "*" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "*" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "=" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "=" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_Thread, "@" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "=" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, "=" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved, "=" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, "=" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, "=" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, "=" },
	{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, "=" }
};
		
//++ ------------------------------------------------------------------------------------
// Details:	CMICmnMIOutOfBandRecord constructor.
// Type:	Method.
// Args:	None.
// Return:	None.
// Throws:	None.
//--
CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord( void )
:	m_strAsyncRecord( MIRSRC( IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION ) )
{
}

//++ ------------------------------------------------------------------------------------
// Details:	CMICmnMIOutOfBandRecord constructor.
// Type:	Method.
// Args:	veType	- (R) A MI Out-of-Bound enumeration.
// Return:	None.
// Throws:	None.
//--
CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord( const OutOfBand_e veType )
:	m_eResultAsyncRecordClass( veType )
,	m_strAsyncRecord( MIRSRC( IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION ) )
{
	BuildAsyncRecord();
}

//++ ------------------------------------------------------------------------------------
// Details:	CMICmnMIOutOfBandRecord constructor.
// Type:	Method.
// Args:	veType		- (R) A MI Out-of-Bound enumeration.
//			vMIResult	- (R) A MI result object.
// Return:	None.
// Throws:	None.
//--
CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord( const OutOfBand_e veType, const CMICmnMIValueResult & vValue )
:	m_eResultAsyncRecordClass( veType )
,	m_strAsyncRecord( MIRSRC( IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION ) )
,	m_partResult( vValue )	
{
	BuildAsyncRecord();
	Add( m_partResult );
}

//++ ------------------------------------------------------------------------------------
// Details:	CMICmnMIOutOfBandRecord destructor.
// Type:	Overrideable.
// Args:	None.
// Return:	None.
// Throws:	None.
//--
CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord( void )
{
}

//++ ------------------------------------------------------------------------------------
// Details:	Return the MI Out-of-band record as a string. The string is a direct result of
//			work done on *this Out-of-band record so if not enough data is added then it is
//			possible to return a malformed Out-of-band record. If nothing has been set or 
//			added to *this MI Out-of-band record object then text "<Invalid>" will be returned.
// Type:	Method.
// Args:	None.
// Return:	CMIUtilString &	- MI output text.
// Throws:	None.
//--
const CMIUtilString & CMICmnMIOutOfBandRecord::GetString( void ) const
{
	return m_strAsyncRecord;
}
	
//++ ------------------------------------------------------------------------------------
// Details:	Build the Out-of-band record's mandatory data part. The part up to the first
//			(additional) result i.e. async-record ==>  "*" type.
// Type:	Method.
// Args:	None.
// Return:	MIstatus::success - Functional succeeded.
//			MIstatus::failure - Functional failed.
// Throws:	None.
//--
bool CMICmnMIOutOfBandRecord::BuildAsyncRecord( void )
{
	const MIchar * pFormat = "%s%s";
	const CMIUtilString & rStrAsyncRecord( ms_MapOutOfBandToOutOfBandText[ m_eResultAsyncRecordClass ] );
	const CMIUtilString & rStrToken( ms_constMapAsyncRecordTextToToken[ m_eResultAsyncRecordClass ] );
	m_strAsyncRecord = CMIUtilString::Format( pFormat, rStrToken.c_str(), rStrAsyncRecord.c_str() );

	return MIstatus::success;
}

//++ ------------------------------------------------------------------------------------
// Details:	Add to *this Out-of-band record additional information.
// Type:	Method.
// Args:	vMIValue	- (R) A MI value derived object.
// Return:	MIstatus::success - Functional succeeded.
//			MIstatus::failure - Functional failed.
// Throws:	None.
//--
bool CMICmnMIOutOfBandRecord::Add( const CMICmnMIValue & vMIValue )
{
	m_strAsyncRecord += ",";
	m_strAsyncRecord += vMIValue.GetString();	

	return MIstatus::success;
}