NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
debugger.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2016 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19// class: Debugger
20// Kann aktiviert werden, um zusätzliche Informationen aus einem "throw" in einer Prozedur zu ziehen
21
22#ifndef DEBUGGER_HPP
23#define DEBUGGER_HPP
24
25#include <vector>
26#include <string>
27#include <map>
28#include <exception>
29#include "../ui/error.hpp"
30#include "breakpointmanager.hpp"
31#include "../ParserLib/muParserDef.h"
32
33
34// stacktrace
35// line number
36// var vals/names
37// erratic command
38// erratic module
40class Procedure;
41
43{
44 private:
46 std::vector<std::pair<std::string, Procedure*> > vStackTrace;
47 unsigned int nLineNumber;
48 std::string sErraticCommand;
49 std::string sErraticModule;
50 std::string sErrorMessage;
51 std::map<std::string,mu::value_type> mLocalVars;
52 std::map<std::string,std::string> mLocalStrings;
53 std::map<std::string,std::string> mLocalTables;
54 std::map<std::string,std::string> mLocalClusters;
55 std::map<std::string,std::string> mArguments;
59
61
62 int showEvent(const std::string& sTitle);
63 void resetBP();
64 void formatMessage();
65 std::string decodeType(std::string& sArgumentValue, const std::string& sArgumentName = "");
66
67 public:
69
70 void reset();
71 inline void finalize()
72 {
73 bExceptionHandled = false;
74 reset();
75 }
76 inline void finalizeCatched()
77 {
78 bExceptionHandled = false;
79 resetBP();
80 }
81 inline bool validDebuggingInformations() const
82 {
83 return bAlreadyThrown;
84 }
85 inline unsigned int getLineNumber() const
86 {
87 return nLineNumber;
88 }
89 inline std::string getErrorModule() const
90 {
91 return sErraticModule;
92 }
93 inline std::string getErrorMessage() const
94 {
95 return sErrorMessage;
96 }
97 inline size_t getStackSize() const
98 {
99 return vStackTrace.size();
100 }
101 inline bool isActive() const
102 {
103 return bDebuggerActive;
104 }
105 inline void setActive(bool active)
106 {
107 bDebuggerActive = active;
108 }
109
111 {
112 return _breakpointManager;
113 }
114 void showError(const std::string& sTitle);
115 void showError(std::exception_ptr e_ptr);
116 void throwException(SyntaxError error);
117
118 int showBreakPoint();
119
120 bool select(size_t nStackElement);
121
122 void pushStackItem(const std::string& sStackItem, Procedure* _currentProcedure);
123 void popStackItem();
124
125 void gatherInformations(ProcedureVarFactory* _varFactory,
126 const std::string& _sErraticCommand, const std::string& _sErraticModule, unsigned int _nLineNumber);
127
128 void gatherInformations(const std::map<std::string, std::pair<std::string, mu::value_type*>>& _mLocalVars,
129 const std::map<std::string, std::pair<std::string, std::string>>& _mLocalStrings,
130 const std::map<std::string, std::string>& _mLocalTables,
131 const std::map<std::string, std::string>& _mLocalClusters,
132 const std::map<std::string, std::string>& _mArguments,
133 const std::string& _sErraticCommand, const std::string& _sErraticModule, unsigned int _nLineNumber);
134
135 void gatherLoopBasedInformations(const std::string& _sErraticCommand, unsigned int _nLineNumber, std::map<std::string,std::string>& mVarMap, const std::vector<mu::value_type>& vVarArray, const std::vector<std::string>& sVarArray);
136
137 std::vector<std::string> getModuleInformations();
138 std::vector<std::string> getStackTrace();
139 std::vector<std::string> getNumVars();
140 std::vector<std::string> getStringVars();
141 std::vector<std::string> getTables();
142 std::vector<std::string> getClusters();
143 std::vector<std::string> getArguments();
144 std::vector<std::string> getGlobals();
145};
146
147
148#endif // DEBUGGER_HPP
149
std::vector< std::string > getNumVars()
This member function returns the numerical variables as a vector.
Definition: debugger.cpp:812
unsigned int nLineNumber
Definition: debugger.hpp:47
void throwException(SyntaxError error)
This member function shows the debugger with the corresponding error message obtained by the passed S...
Definition: debugger.cpp:120
void finalize()
Definition: debugger.hpp:71
void formatMessage()
This function replaces unmasked dollars with regular line break characters and also removes the maski...
Definition: debugger.cpp:210
void gatherInformations(ProcedureVarFactory *_varFactory, const std::string &_sErraticCommand, const std::string &_sErraticModule, unsigned int _nLineNumber)
This member function gathers all information from the current workspace and stores them internally to...
Definition: debugger.cpp:516
int showBreakPoint()
This member function shows the debugger for the current breakpoint and returns the debugger code (i....
Definition: debugger.cpp:158
bool bExceptionHandled
Definition: debugger.hpp:57
BreakpointManager _breakpointManager
Definition: debugger.hpp:45
void finalizeCatched()
Definition: debugger.hpp:76
std::string sErrorMessage
Definition: debugger.hpp:50
bool isActive() const
Definition: debugger.hpp:101
void showError(std::exception_ptr e_ptr)
void reset()
This member function resets the debugger after a thrown and displayed error.
Definition: debugger.cpp:414
bool bAlreadyThrown
Definition: debugger.hpp:56
bool bDebuggerActive
Definition: debugger.hpp:60
std::string getErrorMessage() const
Definition: debugger.hpp:93
std::vector< std::string > getClusters()
This member function returns the clusters as a vector.
Definition: debugger.cpp:884
std::map< std::string, mu::value_type > mLocalVars
Definition: debugger.hpp:51
std::vector< std::string > getGlobals()
This member function returns the current global variables as a vector.
Definition: debugger.cpp:925
void gatherLoopBasedInformations(const std::string &_sErraticCommand, unsigned int _nLineNumber, std::map< std::string, std::string > &mVarMap, const std::vector< mu::value_type > &vVarArray, const std::vector< std::string > &sVarArray)
This member funciton gathers the necessary debugging informations from the current executed control f...
Definition: debugger.cpp:701
std::map< std::string, std::string > mArguments
Definition: debugger.hpp:55
std::map< std::string, std::string > mLocalClusters
Definition: debugger.hpp:54
std::vector< std::pair< std::string, Procedure * > > vStackTrace
Definition: debugger.hpp:46
std::string sErraticModule
Definition: debugger.hpp:49
void resetBP()
This member function resets the debugger after an evaluated breakpoint. This excludes resetting the s...
Definition: debugger.cpp:431
std::string getErrorModule() const
Definition: debugger.hpp:89
bool validDebuggingInformations() const
Definition: debugger.hpp:81
std::vector< std::string > getStringVars()
This member function returns the string variables as a vector.
Definition: debugger.cpp:841
size_t nCurrentStackElement
Definition: debugger.hpp:58
std::vector< std::string > getTables()
This member function returns the tables as a vector.
Definition: debugger.cpp:864
std::map< std::string, std::string > mLocalTables
Definition: debugger.hpp:53
size_t getStackSize() const
Definition: debugger.hpp:97
int showEvent(const std::string &sTitle)
This private member function shows the debugger for the current selected event and returns the debugg...
Definition: debugger.cpp:178
std::vector< std::string > getStackTrace()
This member function returns the stack trace as a vector.
Definition: debugger.cpp:781
bool select(size_t nStackElement)
This member function can be used to select a specific element in the current stack trace to read the ...
Definition: debugger.cpp:370
std::string decodeType(std::string &sArgumentValue, const std::string &sArgumentName="")
This private member function decodes the type of the arguments by looking at their values and apply s...
Definition: debugger.cpp:235
unsigned int getLineNumber() const
Definition: debugger.hpp:85
std::map< std::string, std::string > mLocalStrings
Definition: debugger.hpp:52
void popStackItem()
This member function removes the last item from the stack.
Definition: debugger.cpp:489
std::vector< std::string > getModuleInformations()
This member function returns the module informations as a vector.
Definition: debugger.cpp:763
std::string sErraticCommand
Definition: debugger.hpp:48
void showError(const std::string &sTitle)
This member function shows the debugger with the passed error message.
Definition: debugger.cpp:96
std::vector< std::string > getArguments()
This member function returns the procedure argument as a vector.
Definition: debugger.cpp:904
void setActive(bool active)
Definition: debugger.hpp:105
BreakpointManager & getBreakpointManager()
Definition: debugger.hpp:110
void pushStackItem(const std::string &sStackItem, Procedure *_currentProcedure)
This member function adds a new stack item to the monitored stack. Additionally, it cleanes the proce...
Definition: debugger.cpp:457
NumeReDebugger()
Constructor.
Definition: debugger.cpp:36
void gatherInformations(const std::map< std::string, std::pair< std::string, mu::value_type * > > &_mLocalVars, const std::map< std::string, std::pair< std::string, std::string > > &_mLocalStrings, const std::map< std::string, std::string > &_mLocalTables, const std::map< std::string, std::string > &_mLocalClusters, const std::map< std::string, std::string > &_mArguments, const std::string &_sErraticCommand, const std::string &_sErraticModule, unsigned int _nLineNumber)
This class implements the logic to evaluate complex procedures, which may be called recursively.
Definition: procedure.hpp:56
This class is the variable factory used by procedure instances to create their local variables and re...
Common exception class for all exceptions thrown in NumeRe.
Definition: error.hpp:32