gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/debugger.cpp server/debu...


From: Rob Savoye
Subject: [Gnash-commit] gnash ChangeLog server/debugger.cpp server/debu...
Date: Sat, 10 Feb 2007 01:30:32 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Rob Savoye <rsavoye>    07/02/10 01:30:32

Modified files:
        .              : ChangeLog 
        server         : debugger.cpp debugger.h 
        server/vm      : ASHandlers.cpp ActionExec.cpp 

Log message:
                * server/debugger.{cpp, h}: Implement breakpoint functions. Add 
a
                call stack.
                * server/vm/ASHandlers.cpp: Break and watch point here.
                * server/vm/ActionExec.cpp: Don't watchpoint here anymore.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2294&r2=1.2295
http://cvs.savannah.gnu.org/viewcvs/gnash/server/debugger.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/server/debugger.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ActionExec.cpp?cvsroot=gnash&r1=1.17&r2=1.18

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2294
retrieving revision 1.2295
diff -u -b -r1.2294 -r1.2295
--- ChangeLog   9 Feb 2007 20:03:15 -0000       1.2294
+++ ChangeLog   10 Feb 2007 01:30:31 -0000      1.2295
@@ -1,9 +1,14 @@
 2007-02-09  Rob Savoye  <address@hidden>
 
+       * server/debugger.{cpp, h}: Implement breakpoint functions. Add a
+       call stack.
+       * server/vm/ASHandlers.cpp: Break and watch point here.
+       * server/vm/ActionExec.cpp: Don't watchpoint here anymore.
+
        * macros/ffmpeg.m4: Check for the version of ffmpeg and print a
        warning if it's too old to use.
        * configure.ac: Print warning if you have ffmpeg, but it's a
-       version older than 5.29.0.
+       version older than 5.29.0. #18663.
 
 2007-02-09 Bastiaan Jacques <address@hidden>
 

Index: server/debugger.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/debugger.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/debugger.cpp 9 Feb 2007 16:08:40 -0000       1.9
+++ server/debugger.cpp 10 Feb 2007 01:30:32 -0000      1.10
@@ -94,10 +94,12 @@
     cerr << "\ti l - Local Variables" << endl;
     cerr << "\ti w - Dump watch points" << endl;
     cerr << "\ti b - Dump break points" << endl;
+    cerr << "\ti c - Dump Function Call Stack" << endl;
     // break and watch points
     cerr << "\tw name [r:w:b] - set variable watchpoint" << endl;
     cerr << "\tw name d - delete variable watchpoint" << endl;
-    cerr << "\tb name - set function break point" << endl;
+    cerr << "\tb name [t:f]- enable/disable function break point" << endl;
+    cerr << "\tb name d - delete function break point" << endl;
     // change data
     cerr << "\tset var [name] [value] - set a local variable" << endl;
     cerr << "\tset stack [index] [value] - set a stack entry" << endl;
@@ -218,6 +220,10 @@
                case 's':
                    this->dumpSymbols();
                    break;
+               case 'c':
+                   
+                   this->callStackDump();
+                   break;
              };
              break;
              // Tracing mode. This prints a disasembly every time
@@ -234,6 +240,20 @@
              this->usage();
              break;
              // Set a watchpoint
+         case 'b':
+             cin >> var >> sstate;
+             switch (sstate[0]) {
+               case 't':
+                   this->setBreakPoint(var, true);
+                   break;
+               case 'f':
+                   this->setBreakPoint(var, false);
+                   break;
+               case 'd':
+                   this->removeBreakPoint(var);
+                   break;
+             };
+             break;
          case 'w':
              cin >> var >> sstate;
              switch (sstate[0]) {
@@ -257,6 +277,7 @@
              } else {
                  this->setWatchPoint(var, wstate);
              }
+             sstate.erase();
              break;
          default:
              break;
@@ -265,6 +286,18 @@
 }
 
 void
+Debugger::callStackDump()
+{
+//    GNASH_REPORT_FUNCTION;
+    vector<string>::const_iterator it;
+    for (it=_callstack.begin(); it!=_callstack.end(); it++) {
+       string str = *it;
+       void *addr = this->lookupSymbol(str);
+       cerr << "\t=> " << *it << "() <" << addr << ">" << endl;
+    }
+}
+
+void
 Debugger::dumpMovieInfo()
 {
 //    GNASH_REPORT_FUNCTION;
@@ -372,22 +405,22 @@
 }
 
 void
