blob: 8bad24313b789b509770023d9900fb5273551741 [file] [log] [blame]
Deepak Panickal6f9c4682014-05-16 10:51:01 +00001//===-- MICmnLLDBBroadcaster.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
Deepak Panickal6f9c4682014-05-16 10:51:01 +000010// In-house headers:
11#include "MICmnLLDBBroadcaster.h"
12
13//++ ------------------------------------------------------------------------------------
Zachary Turner1d6af022014-11-17 18:06:21 +000014// Details: CMICmnLLDBBroadcaster constructor.
15// Type: Method.
16// Args: None.
17// Return: None.
18// Throws: None.
Deepak Panickal6f9c4682014-05-16 10:51:01 +000019//--
Zachary Turner1d6af022014-11-17 18:06:21 +000020CMICmnLLDBBroadcaster::CMICmnLLDBBroadcaster(void)
21 : lldb::SBBroadcaster("MI driver")
Deepak Panickal6f9c4682014-05-16 10:51:01 +000022{
23}
24
25//++ ------------------------------------------------------------------------------------
Zachary Turner1d6af022014-11-17 18:06:21 +000026// Details: CMICmnLLDBBroadcaster destructor.
27// Type: Overridable.
28// Args: None.
29// Return: None.
30// Throws: None.
Deepak Panickal6f9c4682014-05-16 10:51:01 +000031//--
Zachary Turner1d6af022014-11-17 18:06:21 +000032CMICmnLLDBBroadcaster::~CMICmnLLDBBroadcaster(void)
Deepak Panickal6f9c4682014-05-16 10:51:01 +000033{
Zachary Turner1d6af022014-11-17 18:06:21 +000034 Shutdown();
Deepak Panickal6f9c4682014-05-16 10:51:01 +000035}
36
37//++ ------------------------------------------------------------------------------------
Bruce Mitchenerae4c0262015-07-07 14:04:40 +000038// Details: Initialize resources for *this broadcaster object.
Zachary Turner1d6af022014-11-17 18:06:21 +000039// Type: Method.
40// Args: None.
41// Return: MIstatus::success - Functionality succeeded.
42// MIstatus::failure - Functionality failed.
43// Throws: None.
Deepak Panickal6f9c4682014-05-16 10:51:01 +000044//--
Zachary Turner1d6af022014-11-17 18:06:21 +000045bool
46CMICmnLLDBBroadcaster::Initialize(void)
Deepak Panickal6f9c4682014-05-16 10:51:01 +000047{
Zachary Turner1d6af022014-11-17 18:06:21 +000048 m_clientUsageRefCnt++;
Deepak Panickal6f9c4682014-05-16 10:51:01 +000049
Zachary Turner1d6af022014-11-17 18:06:21 +000050 if (m_bInitialized)
51 return MIstatus::success;
Deepak Panickal6f9c4682014-05-16 10:51:01 +000052
Zachary Turner1d6af022014-11-17 18:06:21 +000053 m_bInitialized = MIstatus::success;
54
55 return m_bInitialized;
Deepak Panickal6f9c4682014-05-16 10:51:01 +000056}
57
58//++ ------------------------------------------------------------------------------------
Bruce Mitchenerae4c0262015-07-07 14:04:40 +000059// Details: Release resources for *this broadcaster object.
Zachary Turner1d6af022014-11-17 18:06:21 +000060// Type: Method.
61// Args: None.
62// Return: MIstatus::success - Functionality succeeded.
63// MIstatus::failure - Functionality failed.
64// Throws: None.
Deepak Panickal6f9c4682014-05-16 10:51:01 +000065//--
Zachary Turner1d6af022014-11-17 18:06:21 +000066bool
67CMICmnLLDBBroadcaster::Shutdown(void)
Deepak Panickal6f9c4682014-05-16 10:51:01 +000068{
Zachary Turner1d6af022014-11-17 18:06:21 +000069 if (--m_clientUsageRefCnt > 0)
70 return MIstatus::success;
Deepak Panickal6f9c4682014-05-16 10:51:01 +000071
Zachary Turner1d6af022014-11-17 18:06:21 +000072 if (!m_bInitialized)
73 return MIstatus::success;
Deepak Panickal6f9c4682014-05-16 10:51:01 +000074
Zachary Turner1d6af022014-11-17 18:06:21 +000075 m_bInitialized = false;
Deepak Panickal6f9c4682014-05-16 10:51:01 +000076
Zachary Turner1d6af022014-11-17 18:06:21 +000077 return MIstatus::success;
78}