]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmnLLDBDebugger.h
Merge OpenSSL 1.0.1k.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / tools / lldb-mi / MICmnLLDBDebugger.h
1 //===-- MICmnLLDBDebugger.h -------------------------------------*- 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:                MICmnLLDBDebugger.h
12 //
13 // Overview:    CMICmnLLDBDebugger interface.
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 #pragma once
23
24 // Third party headers
25 #include <queue>
26 #include <map>
27 #include <lldb/API/SBDebugger.h>
28 #include <lldb/API/SBListener.h>
29 #include <lldb/API/SBEvent.h>
30
31 // In-house headers:
32 #include "MICmnBase.h"
33 #include "MIUtilThreadBaseStd.h"
34 #include "MIUtilSingletonBase.h"
35
36 // Declarations:
37 class CMIDriverBase;
38 class CMICmnLLDBDebuggerHandleEvents;
39
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
44 //                      thread.
45 //                      A singleton class.
46 // Gotchas:     None.
47 // Authors:     Illya Rudkin 26/02/2014.
48 // Changes:     None.
49 //--
50 class CMICmnLLDBDebugger
51 :       public CMICmnBase
52 ,       public CMIUtilThreadActiveObjBase
53 ,       public MI::ISingleton< CMICmnLLDBDebugger >
54 {
55         friend class MI::ISingleton< CMICmnLLDBDebugger >;
56         
57 // Methods:
58 public:
59         bool    Initialize( void );
60         bool    Shutdown( void );
61         
62         bool                            SetDriver( const CMIDriverBase & vClientDriver );
63         CMIDriverBase &         GetDriver( void ) const;
64         lldb::SBDebugger &      GetTheDebugger( void );
65         lldb::SBListener &      GetTheListener( void );
66         
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 );                                                 
72         
73 // Overridden:
74 public:
75         // From CMIUtilThreadActiveObjBase
76         virtual const CMIUtilString & ThreadGetName( void ) const;
77
78 // Overridden:
79 protected:
80         // From CMIUtilThreadActiveObjBase
81         virtual bool ThreadRun( bool & vrIsAlive );
82         virtual bool ThreadFinish( void );
83         
84 // Typedefs:
85 private:
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;
90
91 // Methods:
92 private:
93         /* ctor */      CMICmnLLDBDebugger( void );
94         /* ctor */      CMICmnLLDBDebugger( const CMICmnLLDBDebugger & );
95         void            operator=( const CMICmnLLDBDebugger & );
96         
97         bool InitSBDebugger( void );
98         bool InitSBListener( void );
99         bool InitStdStreams( void );
100         bool MonitorSBListenerEvents( bool & vrbYesExit );
101         
102         bool BroadcasterGetMask( const CMIUtilString & vBroadcasterClass, MIuint & vEventMask ) const;
103         bool BroadcasterRemoveMask( const CMIUtilString & vBroadcasterClass );
104         bool BroadcasterSaveMask( const CMIUtilString & vBroadcasterClass, const MIuint vEventMask );
105         
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 );
110
111 // Overridden:
112 private:
113         // From CMICmnBase
114         /* dtor */ virtual ~CMICmnLLDBDebugger( void );
115
116 // Attributes:
117 private:
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;
124 };
125