-Debugger::setBreakPoint(std::string & /* asname */)
+Debugger::setBreakPoint(std::string &func, bool enabled)
 {
 //    GNASH_REPORT_FUNCTION;
-    dbglogfile << "WARNING: " << __PRETTY_FUNCTION__ << " is unimplemented!" 
<< endl;
+    _breakpoints[func] = enabled;
 }
 
 void
-Debugger::removeBreakPoint(std::string &var)
+Debugger::removeBreakPoint(std::string &func)
 {
 //    GNASH_REPORT_FUNCTION;
     
     string name;
     std::map<std::string, bool>::const_iterator it;
-    it = _breakpoints.find(var);
+    it = _breakpoints.find(func);
     if (it != _breakpoints.end()) {
-       _breakpoints.erase(var);
+       _breakpoints.erase(func);
     }
 }
 
@@ -399,15 +432,36 @@
     bool val;
     std::map<std::string, bool>::const_iterator it;
     
+    int index = 0;
     for (it=_breakpoints.begin(); it != _breakpoints.end(); it++) {
        name = it->first;
        val = it->second;
        if (name.size()) {
-           dbglogfile << name << endl;
+           string str = (val) ? " is enabled" : " is disabled";
+           cerr << "\tbreak #" << index++ << ": " << name << str << endl;
        }
     }
 }
 
+bool
+Debugger::matchBreakPoint(std::string &func, bool state)
+{
+//    GNASH_REPORT_FUNCTION;
+    std::map<std::string, bool>::const_iterator it;
+    it =_breakpoints.find(func);
+    if (it == _breakpoints.end()) {
+//     dbglogfile << "No Match for variable \"" << var << "\"" << endl;
+       return false;
+    } else {
+       if (state == _breakpoints[func]) {
+//         dbglogfile << "Matched for Function \"" << func << "\"" << endl;
+           this->console();
+           return true;
+       }
+       return false;
+    }
+}
+
 void
 Debugger::setWatchPoint(std::string &var, watch_state_e state)
 {
@@ -699,7 +753,7 @@
        boost::to_lower(namei, vm.getLocale());
     }
     if (namei.size() > 1) {
-       //dbglogfile << "Adding symbol " << namei << " at address: " << ptr << 
endl;
+//     dbglogfile << "Adding symbol " << namei << " at address: " << ptr << 
endl;
        _symbols[ptr] = namei;
     }
     

Index: server/debugger.h
===================================================================
RCS file: /sources/gnash/gnash/server/debugger.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/debugger.h   9 Feb 2007 05:52:49 -0000       1.4
+++ server/debugger.h   10 Feb 2007 01:30:32 -0000      1.5
@@ -44,12 +44,15 @@
     void usage();
 //    bool command(const char cmd, as_environment &env);
 
+    void dumpMovieInfo();
+
     void dissasemble(const unsigned char *data);
     void dissasemble();
-    void setBreakPoint(std::string &var);
+    void setBreakPoint(std::string &var, bool enabled);
     void removeBreakPoint(std::string &var);
     void dumpBreakPoints();
-    void dumpMovieInfo();
+    /// Does the function name match any breakpoints ?
+    bool matchBreakPoint(std::string &var, bool);
 
     /// Set a watchpoint of a variable. Gnash stops and generates a
     /// command prompt when there is a match.
@@ -124,6 +127,11 @@
     void changeGlobalRegister(int index, as_value &val);
     void changeGlobalRegister(as_environment &env, int index, as_value &val);
     
+    void callStackPush(std::string &str) { _callstack.push_back(str); };
+    void callStackPop() { _callstack.pop_back(); };
+    void callStackDump();
+    std::string &callStackFrame() { return _callstack.back(); };
+    
     debug_state_e state() { return _state; };
 private:
     bool                        _enabled;
@@ -135,6 +143,7 @@
     std::map<std::string, watch_state_e> _watchpoints;
     std::map<std::string, bool> _breakpoints;
     std::map<void *, std::string> _symbols;
