To: vim-dev@vim.org Subject: Patch 6.2.117 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.117 Problem: Breakpoints in loops of sourced files and functions are not detected. (Hari Krishna Dara) Solution: Check for breakpoints when using lines that were previously read. (Servatius Brandt) Files: src/eval.c, src/ex_cmds2.c, src/ex_docmd.c, src/proto/eval.pro, src/proto/ex_cmds2.pro *** ../vim-6.2.116/src/eval.c Sun Oct 12 16:56:43 2003 --- src/eval.c Sun Oct 12 20:04:45 2003 *************** *** 126,131 **** --- 126,161 ---- }; /* + * Return the name of the executed function. + */ + char_u * + func_name(cookie) + void *cookie; + { + return ((struct funccall *)cookie)->func->name; + } + + /* + * Return the address holding the next breakpoint line for a funccall cookie. + */ + linenr_T * + func_breakpoint(cookie) + void *cookie; + { + return &((struct funccall *)cookie)->breakpoint; + } + + /* + * Return the address holding the debug tick for a funccall cookie. + */ + int * + func_dbg_tick(cookie) + void *cookie; + { + return &((struct funccall *)cookie)->dbg_tick; + } + + /* * Return the nesting level for a funccall cookie. */ int *** ../vim-6.2.116/src/ex_cmds2.c Sat Sep 27 19:36:46 2003 --- src/ex_cmds2.c Sun Oct 12 20:04:45 2003 *************** *** 1995,2000 **** --- 1995,2020 ---- }; #ifdef FEAT_EVAL + /* + * Return the address holding the next breakpoint line for a source cookie. + */ + linenr_T * + source_breakpoint(cookie) + void *cookie; + { + return &((struct source_cookie *)cookie)->breakpoint; + } + + /* + * Return the address holding the debug tick for a source cookie. + */ + int * + source_dbg_tick(cookie) + void *cookie; + { + return &((struct source_cookie *)cookie)->dbg_tick; + } + /* * Return the nesting level for a source cookie. */ *** ../vim-6.2.116/src/ex_docmd.c Sun Oct 12 17:10:47 2003 --- src/ex_docmd.c Sun Oct 12 20:14:08 2003 *************** *** 591,596 **** --- 591,599 ---- struct condstack cstack; /* conditional stack */ garray_T lines_ga; /* keep lines for ":while" */ int current_line = 0; /* active line in lines_ga */ + char_u *fname = NULL; /* function or script name */ + linenr_T *breakpoint = NULL; /* ptr to breakpoint field in cookie */ + int *dbg_tick = NULL; /* ptr to dbg_tick field in cookie */ int saved_trylevel = 0; int saved_force_abort = 0; except_T *saved_caught_stack = NULL; *************** *** 649,654 **** --- 652,672 ---- if (getline == get_func_line && ex_nesting_level == func_level(cookie)) ++ex_nesting_level; + /* Get the function or script name and the address where the next breakpoint + * line and the debug tick for a function or script are stored. */ + if (getline == get_func_line) + { + fname = func_name(cookie); + breakpoint = func_breakpoint(cookie); + dbg_tick = func_dbg_tick(cookie); + } + else if (getline == getsourceline) + { + fname = sourcing_name; + breakpoint = source_breakpoint(cookie); + dbg_tick = source_dbg_tick(cookie); + } + /* * Initialize "force_abort" and "suppress_errthrow" at the top level. */ *************** *** 749,756 **** --- 767,794 ---- break; } + /* If breakpoints have been added/deleted need to check for it. */ + if (breakpoint != NULL && dbg_tick != NULL + && *dbg_tick != debug_tick) + { + *breakpoint = dbg_find_breakpoint((getline == getsourceline), + fname, sourcing_lnum); + *dbg_tick = debug_tick; + } + next_cmdline = ((wcmd_T *)(lines_ga.ga_data))[current_line].line; sourcing_lnum = ((wcmd_T *)(lines_ga.ga_data))[current_line].lnum; + + /* Did we encounter a breakpoint? */ + if (breakpoint != NULL && *breakpoint != 0 + && *breakpoint <= sourcing_lnum) + { + dbg_breakpoint(fname, sourcing_lnum); + /* Find next breakpoint. */ + *breakpoint = dbg_find_breakpoint((getline == getsourceline), + fname, sourcing_lnum); + *dbg_tick = debug_tick; + } } #endif *************** *** 932,937 **** --- 970,984 ---- current_line = cstack.cs_line[cstack.cs_idx]; cstack.cs_had_while = TRUE; /* note we jumped there */ line_breakcheck(); /* check if CTRL-C typed */ + + /* Check for the next breakpoint at or after the ":while".*/ + if (breakpoint != NULL) + { + *breakpoint = dbg_find_breakpoint( + (getline == getsourceline), fname, + ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1); + *dbg_tick = debug_tick; + } } else /* can only get here with ":endwhile" */ { *** ../vim-6.2.116/src/proto/eval.pro Sun Jun 1 12:26:07 2003 --- src/proto/eval.pro Sun Oct 12 20:04:45 2003 *************** *** 1,4 **** --- 1,7 ---- /* eval.c */ + char_u *func_name __ARGS((void *cookie)); + linenr_T *func_breakpoint __ARGS((void *cookie)); + int *func_dbg_tick __ARGS((void *cookie)); int func_level __ARGS((void *cookie)); int current_func_returned __ARGS((void)); void set_internal_string_var __ARGS((char_u *name, char_u *value)); *** ../vim-6.2.116/src/proto/ex_cmds2.pro Sun Jun 1 12:26:08 2003 --- src/proto/ex_cmds2.pro Sun Oct 12 20:04:45 2003 *************** *** 37,42 **** --- 37,44 ---- int do_in_runtimepath __ARGS((char_u *name, int all, void (*callback)(char_u *fname))); void ex_options __ARGS((exarg_T *eap)); void ex_source __ARGS((exarg_T *eap)); + linenr_T *source_breakpoint __ARGS((void *cookie)); + int *source_dbg_tick __ARGS((void *cookie)); int source_level __ARGS((void *cookie)); int do_source __ARGS((char_u *fname, int check_other, int is_vimrc)); void ex_scriptnames __ARGS((exarg_T *eap)); *** ../vim-6.2.116/src/version.c Sun Oct 12 17:28:22 2003 --- src/version.c Sun Oct 12 20:19:24 2003 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 117, /**/ -- Wizards had always known that the act of observation changed the thing that was observed, and sometimes forgot that it also changed the observer too. Terry Pratchett - Interesting times /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///