Index: Makefile.in =================================================================== RCS file: /cvs/octave/src/Makefile.in,v retrieving revision 1.425 diff -c -r1.425 Makefile.in *** Makefile.in 5 Jan 2007 22:54:10 -0000 1.425 --- Makefile.in 29 Jan 2007 02:39:26 -0000 *************** *** 109,115 **** parse.h pr-output.h procstream.h sighandlers.h siglist.h \ sparse-xdiv.h sparse-xpow.h symtab.h sysdep.h \ token.h toplev.h unwind-prot.h utils.h variables.h version.h \ ! xdiv.h xpow.h \ $(OV_INCLUDES) \ $(PT_INCLUDES) \ $(OV_SPARSE_INCLUDES) --- 109,115 ---- parse.h pr-output.h procstream.h sighandlers.h siglist.h \ sparse-xdiv.h sparse-xpow.h symtab.h sysdep.h \ token.h toplev.h unwind-prot.h utils.h variables.h version.h \ ! xdiv.h xpow.h profiler.h\ $(OV_INCLUDES) \ $(PT_INCLUDES) \ $(OV_SPARSE_INCLUDES) *************** *** 179,185 **** parse.y pr-output.cc procstream.cc sighandlers.cc \ siglist.c sparse-xdiv.cc sparse-xpow.cc strfns.cc \ symtab.cc syscalls.cc sysdep.cc token.cc toplev.cc \ ! unwind-prot.cc utils.cc variables.cc xdiv.cc xpow.cc \ $(OV_SRC) \ $(PT_SRC) --- 179,185 ---- parse.y pr-output.cc procstream.cc sighandlers.cc \ siglist.c sparse-xdiv.cc sparse-xpow.cc strfns.cc \ symtab.cc syscalls.cc sysdep.cc token.cc toplev.cc \ ! unwind-prot.cc utils.cc variables.cc xdiv.cc xpow.cc profiler.cc\ $(OV_SRC) \ $(PT_SRC) Index: debug.cc =================================================================== RCS file: /cvs/octave/src/debug.cc,v retrieving revision 1.20 diff -c -r1.20 debug.cc *** debug.cc 6 Apr 2006 19:38:34 -0000 1.20 --- debug.cc 29 Jan 2007 02:39:26 -0000 *************** *** 348,355 **** os << "dbtype: unable to open `" << ff << "' for reading!\n"; } else ! os << "dbtype: unkown function"; } DEFCMD (dbtype, args, , --- 348,361 ---- os << "dbtype: unable to open `" << ff << "' for reading!\n"; } else ! os << "dbtype: unkown function "<< name << "\n"; + os.flush(); + } + + inline int min(int x,int y) + { + return (x< y)?x: y; } DEFCMD (dbtype, args, , *************** *** 401,425 **** int start = atoi (start_str.c_str ()); int end = atoi (end_str.c_str ()); ! if (start < end) do_dbtype (octave_stdout, dbg_fcn->name (), start, end); else error ("dbtype: the start line must be less than the end line\n"); } else ! error ("dbtype: if you specify lines it must be like `start:end`"); } } break; ! case 2: // (dbtype func start:end) dbg_fcn = get_user_function (argv[1]); if (dbg_fcn) { std::string arg = argv[2]; ! size_t ind = arg.find (':'); if (ind != NPOS) --- 407,437 ---- int start = atoi (start_str.c_str ()); int end = atoi (end_str.c_str ()); ! if (min(start,end) <= 0) ! error("dbtype: the start & end lines must be >= 1\n"); ! ! if (start <= end) do_dbtype (octave_stdout, dbg_fcn->name (), start, end); else error ("dbtype: the start line must be less than the end line\n"); } else ! { ! error ("dbtype: if you specify lines it must be like `start:end`"); ! } } } break; ! case 2: // (dbtype func start:end) , (dbtype func start) dbg_fcn = get_user_function (argv[1]); if (dbg_fcn) { std::string arg = argv[2]; ! int start=0; ! int end=0; size_t ind = arg.find (':'); if (ind != NPOS) *************** *** 427,443 **** std::string start_str = arg.substr (0, ind); std::string end_str = arg.substr (ind + 1); ! int start = atoi (start_str.c_str ()); ! int end = atoi (end_str.c_str ()); ! ! if (start < end) ! do_dbtype (octave_stdout, ! dbg_fcn->name (), start, end); ! else ! error ("dbtype: the start line must be less than the end line\n"); } else ! error ("dbtype: if you specify lines it must be like `start:end`"); } break; --- 439,463 ---- std::string start_str = arg.substr (0, ind); std::string end_str = arg.substr (ind + 1); ! start = atoi (start_str.c_str ()); ! end = atoi (end_str.c_str ()); ! ! } ! else ! { ! const std::string start_str = arg; ! start = atoi (start_str.c_str ()); ! end = start; } + + if (min(start,end) <= 0) + error("dbtype: the start & end lines must be >= 1\n"); + + if (start <= end) + do_dbtype (octave_stdout, + dbg_fcn->name (), start, end); else ! error ("dbtype: the start line must be less than the end line\n"); } break; Index: ov-builtin.cc =================================================================== RCS file: /cvs/octave/src/ov-builtin.cc,v retrieving revision 1.23 diff -c -r1.23 ov-builtin.cc *** ov-builtin.cc 22 Jun 2006 00:57:28 -0000 1.23 --- ov-builtin.cc 29 Jan 2007 02:39:26 -0000 *************** *** 31,36 **** --- 31,39 ---- #include "ov.h" #include "toplev.h" #include "unwind-prot.h" + #include "pager.h" + + #include "profiler.h" DEFINE_OCTAVE_ALLOCATOR (octave_builtin); *************** *** 50,57 **** case '(': { int tmp_nargout = (type.length () > 1 && nargout == 0) ? 1 : nargout; ! ! retval = do_multi_index_op (tmp_nargout, idx.front ()); } break; --- 53,82 ---- case '(': { int tmp_nargout = (type.length () > 1 && nargout == 0) ? 1 : nargout; ! profiler_call_state cstate=ENDOF_FUNCTION_STATES; ! ! //profiler event "builtin-call" ! //octave_stdout << "ov-builtin: profiler event builtin-call to **>" << this->name() << "<** \n"; ! cstate=ENTER_FUNCTION; ! if(octave_profiler::isprofiling()) ! octave_profiler::send_event(this,BUILTIN_FUNCTION,cstate); ! ! retval = do_multi_index_op (tmp_nargout, idx.front ()); ! ! //profiler event "builtin-exception" ! if (error_state) ! { ! //octave_stdout << "ov-builtin: profiler event builtin-exception \n"; ! cstate=EXCEPTION_IN_FUNCTION; ! } ! //profiler event "builtin-return" ! else ! { ! //octave_stdout << "ov-builtin: profiler event builtin-return \n"; ! cstate=LEAVE_FUNCTION; ! } ! if(octave_profiler::isprofiling()) ! octave_profiler::send_event(this,BUILTIN_FUNCTION,cstate); } break; Index: ov-mapper.cc =================================================================== RCS file: /cvs/octave/src/ov-mapper.cc,v retrieving revision 1.32 diff -c -r1.32 ov-mapper.cc *** ov-mapper.cc 24 Apr 2006 19:13:10 -0000 1.32 --- ov-mapper.cc 29 Jan 2007 02:39:26 -0000 *************** *** 34,39 **** --- 34,42 ---- #include "ov.h" #include "toplev.h" #include "unwind-prot.h" + #include "pager.h" + + #include "profiler.h" DEFINE_OCTAVE_ALLOCATOR (octave_mapper); *************** *** 397,405 **** { case '(': { ! int tmp_nargout = (type.length () > 1 && nargout == 0) ? 1 : nargout; ! retval = do_multi_index_op (tmp_nargout, idx.front ()); } break; --- 400,430 ---- { case '(': { ! int tmp_nargout = (type.length () > 1 && nargout == 0) ? 1 : nargout; ! profiler_call_state cstate=ENDOF_FUNCTION_STATES; ! ! // enter profiler for mapper-function "mapper-call" ! //octave_stdout << "ov-mapper: profiler event mapper-call to **>" << this->name() << "<** \n"; ! cstate=ENTER_FUNCTION; ! if(octave_profiler::isprofiling()) ! octave_profiler::send_event(this,BUILTIN_FUNCTION,cstate); ! ! retval = do_multi_index_op (tmp_nargout, idx.front ()); ! // leave profiler for mapper-function "mapper-exception" ! if(error_state) ! { ! //octave_stdout << "ov-mapper: profiler event mapper-exception \n"; ! cstate=EXCEPTION_IN_FUNCTION; ! } ! // leave profiler for mapper-function "mapper-return" ! else ! { ! //octave_stdout << "ov-mapper: profiler event mapper-return \n"; ! cstate=LEAVE_FUNCTION; ! } ! if(octave_profiler::isprofiling()) ! octave_profiler::send_event(this,BUILTIN_FUNCTION,cstate); } break; Index: ov-mex-fcn.cc =================================================================== RCS file: /cvs/octave/src/ov-mex-fcn.cc,v retrieving revision 1.2 diff -c -r1.2 ov-mex-fcn.cc *** ov-mex-fcn.cc 20 Oct 2006 16:54:30 -0000 1.2 --- ov-mex-fcn.cc 29 Jan 2007 02:39:26 -0000 *************** *** 35,40 **** --- 35,43 ---- #include "ov.h" #include "toplev.h" #include "unwind-prot.h" + #include "pager.h" + + #include "profiler.h" DEFINE_OCTAVE_ALLOCATOR (octave_mex_function); *************** *** 87,95 **** { case '(': { ! int tmp_nargout = (type.length () > 1 && nargout == 0) ? 1 : nargout; ! ! retval = do_multi_index_op (tmp_nargout, idx.front ()); } break; --- 90,120 ---- { case '(': { ! int tmp_nargout = (type.length () > 1 && nargout == 0) ? 1 : nargout; ! profiler_call_state cstate=ENDOF_FUNCTION_STATES; ! ! //profiler event "mex-call" ! //octave_stdout << "ov-mex: profiler event mex-call to **>" << this->name() << "<** \n"; ! cstate=ENTER_FUNCTION; ! if(octave_profiler::isprofiling()) ! octave_profiler::send_event(this,MEX_FUNCTION,cstate); ! ! retval = do_multi_index_op (tmp_nargout, idx.front ()); ! ! //profiler event "mex-exception" ! if (error_state) ! { ! //octave_stdout << "ov-mex: profiler event mex-exception \n"; ! cstate=EXCEPTION_IN_FUNCTION; ! } ! //profiler event "mex-return" ! else ! { ! //octave_stdout << "ov-mex: profiler event mex-return \n"; ! cstate=LEAVE_FUNCTION; ! } ! if(octave_profiler::isprofiling()) ! octave_profiler::send_event(this,BUILTIN_FUNCTION,cstate); } break; Index: ov-usr-fcn.cc =================================================================== RCS file: /cvs/octave/src/ov-usr-fcn.cc,v retrieving revision 1.72 diff -c -r1.72 ov-usr-fcn.cc *** ov-usr-fcn.cc 9 Nov 2006 18:26:56 -0000 1.72 --- ov-usr-fcn.cc 29 Jan 2007 02:39:26 -0000 *************** *** 48,53 **** --- 48,55 ---- #include "parse.h" #include "variables.h" + #include "profiler.h" + // Maximum nesting level for functions called recursively. static int Vmax_recursion_depth = 256; *************** *** 204,209 **** --- 206,212 ---- sr->unprotect (); } + // origin of call -> () octave_value_list octave_user_function::subsref (const std::string& type, const std::list& idx, *************** *** 215,223 **** { case '(': { ! int tmp_nargout = (type.length () > 1 && nargout == 0) ? 1 : nargout; ! ! retval = do_multi_index_op (tmp_nargout, idx.front ()); } break; --- 218,271 ---- { case '(': { ! int tmp_nargout = (type.length () > 1 && nargout == 0) ? 1 : nargout; ! profiler_function_type ftype=ENDOF_FUNCTION_TYPES; ! profiler_call_state cstate=ENDOF_FUNCTION_STATES; ! ! // check if we have any useful variant of the function that calls the ! ! // profiler passes octave-call event. (1 point for anonymous functions, scripts) ! // profiler::report() should take only the octave_function handle & determine ! // if these are nested or inline or whatever such. ! //octave_stdout << "ov-user-fcn: do_multi_index_op event: octave-call to **>"; ! if ( is_inline_function() ) ! { ! ftype=ANONYMOUS_FUNCTION; ! //octave_stdout << this->name() << "<** (ANONYMOUS/INLINE FUNCTION)\n"; ! } ! else if( is_nested_function() ) ! { ! ftype=NESTED_FUNCTION; ! //octave_stdout << this->name() << "<** (NESTED FUNCTION) \n"; ! } ! else ! { ! ftype=OCTAVE_FUNCTION; //standard M-function ! //octave_stdout << this->name() << "<** \n"; ! } ! ! cstate=ENTER_FUNCTION; ! if(octave_profiler::isprofiling()) ! octave_profiler::send_event(this,ftype,cstate); ! ! retval = do_multi_index_op (tmp_nargout, idx.front ()); ! ! // profiler passes octave-exception event. ! if(error_state) ! { ! //octave_stdout << "ov-user-fcn: do_multi_index_op event: octave-exception \n"; ! cstate=EXCEPTION_IN_FUNCTION; ! } ! // profiler passes octave-return event. ! else ! { ! //octave_stdout << "ov-user-fcn: do_multi_index_op event: octave-return \n"; ! cstate=LEAVE_FUNCTION; ! } ! ! // report the event ! if(octave_profiler::isprofiling()) ! octave_profiler::send_event(this,ftype,cstate); } break; *************** *** 243,248 **** --- 291,297 ---- return retval; } + // add profiling hooks here. octave_value_list octave_user_function::do_multi_index_op (int nargout, const octave_value_list& args) *************** *** 354,361 **** // Evaluate the commands that make up the function. unwind_protect_bool (evaluating_function_body); ! evaluating_function_body = true; ! cmd_list->eval (); if (echo_commands) --- 403,410 ---- // Evaluate the commands that make up the function. unwind_protect_bool (evaluating_function_body); ! evaluating_function_body = true; ! cmd_list->eval (); if (echo_commands) *************** *** 372,377 **** --- 421,427 ---- traceback_error (); goto abort; } + // Copy return values out. Index: pt-stmt.cc =================================================================== RCS file: /cvs/octave/src/pt-stmt.cc,v retrieving revision 1.31 diff -c -r1.31 pt-stmt.cc *** pt-stmt.cc 24 Jan 2007 20:43:37 -0000 1.31 --- pt-stmt.cc 29 Jan 2007 02:39:26 -0000 *************** *** 84,89 **** --- 84,90 ---- } } + // point of dispatch the real function octave_value_list tree_statement::eval (bool silent, int nargout, bool in_function_body) { *************** *** 94,105 **** if (cmd || expr) { unwind_protect_ptr (curr_statement); ! curr_statement = this; ! maybe_echo_code (in_function_body); if (cmd) ! cmd->eval (); else { expr->set_print_flag (pf); --- 95,112 ---- if (cmd || expr) { unwind_protect_ptr (curr_statement); ! curr_statement = this; maybe_echo_code (in_function_body); if (cmd) ! { ! //octave_function *curr=octave_call_stack::current(); ! //octave_stdout << "tree_statement::eval Calling the function "; ! //if(curr) ! //octave_stdout << curr->name(); ! //octave_stdout << "\n"; ! cmd->eval (); ! } else { expr->set_print_flag (pf); *************** *** 165,170 **** --- 172,178 ---- tw.visit_statement (*this); } + // is this the point of dispatch to all functions? octave_value_list tree_statement_list::eval (bool silent, int nargout) { *************** *** 197,203 **** break; if (tree_return_command::returning) ! break; if (p == end ()) break; --- 205,214 ---- break; if (tree_return_command::returning) ! { ! //octave_stdout << "pt-stmt:treelist:eval return \n"; ! break; ! } if (p == end ()) break;