DebugObserver.h
Go to the documentation of this file.
1 /*
2  * PFPSim: Library for the Programmable Forwarding Plane Simulation Framework
3  *
4  * Copyright (C) 2016 Concordia Univ., Montreal
5  * Samar Abdi
6  * Umair Aftab
7  * Gordon Bailey
8  * Faras Dewal
9  * Shafigh Parsazad
10  * Eric Tremblay
11  *
12  * Copyright (C) 2016 Ericsson
13  * Bochra Boughzala
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28  * 02110-1301, USA.
29  */
30 
39 #ifndef CORE_DEBUGGER_DEBUGOBSERVER_H_
40 #define CORE_DEBUGGER_DEBUGOBSERVER_H_
41 
42 #include <string>
43 #include <map>
44 #include "../TrType.h"
45 #include "../PFPObserver.h"
46 #include "DebuggerIPCServer.h"
47 #include "DebugDataManager.h"
48 #include "DebuggerPacket.h"
49 
50 #define VERBOSE 0
51 
52 namespace pfp {
53 namespace core {
54 namespace db {
55 
62 class DebugObserver : public PFPObserver {
63  public:
67  DebugObserver();
68 
73 
80  virtual void counter_added(const std::string& module_name,
81  const std::string& counter_name, double simulation_time = 0);
82 
89  virtual void counter_removed(const std::string& module_name,
90  const std::string& counter_name, double simulation_time = 0);
91 
99  virtual void counter_updated(const std::string& module_name,
100  const std::string& counter_name,
101  std::size_t new_value,
102  double simulation_time);
103 
110  void data_written(const std::string& from_module,
111  const std::shared_ptr<TrType> data,
112  double simulation_time) override;
113 
120  void data_read(const std::string& to_module,
121  const std::shared_ptr<TrType> data,
122  double simulation_time) override;
123 
130  void data_dropped(const std::string& in_module,
131  const std::shared_ptr<TrType> data,
132  const std::string& drop_reason,
133  double simulation_time) override;
134 
142  virtual void thread_begin(const std::string& teu_mod,
143  const std::string& tec_mod, std::size_t thread_id,
144  std::size_t packet_id, double simulation_time);
145 
153  virtual void thread_end(const std::string& teu_mod,
154  const std::string& tec_mod, std::size_t thread_id,
155  std::size_t packet_id, double simulation_time);
156 
164  virtual void thread_idle(const std::string& teu_mod,
165  const std::string& tec_mod, std::size_t thread_id,
166  std::size_t packet_id, double simulation_time);
167 
168  virtual void core_busy(const std::string& teu_mod,
169  const std::string& tec_mod, double simulation_time);
170  virtual void core_idle(const std::string& teu_mod,
171  const std::string& tec_mod, double simulation_time);
172 
176  void waitForRunCommand();
177 
183  void registerCP(CPDebuggerInterface *cp_debug_if);
184 
188  void enableDebugger();
189 
190  private:
191  DebuggerIPCServer *ipc_server;
192  DebugDataManager *data_manager;
193  bool enable = false;
198  void pause();
199 
203  void notifyServer();
204 
209  void updateSimulationTime(double sim_time);
210 
215  void updateWhoAmI(int packet_id);
216 
224  void updatePacketList(int id, std::string loc, double t);
225 
233  void checkBreakpointHit(std::string module, int packet_id,
234  double sim_time, bool read);
235 };
236 
237 }; // namespace db
238 }; // namespace core
239 }; // namespace pfp
240 
241 #endif // CORE_DEBUGGER_DEBUGOBSERVER_H_
virtual void thread_idle(const std::string &teu_mod, const std::string &tec_mod, std::size_t thread_id, std::size_t packet_id, double simulation_time)
Function called by the simulation when a TEU thread starts idling.
Definition: DebugObserver.cpp:203
DebugObserver()
Default Constructor.
Definition: DebugObserver.cpp:43
void enableDebugger()
Enables the debugger.
Definition: DebugObserver.cpp:224
void waitForRunCommand()
Called after SystemC elaboration to halt the simulation until the run command is sent.
Definition: DebugObserver.cpp:63
void data_dropped(const std::string &in_module, const std::shared_ptr< TrType > data, const std::string &drop_reason, double simulation_time) override
Function called by the simulation when data is dropped in a module.
Definition: DebugObserver.cpp:157
void data_written(const std::string &from_module, const std::shared_ptr< TrType > data, double simulation_time) override
Function called by the simulation when data is written by a module.
Definition: DebugObserver.cpp:117
Interface for Control Plane module that is necessary for it to work with pfpdb.
Definition: CPDebuggerInterface.h:57
~DebugObserver()
Destructor.
Definition: DebugObserver.cpp:53
Definition: PFPObserver.h:51
virtual void counter_added(const std::string &module_name, const std::string &counter_name, double simulation_time=0)
Function called by the simulation when a counter is added to a module.
Definition: DebugObserver.cpp:67
virtual void counter_removed(const std::string &module_name, const std::string &counter_name, double simulation_time=0)
Function called by the simulation when a counter is removed from a module.
Definition: DebugObserver.cpp:78
virtual void thread_end(const std::string &teu_mod, const std::string &tec_mod, std::size_t thread_id, std::size_t packet_id, double simulation_time)
Function called by the simulation when a TEU thread ends.
Definition: DebugObserver.cpp:192
Stores any data acquired from the simulation from the observer so that it may be fetched by the serve...
Definition: DebugDataManager.h:60
void registerCP(CPDebuggerInterface *cp_debug_if)
Register a Control Plane (which implements CPDebuggerInterface) to the debugger.
Definition: DebugObserver.cpp:324
void data_read(const std::string &to_module, const std::shared_ptr< TrType > data, double simulation_time) override
Function called by the simulation when data is read by a module.
Definition: DebugObserver.cpp:136
virtual void thread_begin(const std::string &teu_mod, const std::string &tec_mod, std::size_t thread_id, std::size_t packet_id, double simulation_time)
Function called by the simulation when a TEU thread begins.
Definition: DebugObserver.cpp:181
Defines a class representation of a packet in the debugger context.
Establishes communication with pfpdb python script and services its requests.
Definition: DebuggerIPCServer.h:61
Observer for pfpdb.
Definition: DebugObserver.h:62
virtual void counter_updated(const std::string &module_name, const std::string &counter_name, std::size_t new_value, double simulation_time)
Function called by the simulation when a counter is updated.
Definition: DebugObserver.cpp:89
Defines class which stores any data about taht simulation that is required by pfpdb.
Defines class that services requests from pfpdb.
PacketBase.h.
Definition: ConfigurationParameters.cpp:36