DebugDataManager.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_DEBUGDATAMANAGER_H_
40 #define CORE_DEBUGGER_DEBUGDATAMANAGER_H_
41 
42 #include <mutex>
43 #include <string>
44 #include <vector>
45 #include <iostream>
46 #include <map>
47 #include <tuple>
48 
49 #include "Breakpoint.h"
50 #include "Watchpoint.h"
51 #include "DebuggerPacket.h"
52 
53 namespace pfp {
54 namespace core {
55 namespace db {
56 
61  public:
66 
71  void addCounter(std::string name);
72 
77  void removeCounter(std::string name);
78 
84  void updateCounter(std::string name, int val);
85 
90  void addBreakpoint(Breakpoint br);
91 
96  void removeBreakpoint(int identifier);
97 
102  void enableBreakpoint(int id);
103 
108  void disableBreakpoint(int id);
109 
117  void updatePacket(int id, std::string module, double time_, bool read);
118 
123  void removePacket(int id);
124 
129  void addWatchpoint(Watchpoint wp);
130 
135  void removeWatchpoint(int id);
136 
141  void enableWatchpoint(int id);
142 
147  void disableWatchpoint(int id);
148 
153  int whoami();
154 
159  void set_whoami(int id);
160 
166  void addIgnoreModule(std::string mod);
167 
173  bool checkIgnoreModules(std::string mod);
174 
179  void removeIgnoreModule(std::string mod);
180 
187  void addDroppedPacket(int id, std::string module, std::string reason);
188 
193  void setBreakOnPacketDrop(bool b);
194 
199  bool getBreakOnPacketDrop();
200 
206  int getCounterValue(std::string name);
207 
212  std::map<std::string, int> getCounters();
213 
219  Breakpoint getBreakpoint(int index);
220 
225  std::vector<Breakpoint>& getBreakpointList();
226 
232 
237  double getSimulationTime();
238 
244  DebuggerPacket* getPacket(int id);
245 
250  std::map<int, DebuggerPacket>& getPacketList();
251 
256  std::vector<Watchpoint>& getWatchpointList();
257 
262  std::vector<std::string>& getIgnoreModuleList();
263 
268  std::vector<std::tuple<int, std::string,
269  std::string>>& getDroppedPacketList();
270 
275  void setSimulationTime(double time_ns);
276 
277  private:
279  std::map<std::string, int> counters;
282  std::mutex mutex_;
284  std::map<int, DebuggerPacket> packet_list;
286  std::vector<Breakpoint> breakpoint_list;
288  double simulation_time;
290  int current_packet_id;
292  std::vector<Watchpoint> watchpoint_list;
294  int next_watchpoint_id;
296  std::vector<std::string> ignore_module_list;
298  std::vector<std::tuple<int, std::string, std::string>> dropped_packet_list;
301  bool break_packet_dropped;
302 };
303 
304 }; // namespace db
305 }; // namespace core
306 }; // namespace pfp
307 
308 #endif // CORE_DEBUGGER_DEBUGDATAMANAGER_H_
int getCounterValue(std::string name)
Get the value of a counter.
Definition: DebugDataManager.cpp:69
void enableBreakpoint(int id)
Enable a Breakpoint.
Definition: DebugDataManager.cpp:106
Class representation of a packet for pfpdb.
Definition: DebuggerPacket.h:52
void updatePacket(int id, std::string module, double time_, bool read)
Add a new packet or update an existing one.
Definition: DebugDataManager.cpp:128
void addDroppedPacket(int id, std::string module, std::string reason)
Add a packet to the list of dropped packets.
Definition: DebugDataManager.cpp:233
double getSimulationTime()
Get current simulation time.
Definition: DebugDataManager.cpp:265
void setSimulationTime(double time_ns)
Set the current simulation time.
Definition: DebugDataManager.cpp:300
std::vector< std::tuple< int, std::string, std::string > > & getDroppedPacketList()
Get vector of tuple representing a dropped packet.
Definition: DebugDataManager.cpp:295
std::vector< std::string > & getIgnoreModuleList()
Get list of modules that are being ignored.
Definition: DebugDataManager.cpp:289
void addWatchpoint(Watchpoint wp)
Add a Watchpoint.
Definition: DebugDataManager.cpp:151
std::vector< Breakpoint > & getBreakpointList()
Get list of Breakpoints.
Definition: DebugDataManager.cpp:255
DebugDataManager()
Default Constructor.
Definition: DebugDataManager.cpp:42
Class representation of a pfpdb breakpoint.
Definition: Breakpoint.h:53
void removeWatchpoint(int id)
Remove a Watchpoint.
Definition: DebugDataManager.cpp:161
void removeCounter(std::string name)
Remove a counter.
Definition: DebugDataManager.cpp:53
void disableBreakpoint(int id)
Disable a Breakpoint.
Definition: DebugDataManager.cpp:117
DebuggerPacket * getPacket(int id)
Get DebuggerPacket with given ID>
Definition: DebugDataManager.cpp:270
std::vector< Watchpoint > & getWatchpointList()
Get list of Watchpoints.
Definition: DebugDataManager.cpp:284
void addBreakpoint(Breakpoint br)
Add a Breakpoint.
Definition: DebugDataManager.cpp:84
Breakpoint getBreakpoint(int index)
Get Breakpoint at given index from list of Breakpoints.
Definition: DebugDataManager.cpp:250
void disableWatchpoint(int id)
Disable a Watchpoint.
Definition: DebugDataManager.cpp:181
Defines a class representation of a breakpoint.
void setBreakOnPacketDrop(bool b)
Set whether the debugger should break when a packet is dropped.
Definition: DebugDataManager.cpp:240
int whoami()
Get the ID of the packet that is the debugger is currently following or focusing on.
Definition: DebugDataManager.cpp:191
bool checkIgnoreModules(std::string mod)
Check if the given module is being ignored.
Definition: DebugDataManager.cpp:211
std::map< int, DebuggerPacket > & getPacketList()
Get the map containing the DebuggerPacket as the key and the DebuggerPacket object as the value...
Definition: DebugDataManager.cpp:279
int getNumberOfBreakpoints()
Get number of Breakpoints in list.
Definition: DebugDataManager.cpp:260
void enableWatchpoint(int id)
Enable a Watchpoint.
Definition: DebugDataManager.cpp:171
void removeIgnoreModule(std::string mod)
Remove a module from the list of ignored modules.
Definition: DebugDataManager.cpp:222
void set_whoami(int id)
Set which packet is currently be followed or focused on.
Definition: DebugDataManager.cpp:195
Stores any data acquired from the simulation from the observer so that it may be fetched by the serve...
Definition: DebugDataManager.h:60
Defines a class representation of a watchpoint for the debugger.
Class representation of watchpoints.
Definition: Watchpoint.h:53
Defines a class representation of a packet in the debugger context.
void addIgnoreModule(std::string mod)
Add a module to ignore.
Definition: DebugDataManager.cpp:200
void removeBreakpoint(int identifier)
Remove a Breakpoint.
Definition: DebugDataManager.cpp:95
std::map< std::string, int > getCounters()
Get map of counters and their values.
Definition: DebugDataManager.cpp:79
void updateCounter(std::string name, int val)
Update the value of a counter.
Definition: DebugDataManager.cpp:58
bool getBreakOnPacketDrop()
Check if the debugger is currently set to break when a packet is dropped.
Definition: DebugDataManager.cpp:245
void addCounter(std::string name)
Add a counter.
Definition: DebugDataManager.cpp:48
void removePacket(int id)
Remove a packet.
Definition: DebugDataManager.cpp:146
PacketBase.h.
Definition: ConfigurationParameters.cpp:36