1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef WINTERMUTE_DEBUGGER_ADAPTER_H 24 #define WINTERMUTE_DEBUGGER_ADAPTER_H 25 26 #include "common/str.h" 27 #include "engines/wintermute/coll_templ.h" 28 #include "engines/wintermute/wintermute.h" 29 #include "engines/wintermute/debugger/listing_providers/source_listing_provider.h" 30 #include "script_monitor.h" 31 #include "error.h" 32 #include "listing.h" 33 namespace Wintermute { 34 35 class ScScript; 36 class DebuggableScript; 37 class ScValue; 38 39 struct BreakpointInfo { 40 Common::String _filename; 41 int _line; 42 int _hits; 43 bool _enabled; 44 }; 45 46 struct WatchInfo { 47 Common::String _filename; 48 Common::String _symbol; 49 int _hits; 50 bool _enabled; 51 }; 52 53 struct TopEntry { 54 bool current; 55 Common::String filename; 56 int watches; 57 int breakpointInfo; 58 }; 59 60 class DebuggerController : public ScriptMonitor { 61 SourceListingProvider *_sourceListingProvider; 62 const WintermuteEngine *_engine; 63 DebuggableScript *_lastScript; 64 uint32 _lastLine; 65 void clear(); 66 bool bytecodeExists(const Common::String &filename); 67 public: 68 DebuggerController(WintermuteEngine *vm); 69 ~DebuggerController(); 70 Common::Array<TopEntry> getTop() const; 71 /** 72 * Get the last line # we've stopped at 73 */ 74 uint32 getLastLine() const; 75 Error addBreakpoint(const char *filename, int line); 76 Error removeBreakpoint(uint id); 77 Error disableBreakpoint(uint id); 78 Error enableBreakpoint(uint id); 79 Error addWatch(const char *filename, const char *symbol); 80 Error removeWatchpoint(uint id); 81 Error disableWatchpoint(uint id); 82 Error enableWatchpoint(uint id); 83 Common::Array<BreakpointInfo> getBreakpoints() const; 84 Common::Array<WatchInfo> getWatchlist() const; 85 /** 86 * @brief step one instruction 87 */ 88 Error step(); 89 /** 90 * @brief continue execution and don't step until next breakpoint 91 */ 92 Error stepContinue(); 93 /** 94 * @brief continue execution and don't step until the current activation record is popped 95 */ 96 Error stepFinish(); 97 /** 98 * @brief read value for a variable accessible from within the current scope. 99 */ 100 Common::String readValue(const Common::String &name, Error *error); 101 /** 102 * @brief set value for a variable accessible from within the current scope. 103 */ 104 Error setValue(const Common::String &name, const Common::String &value, ScValue*&var); 105 Error setSourcePath(const Common::String &sourcePath); 106 Common::String getSourcePath() const; 107 Listing *getListing(Error* &err); 108 void showFps(bool show); 109 /** 110 * Inherited from ScriptMonitor 111 */ 112 void onBreakpoint(const Breakpoint *breakpoint, DebuggableScript *script); 113 void onWatch(const Watch *watch, DebuggableScript *script); 114 void notifyStep(DebuggableScript *script) override; 115 }; 116 } 117 118 #endif // WINTERMUTE_DEBUGGER_H 119