1 //===-- MICmnLLDBDebugger.h -------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 // File: MICmnLLDBDebugger.h
13 // Overview: CMICmnLLDBDebugger interface.
15 // Environment: Compilers: Visual C++ 12.
16 // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 // Libraries: See MIReadmetxt.
24 // Third party headers
27 #include <lldb/API/SBDebugger.h>
28 #include <lldb/API/SBListener.h>
29 #include <lldb/API/SBEvent.h>
32 #include "MICmnBase.h"
33 #include "MIUtilThreadBaseStd.h"
34 #include "MIUtilSingletonBase.h"
38 class CMICmnLLDBDebuggerHandleEvents;
40 //++ ============================================================================
41 // Details: MI proxy/adapter for the LLDB public SBDebugger API. The CMIDriver
42 // requires *this object. Command classes make calls on *this object
43 // to facilitate their work effort. The instance runs in its own worker
47 // Authors: Illya Rudkin 26/02/2014.
50 class CMICmnLLDBDebugger
52 , public CMIUtilThreadActiveObjBase
53 , public MI::ISingleton< CMICmnLLDBDebugger >
55 friend class MI::ISingleton< CMICmnLLDBDebugger >;
59 bool Initialize( void );
60 bool Shutdown( void );
62 bool SetDriver( const CMIDriverBase & vClientDriver );
63 CMIDriverBase & GetDriver( void ) const;
64 lldb::SBDebugger & GetTheDebugger( void );
65 lldb::SBListener & GetTheListener( void );
67 // MI Commands can use these functions to listen for events they require
68 bool RegisterForEvent( const CMIUtilString & vClientName, const CMIUtilString & vBroadcasterClass, const MIuint vEventMask );
69 bool UnregisterForEvent( const CMIUtilString & vClientName, const CMIUtilString & vBroadcasterClass );
70 bool RegisterForEvent( const CMIUtilString & vClientName, const lldb::SBBroadcaster & vBroadcaster, const MIuint vEventMask );
71 bool UnregisterForEvent( const CMIUtilString & vClientName, const lldb::SBBroadcaster & vBroadcaster );
75 // From CMIUtilThreadActiveObjBase
76 virtual const CMIUtilString & ThreadGetName( void ) const;
80 // From CMIUtilThreadActiveObjBase
81 virtual bool ThreadRun( bool & vrIsAlive );
82 virtual bool ThreadFinish( void );
86 typedef std::map< CMIUtilString, MIuint > MapBroadcastClassNameToEventMask_t;
87 typedef std::pair< CMIUtilString, MIuint > MapPairBroadcastClassNameToEventMask_t;
88 typedef std::map< CMIUtilString, MIuint > MapIdToEventMask_t;
89 typedef std::pair< CMIUtilString, MIuint > MapPairIdToEventMask_t;
93 /* ctor */ CMICmnLLDBDebugger( void );
94 /* ctor */ CMICmnLLDBDebugger( const CMICmnLLDBDebugger & );
95 void operator=( const CMICmnLLDBDebugger & );
97 bool InitSBDebugger( void );
98 bool InitSBListener( void );
99 bool InitStdStreams( void );
100 bool MonitorSBListenerEvents( bool & vrbYesExit );
102 bool BroadcasterGetMask( const CMIUtilString & vBroadcasterClass, MIuint & vEventMask ) const;
103 bool BroadcasterRemoveMask( const CMIUtilString & vBroadcasterClass );
104 bool BroadcasterSaveMask( const CMIUtilString & vBroadcasterClass, const MIuint vEventMask );
106 MIuint ClientGetMaskForAllClients( const CMIUtilString & vBroadcasterClass ) const;
107 bool ClientSaveMask( const CMIUtilString & vClientName, const CMIUtilString & vBroadcasterClass, const MIuint vEventMask );
108 bool ClientRemoveTheirMask( const CMIUtilString & vClientName, const CMIUtilString & vBroadcasterClass );
109 bool ClientGetTheirMask( const CMIUtilString & vClientName, const CMIUtilString & vBroadcasterClass, MIuint & vwEventMask );
114 /* dtor */ virtual ~CMICmnLLDBDebugger( void );
118 CMIDriverBase * m_pClientDriver; // The driver that wants to use *this LLDB debugger
119 lldb::SBDebugger m_lldbDebugger; // SBDebugger is the primordial object that creates SBTargets and provides access to them
120 lldb::SBListener m_lldbListener; // API clients can register its own listener to debugger events
121 const CMIUtilString m_constStrThisThreadId;
122 MapBroadcastClassNameToEventMask_t m_mapBroadcastClassNameToEventMask;
123 MapIdToEventMask_t m_mapIdToEventMask;