• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

debugger.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00003 //   Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 
00020 #ifndef __DEBUGGER_H__
00021 #define __DEBUGGER_H__
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include "gnashconfig.h"
00025 #endif
00026 
00027 #ifdef USE_DEBUGGER
00028 
00029 #include <string>
00030 #include <map>
00031 
00032 #include "dsodefs.h"
00033 #include "as_environment.h"
00034 
00035 namespace gnash 
00036 {
00037 
00038 class Debugger {
00039 public:
00040     DSOEXPORT Debugger();
00041     DSOEXPORT ~Debugger();
00042     // Return the default instance of Debugger
00043     DSOEXPORT static Debugger& getDefaultInstance();
00044 
00045     typedef enum {NONE, BREAK, CONTINUE, STOP} debug_state_e;
00046     typedef enum {BOTH, WRITES, READS} watch_state_e;
00047 
00048     void usage();
00049 //    bool command(const char cmd, as_environment &env);
00050 
00051     void dumpMovieInfo();
00052 
00053     void disassemble(const unsigned char *data);
00054     void disassemble();
00055     void setBreakPoint(const std::string &var, bool enabled);
00056     void removeBreakPoint(const std::string &var);
00057     void dumpBreakPoints();
00059     bool matchBreakPoint(const std::string &var, bool);
00060 
00063     void setWatchPoint(const std::string &var, watch_state_e state);
00064     void removeWatchPoint(const std::string &var);
00065     void dumpWatchPoints();
00066 
00068     void hitBreak() { _skipb--; };
00069     
00071     void go(int x) { _skipb = x; };
00072     bool isContinuing() { return (_skipb > 0) ? true : false; };
00073 
00074     // These functions manipulate the environment stack
00075     void dumpStackFrame(as_environment &env);
00076     void dumpStackFrame();
00077     static void dumpLocalRegisters(as_environment &env);
00078     void dumpLocalRegisters();
00079     void dumpGlobalRegisters(as_environment &env);
00080     void dumpGlobalRegisters();
00081     static void dumpLocalVariables(as_environment &env);
00082     void dumpLocalVariables();
00083     void setEnvStack(as_environment *x) { _env = x; };
00084     as_environment *getEnvStack() { return _env; };
00085 
00086     // 
00087     void setFramePointer(const unsigned char *x) { _pc = x; };
00088     const unsigned char *getFramePointer() const { return _pc; };
00089 
00090     DSOEXPORT void console(as_environment &env);
00091     DSOEXPORT void console();
00092     
00094     void enabled(bool x) { _enabled = x; };
00095     bool isEnabled() { return _enabled; };
00096 
00100     void traceMode(bool x) { _tracing = x; };
00102     bool isTracing() { return _tracing; };
00103 
00105     int anyWatchPoints() { return _watchpoints.size(); };
00107     bool matchWatchPoint(const std::string &var, watch_state_e state);
00108     
00110     int anyBreakPoints() { return _breakpoints.size(); };
00111 
00112     // Manipulate a symbol table
00113     void addSymbol(void *ptr, std::string name);
00114     void *lookupSymbol(std::string &name);
00115     std::string lookupSymbol(void *ptr);
00116     void dumpSymbols();
00117 
00118     // Change the value of a parameter on the stack
00119     void changeStackValue(unsigned int index, as_value &val);
00120     void changeStackValue(as_environment &env, unsigned int index, as_value &val);
00121     
00122     // Change the value of a local variable
00123     void changeLocalVariable(const std::string &var, as_value &val);
00124     void changeLocalVariable(as_environment &env, const std::string &var, as_value &val);
00125     
00126     // Change the value of a local variable
00127     void changeLocalRegister(unsigned index, as_value &val);
00128     void changeLocalRegister(as_environment &env, unsigned index, as_value &val);
00129     
00130     // Change the value of a local variable
00131     void changeGlobalRegister(unsigned index, as_value &val);
00132     void changeGlobalRegister(as_environment &env, unsigned index, as_value &val);
00133 
00134     void callStackPush(const std::string &str) { _callstack.push_back(str); };
00135     void callStackPop() { if ( ! _callstack.empty() ) _callstack.pop_back(); };
00136     void callStackDump();
00137     std::string &callStackFrame() { return _callstack.back(); };
00138     
00139     debug_state_e state() { return _state; };
00140 
00141 private:
00142     bool                        _enabled;
00143     bool                        _tracing;
00144     debug_state_e               _state;
00145     int                         _skipb;
00146     as_environment              *_env;
00147     const unsigned char         *_pc;
00148     std::map<std::string, watch_state_e> _watchpoints;
00149     std::map<std::string, bool> _breakpoints;
00150     std::map<void *, std::string> _symbols;
00151     std::vector<std::string>    _callstack;
00152 };
00153 
00154 } // end of gnash namespace
00155 
00156 #endif // end of USE_DEBUGGER
00157 
00158 // __DEBUGGER_H__
00159 #endif
00160 
00161 // Local Variables:
00162 // mode: C++
00163 // indent-tabs-mode: t
00164 // End:

Generated on Fri Mar 16 2012 15:46:09 for Gnash by  doxygen 1.7.1