+    std::vector<std::string>    _callstack;
 };
 
 } // end of gnash namespace

Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- server/vm/ASHandlers.cpp    9 Feb 2007 05:52:49 -0000       1.35
+++ server/vm/ASHandlers.cpp    10 Feb 2007 01:30:32 -0000      1.36
@@ -14,7 +14,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: ASHandlers.cpp,v 1.35 2007/02/09 05:52:49 rsavoye Exp $ */
+/* $Id: ASHandlers.cpp,v 1.36 2007/02/10 01:30:32 rsavoye Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -103,6 +103,7 @@
        as_environment& env, unsigned int nargs,
        unsigned int first_arg_index)
 {
+//    GNASH_REPORT_FUNCTION;
 
     as_value new_obj;
 
@@ -1030,6 +1031,9 @@
                                (void*)top_value.to_object());
                }
        );
+#ifdef USE_DEBUGGER
+       debugger.matchWatchPoint(var_string, Debugger::READS);
+#endif
 }
 
 void
@@ -1043,12 +1047,17 @@
        thread.ensureStack(2); 
 
        assert(env.top(1).to_string());
+        string name = env.top(1).to_std_string();
        thread.setVariable(env.top(1).to_std_string(), env.top(0));
 
         IF_VERBOSE_ACTION (
             log_action("-- set var: %s", env.top(1).to_string());
             );
 
+#ifdef USE_DEBUGGER
+       debugger.matchWatchPoint(name, Debugger::WRITES);
+#endif
+
        env.drop(2);
 }
 
@@ -2148,6 +2157,7 @@
 {
 //        GNASH_REPORT_FUNCTION;
        as_environment& env = thread.env;
+        string function_name;
 
        thread.ensureStack(2); // func name, nargs
 
@@ -2158,7 +2168,7 @@
        if ( ! function.is_function() )
        {
                // Let's consider it a as a string and lookup the function.
-               string function_name(function.to_string());
+                function_name = function.to_string();
                function = thread.getVariable(function_name);
                
                if ( ! function.is_function() )
@@ -2176,6 +2186,11 @@
 
        //log_msg("Function's nargs: %d", nargs);
     
+#ifdef USE_DEBUGGER
+//        cerr << "entering function: " << function_name << endl;
+        debugger.callStackPush(function_name);
+       debugger.matchBreakPoint(function_name, true);
+#endif
        as_value result = call_method(function, &env, env.get_target(),
                                  nargs, env.get_top_index() - 2);
 
@@ -2208,6 +2223,11 @@
        }
        env.drop(1);
 
+#ifdef USE_DEBUGGER
+//        cerr << "Returning from function: " << env.top(0).to_string() << 
endl;
+        debugger.callStackPop();
+#endif
+
        //log_msg("After top/drop");
        //env.dump_stack();
     
@@ -2265,6 +2285,7 @@
 #ifdef USE_DEBUGGER
         debugger.addSymbol(new_obj.to_object(), classname);
 #endif
+
        env.drop(nargs);
        env.push(new_obj);
 
@@ -2387,7 +2408,7 @@
 static void
 enumerateObject(as_environment& env, const as_object& obj)
 {
-    
+//    GNASH_REPORT_FUNCTION;    
        assert( env.top(0).is_null() );
        obj.enumerateProperties(env);
 }
@@ -2682,6 +2703,11 @@
           }
           else
           {
+#ifdef USE_DEBUGGER
+//        cerr << "FIXME: method name is: " << method_name << endl;
+              debugger.callStackPush(method_name);
+              debugger.matchBreakPoint(method_name, true);
+#endif
             result = call_method( method, &env, obj, nargs,
                 env.get_top_index() - 3);
           }

Index: server/vm/ActionExec.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ActionExec.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- server/vm/ActionExec.cpp    6 Feb 2007 23:06:18 -0000       1.17
+++ server/vm/ActionExec.cpp    10 Feb 2007 01:30:32 -0000      1.18
@@ -14,7 +14,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: ActionExec.cpp,v 1.17 2007/02/06 23:06:18 rsavoye Exp $ */
+/* $Id: ActionExec.cpp,v 1.18 2007/02/10 01:30:32 rsavoye Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -305,9 +305,6 @@
            boost::to_lower(namei, vm.getLocale());
        }
        
-#ifdef USE_DEBUGGER
-       debugger.matchWatchPoint(namei, Debugger::WRITES);
-#endif
        return env.set_variable(namei, val, getWithStack());
 }
 
@@ -321,9 +318,6 @@
            boost::to_lower(namei, vm.getLocale());
        }
        
-#ifdef USE_DEBUGGER
-       debugger.matchWatchPoint(namei, Debugger::READS);
-#endif
        return env.get_variable(namei, getWithStack());
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]