ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

debugger.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GUI_DEBUGGER_H
00024 #define GUI_DEBUGGER_H
00025 
00026 #include "common/func.h"
00027 #include "common/ptr.h"
00028 #include "common/hashmap.h"
00029 #include "common/hash-str.h"
00030 #include "common/array.h"
00031 #include "common/str.h"
00032 #include "common/str-array.h"
00033 
00034 #include "engines/engine.h"
00035 
00036 namespace GUI {
00037 
00038 #ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER
00039 class ConsoleDialog;
00040 #endif
00041 
00042 class Debugger {
00043 public:
00044     Debugger();
00045     virtual ~Debugger();
00046 
00047     int getCharsPerLine();
00048 
00049     int debugPrintf(const char *format, ...) GCC_PRINTF(2, 3);
00050 
00051     void debugPrintColumns(const Common::StringArray &list);
00052 
00064     virtual void onFrame();
00065 
00070     virtual void attach(const char *entry = nullptr);
00071 
00076     bool isActive() const { return _isActive; }
00077 
00078 protected:
00079     typedef Common::Functor2<int, const char **, bool> Debuglet;
00080 
00089     #define WRAP_METHOD(cls, method) \
00090         new Common::Functor2Mem<int, const char **, bool, cls>(this, &cls::method)
00091 
00092     enum VarType {
00093         DVAR_BYTE,
00094         DVAR_INT,
00095         DVAR_BOOL,
00096         DVAR_INTARRAY,
00097         DVAR_STRING
00098     };
00099 
00100     struct Var {
00101         Common::String name;
00102         void *variable;
00103         VarType type;
00104         int arraySize;
00105     };
00106 
00107 private:
00116     void registerVar(const Common::String &varname, void *variable, VarType type, int arraySize);
00117 
00118 protected:
00119     void registerVar(const Common::String &varname, byte *variable) {
00120         registerVar(varname, variable, DVAR_BYTE, 0);
00121     }
00122 
00123     void registerVar(const Common::String &varname, int *variable) {
00124         registerVar(varname, variable, DVAR_INT, 0);
00125     }
00126 
00127     void registerVar(const Common::String &varname, bool *variable) {
00128         registerVar(varname, variable, DVAR_BOOL, 0);
00129     }
00130 
00131     void registerVar(const Common::String &varname, int32 **variable, int arraySize) {
00132         registerVar(varname, variable, DVAR_INTARRAY, arraySize);
00133     }
00134 
00135     void registerVar(const Common::String &varname, Common::String *variable) {
00136         registerVar(varname, variable, DVAR_STRING, 0);
00137     }
00138 
00139     void registerCmd(const Common::String &cmdname, Debuglet *debuglet);
00140 
00141 
00142 private:
00154     uint _frameCountdown;
00155 
00156     Common::Array<Var> _vars;
00157 
00158     typedef Common::HashMap<Common::String, Common::SharedPtr<Debuglet>, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> CommandsMap;
00159     CommandsMap _cmds;
00160 
00165     bool _isActive;
00166 
00167     Common::String _errStr;
00168 
00175     bool _firstTime;
00176 
00177 protected:
00178     PauseToken _debugPauseToken;
00179 
00180 #ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER
00181     GUI::ConsoleDialog *_debuggerDialog;
00182 #endif
00183 
00184 protected:
00191     virtual void preEnter();
00192 
00199     virtual void postEnter();
00200 
00206     virtual bool handleCommand(int argc, const char **argv, bool &keepRunning);
00207 
00215     void detach();
00216 
00217 private:
00218     void enter();
00219 
00224     void splitCommand(Common::String &input, int &argc, const char **argv);
00225 
00226     bool parseCommand(const char *input);
00227     bool tabComplete(const char *input, Common::String &completion) const;
00228 
00229 protected:
00230     bool cmdExit(int argc, const char **argv);
00231     bool cmdHelp(int argc, const char **argv);
00232     bool cmdOpenLog(int argc, const char **argv);
00233 #ifndef DISABLE_MD5
00234     bool cmdMd5(int argc, const char **argv);
00235     bool cmdMd5Mac(int argc, const char **argv);
00236 #endif
00237     bool cmdDebugLevel(int argc, const char **argv);
00238     bool cmdDebugFlagsList(int argc, const char **argv);
00239     bool cmdDebugFlagEnable(int argc, const char **argv);
00240     bool cmdDebugFlagDisable(int argc, const char **argv);
00241 
00242 #ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER
00243 private:
00244     static bool debuggerInputCallback(GUI::ConsoleDialog *console, const char *input, void *refCon);
00245     static bool debuggerCompletionCallback(GUI::ConsoleDialog *console, const char *input, Common::String &completion, void *refCon);
00246 #elif defined(USE_READLINE)
00247 public:
00248     char *readlineComplete(const char *input, int state);
00249 #endif
00250 
00251 };
00252 
00253 } // End of namespace GUI
00254 
00255 #endif


Generated on Sat Aug 8 2020 05:01:10 for ResidualVM by doxygen 1.7.1
curved edge   curved edge