# Hurricane VLSI Database

DebugSession.h
1 // -*- C++ -*-
2 //
3 // Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
4 //
5 // This file is part of Hurricane.
6 //
7 // Hurricane is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
11 //
12 // Hurricane is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
14 // TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the Lesser GNU General Public
18 // License along with Hurricane. If not, see
19 // <http://www.gnu.org/licenses/>.
20 //
21 // +-----------------------------------------------------------------+
22 // | H U R R I C A N E |
23 // | V L S I B a c k e n d D a t a - B a s e |
24 // | |
25 // | Author : Jean-Paul Chaput |
26 // | E-mail : Jean-Paul.Chaput@lip6.fr |
27 // | =============================================================== |
28 // | C++ Header : "./hurricane/DebugSession.h" |
29 // +-----------------------------------------------------------------+
30
31
32 #ifndef HURRICANE_DEBUG_SESSION_H
33 #define HURRICANE_DEBUG_SESSION_H
34
35 #include <set>
36 #include <stack>
37 #include "hurricane/Commons.h"
38
39
40 namespace Hurricane {
41
42 class Name;
43 class Net;
44 class Cell;
45
46 using std::pair;
47 using std::make_pair;
48 using std::set;
49 using std::stack;
50
51
52 // -------------------------------------------------------------------
53 // Class : "Hurricane::DebugSession".
54
55 class DebugSession {
56
57 public:
58 // Static Access.
59 static DebugSession* create ();
60 static inline DebugSession* get ();
61 static inline bool isTraced ( const void* symbol );
62 static inline void isTracedNet ( const Net* );
63 static inline void addToTrace ( const void* symbol );
64 static inline void addToTrace ( const Cell*, const Name& );
65 static inline void addToTrace ( const Net* );
66 static inline void open ( int minLevel, int maxLevel );
67 static inline void open ( const void* symbol, int minLevel, int maxLevel );
68 static inline void close ();
69 // Singleton Access.
70 inline bool _isTraced ( const void* symbol ) const;
71 inline void _addToTrace ( const void* symbol );
72 void _addToTrace ( const Cell*, const Name& );
73 inline void _addToTrace ( const Net* net );
74 // Inspector Management.
75 Record* _getRecord () const;
76 string _getString () const;
77 string _getTypeName () const;
78
79 protected:
80 // Internal: Attributes.
81 static DebugSession* _singleton;
82 set<const void*> _symbols;
83 stack< pair<int,int> > _levels;
84
85 protected:
86 // Internal: Constructor & Destructor.
87 DebugSession ();
88 ~DebugSession ();
89 private:
90 DebugSession ( const DebugSession& );
91 DebugSession& operator= ( const DebugSession& );
92 };
93
94
95 // Inline Functions.
96
97 void DebugSession::open ( int minLevel, int maxLevel )
98 {
99 if (cdebug.getMinLevel() < minLevel) minLevel = cdebug.getMinLevel();
100 if (cdebug.getMaxLevel() > maxLevel) maxLevel = cdebug.getMaxLevel();
101
102 _singleton->_levels.push( make_pair( cdebug.setMinLevel(minLevel)
103 , cdebug.setMaxLevel(maxLevel) ) );
104
105 //std::cerr << "DebugSession::open() " << minLevel << ":" << maxLevel << std::endl;
106 }
107
108
109 void DebugSession::open ( const void* symbol, int minLevel, int maxLevel )
110 {
111 if (cdebug.getMinLevel() < minLevel) minLevel = cdebug.getMinLevel();
112 if (cdebug.getMaxLevel() > maxLevel) maxLevel = cdebug.getMaxLevel();
113
114 if ( _singleton->_isTraced(symbol) ) {
115 _singleton->_levels.push( make_pair( cdebug.setMinLevel(minLevel)
116 , cdebug.setMaxLevel(maxLevel) ) );
117
118 //std::cerr << "DebugSession::open() " << symbol << " " << minLevel << ":" << maxLevel << std::endl;
119 } else {
120 _singleton->_levels.push ( make_pair( cdebug.getMinLevel()
121 , cdebug.getMaxLevel() ) );
122
123 //std::cerr << "DebugSession::open() Same level " << minLevel << ":" << maxLevel << std::endl;
124 }
125 }
126
127
128 void DebugSession::close ()
129 {
130 if ( not _singleton->_levels.empty() ) {
131 cdebug.setMinLevel( _singleton->_levels.top().first );
132 cdebug.setMaxLevel( _singleton->_levels.top().second );
133 _singleton->_levels.pop ();
134
135 //std::cerr << "DebugSession::close() " << cdebug.getMinLevel() << ":" << cdebug.getMaxLevel() << std::endl;
136 }
137 }
138
139
140 DebugSession* DebugSession::get () { return _singleton; }
141 bool DebugSession::isTraced ( const void* symbol ) { return _singleton->_isTraced(symbol); }
142 void DebugSession::addToTrace ( const void* symbol ) { _singleton->_addToTrace(symbol); }
143 void DebugSession::addToTrace ( const Net* net ) { _singleton->_addToTrace(net); }
144 void DebugSession::addToTrace ( const Cell* cell
145 , const Name& name ) { _singleton->_addToTrace( cell, name ); }
146 bool DebugSession::_isTraced ( const void* symbol ) const { return _symbols.find(symbol) != _symbols.end(); }
147 void DebugSession::_addToTrace ( const void* symbol ) { _symbols.insert( symbol ); }
148 void DebugSession::_addToTrace ( const Net* net ) { _addToTrace( static_cast<const void*>(net) ); }
149
150
151
152 } // Hurricane namespace.
153
154
155 INSPECTOR_P_SUPPORT(Hurricane::DebugSession);
156
157
158 #endif // HURRICANE_DEBUG_SESSION_H
Hurricane::DebugSession::addToTrace
static void addToTrace(const void *symbol)
Definition: DebugSession.h:142
Hurricane::Name
Name description (API)
Definition: Name.h:35
tstream::setMaxLevel
int setMaxLevel(int)
Definition: Commons.h:1044
Hurricane::Cell
The model (API).
Definition: Cell.h:66
Hurricane::DebugSession::close
static void close()
Definition: DebugSession.h:128
tstream::setMinLevel
int setMinLevel(int)
Definition: Commons.h:1043
tstream::getMinLevel
int getMinLevel() const
Definition: Commons.h:1041
Hurricane::DebugSession
Enable/Disable trace information (API).
Definition: DebugSession.h:55
Hurricane
The namespace dedicated to Hurricane.
Definition: Generalities.dox:5
Hurricane::DebugSession::isTraced
static bool isTraced(const void *symbol)
Definition: DebugSession.h:141
Hurricane::Net
Net description (API)
Definition: Net.h:48
tstream::getMaxLevel
int getMaxLevel() const
Definition: Commons.h:1042
Hurricane::DebugSession::open
static void open(int minLevel, int maxLevel)
Definition: DebugSession.h:97

Generated by doxygen 1.8.14 on Tue Jul 21 2020 | Return to top of page

Hurricane VLSI Database | Copyright © 2000-2016 Bull S.A. All rights reserved