Mercurial > vim
comparison src/debugger.c @ 16391:3fc956fc63b6 v8.1.1200
patch 8.1.1200: old style comments in debugger source
commit https://github.com/vim/vim/commit/31fc39e47b3cc5e9ef4fa05943d42a4fb22de55e
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Apr 23 18:39:49 2019 +0200
patch 8.1.1200: old style comments in debugger source
Problem: Old style comments in debugger source.
Solution: Use new style comments. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4286)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 23 Apr 2019 18:45:04 +0200 |
parents | 1dcbaa780b8e |
children | ef00b6bc186b |
comparison
equal
deleted
inserted
replaced
16390:85514bc2b277 | 16391:3fc956fc63b6 |
---|---|
12 */ | 12 */ |
13 | 13 |
14 #include "vim.h" | 14 #include "vim.h" |
15 | 15 |
16 #if defined(FEAT_EVAL) || defined(PROTO) | 16 #if defined(FEAT_EVAL) || defined(PROTO) |
17 static int debug_greedy = FALSE; /* batch mode debugging: don't save | 17 static int debug_greedy = FALSE; // batch mode debugging: don't save |
18 and restore typeahead. */ | 18 // and restore typeahead. |
19 static void do_setdebugtracelevel(char_u *arg); | 19 static void do_setdebugtracelevel(char_u *arg); |
20 static void do_checkbacktracelevel(void); | 20 static void do_checkbacktracelevel(void); |
21 static void do_showbacktrace(char_u *cmd); | 21 static void do_showbacktrace(char_u *cmd); |
22 | 22 |
23 static char_u *debug_oldval = NULL; /* old and newval for debug expressions */ | 23 static char_u *debug_oldval = NULL; // old and newval for debug expressions |
24 static char_u *debug_newval = NULL; | 24 static char_u *debug_newval = NULL; |
25 static int debug_expr = 0; /* use debug_expr */ | 25 static int debug_expr = 0; // use debug_expr |
26 | 26 |
27 int | 27 int |
28 has_watchexpr(void) | 28 has_watchexpr(void) |
29 { | 29 { |
30 return debug_expr; | 30 return debug_expr; |
63 #define CMD_FRAME 8 | 63 #define CMD_FRAME 8 |
64 #define CMD_UP 9 | 64 #define CMD_UP 9 |
65 #define CMD_DOWN 10 | 65 #define CMD_DOWN 10 |
66 | 66 |
67 #ifdef ALWAYS_USE_GUI | 67 #ifdef ALWAYS_USE_GUI |
68 /* Can't do this when there is no terminal for input/output. */ | 68 // Can't do this when there is no terminal for input/output. |
69 if (!gui.in_use) | 69 if (!gui.in_use) |
70 { | 70 { |
71 /* Break as soon as possible. */ | 71 // Break as soon as possible. |
72 debug_break_level = 9999; | 72 debug_break_level = 9999; |
73 return; | 73 return; |
74 } | 74 } |
75 #endif | 75 #endif |
76 | 76 |
77 /* Make sure we are in raw mode and start termcap mode. Might have side | 77 // Make sure we are in raw mode and start termcap mode. Might have side |
78 * effects... */ | 78 // effects... |
79 settmode(TMODE_RAW); | 79 settmode(TMODE_RAW); |
80 starttermcap(); | 80 starttermcap(); |
81 | 81 |
82 ++RedrawingDisabled; /* don't redisplay the window */ | 82 ++RedrawingDisabled; // don't redisplay the window |
83 ++no_wait_return; /* don't wait for return */ | 83 ++no_wait_return; // don't wait for return |
84 did_emsg = FALSE; /* don't use error from debugged stuff */ | 84 did_emsg = FALSE; // don't use error from debugged stuff |
85 cmd_silent = FALSE; /* display commands */ | 85 cmd_silent = FALSE; // display commands |
86 msg_silent = FALSE; /* display messages */ | 86 msg_silent = FALSE; // display messages |
87 emsg_silent = FALSE; /* display error messages */ | 87 emsg_silent = FALSE; // display error messages |
88 redir_off = TRUE; /* don't redirect debug commands */ | 88 redir_off = TRUE; // don't redirect debug commands |
89 | 89 |
90 State = NORMAL; | 90 State = NORMAL; |
91 debug_mode = TRUE; | 91 debug_mode = TRUE; |
92 | 92 |
93 if (!debug_did_msg) | 93 if (!debug_did_msg) |
108 msg((char *)sourcing_name); | 108 msg((char *)sourcing_name); |
109 if (sourcing_lnum != 0) | 109 if (sourcing_lnum != 0) |
110 smsg(_("line %ld: %s"), (long)sourcing_lnum, cmd); | 110 smsg(_("line %ld: %s"), (long)sourcing_lnum, cmd); |
111 else | 111 else |
112 smsg(_("cmd: %s"), cmd); | 112 smsg(_("cmd: %s"), cmd); |
113 /* | 113 |
114 * Repeat getting a command and executing it. | 114 // Repeat getting a command and executing it. |
115 */ | |
116 for (;;) | 115 for (;;) |
117 { | 116 { |
118 msg_scroll = TRUE; | 117 msg_scroll = TRUE; |
119 need_wait_return = FALSE; | 118 need_wait_return = FALSE; |
120 | 119 |
121 /* Save the current typeahead buffer and replace it with an empty one. | 120 // Save the current typeahead buffer and replace it with an empty one. |
122 * This makes sure we get input from the user here and don't interfere | 121 // This makes sure we get input from the user here and don't interfere |
123 * with the commands being executed. Reset "ex_normal_busy" to avoid | 122 // with the commands being executed. Reset "ex_normal_busy" to avoid |
124 * the side effects of using ":normal". Save the stuff buffer and make | 123 // the side effects of using ":normal". Save the stuff buffer and make |
125 * it empty. Set ignore_script to avoid reading from script input. */ | 124 // it empty. Set ignore_script to avoid reading from script input. |
126 save_ex_normal_busy = ex_normal_busy; | 125 save_ex_normal_busy = ex_normal_busy; |
127 ex_normal_busy = 0; | 126 ex_normal_busy = 0; |
128 if (!debug_greedy) | 127 if (!debug_greedy) |
129 { | 128 { |
130 save_typeahead(&typeaheadbuf); | 129 save_typeahead(&typeaheadbuf); |
145 | 144 |
146 cmdline_row = msg_row; | 145 cmdline_row = msg_row; |
147 msg_starthere(); | 146 msg_starthere(); |
148 if (cmdline != NULL) | 147 if (cmdline != NULL) |
149 { | 148 { |
150 /* If this is a debug command, set "last_cmd". | 149 // If this is a debug command, set "last_cmd". |
151 * If not, reset "last_cmd". | 150 // If not, reset "last_cmd". |
152 * For a blank line use previous command. */ | 151 // For a blank line use previous command. |
153 p = skipwhite(cmdline); | 152 p = skipwhite(cmdline); |
154 if (*p != NUL) | 153 if (*p != NUL) |
155 { | 154 { |
156 switch (*p) | 155 switch (*p) |
157 { | 156 { |
200 break; | 199 break; |
201 default: last_cmd = 0; | 200 default: last_cmd = 0; |
202 } | 201 } |
203 if (last_cmd != 0) | 202 if (last_cmd != 0) |
204 { | 203 { |
205 /* Check that the tail matches. */ | 204 // Check that the tail matches. |
206 ++p; | 205 ++p; |
207 while (*p != NUL && *p == *tail) | 206 while (*p != NUL && *p == *tail) |
208 { | 207 { |
209 ++p; | 208 ++p; |
210 ++tail; | 209 ++tail; |
214 } | 213 } |
215 } | 214 } |
216 | 215 |
217 if (last_cmd != 0) | 216 if (last_cmd != 0) |
218 { | 217 { |
219 /* Execute debug command: decided where to break next and | 218 // Execute debug command: decided where to break next and |
220 * return. */ | 219 // return. |
221 switch (last_cmd) | 220 switch (last_cmd) |
222 { | 221 { |
223 case CMD_CONT: | 222 case CMD_CONT: |
224 debug_break_level = -1; | 223 debug_break_level = -1; |
225 break; | 224 break; |
237 debug_break_level = -1; | 236 debug_break_level = -1; |
238 break; | 237 break; |
239 case CMD_INTERRUPT: | 238 case CMD_INTERRUPT: |
240 got_int = TRUE; | 239 got_int = TRUE; |
241 debug_break_level = 9999; | 240 debug_break_level = 9999; |
242 /* Do not repeat ">interrupt" cmd, continue stepping. */ | 241 // Do not repeat ">interrupt" cmd, continue stepping. |
243 last_cmd = CMD_STEP; | 242 last_cmd = CMD_STEP; |
244 break; | 243 break; |
245 case CMD_BACKTRACE: | 244 case CMD_BACKTRACE: |
246 do_showbacktrace(cmd); | 245 do_showbacktrace(cmd); |
247 continue; | 246 continue; |
263 case CMD_DOWN: | 262 case CMD_DOWN: |
264 debug_backtrace_level--; | 263 debug_backtrace_level--; |
265 do_checkbacktracelevel(); | 264 do_checkbacktracelevel(); |
266 continue; | 265 continue; |
267 } | 266 } |
268 /* Going out reset backtrace_level */ | 267 // Going out reset backtrace_level |
269 debug_backtrace_level = 0; | 268 debug_backtrace_level = 0; |
270 break; | 269 break; |
271 } | 270 } |
272 | 271 |
273 /* don't debug this command */ | 272 // don't debug this command |
274 n = debug_break_level; | 273 n = debug_break_level; |
275 debug_break_level = -1; | 274 debug_break_level = -1; |
276 (void)do_cmdline(cmdline, getexline, NULL, | 275 (void)do_cmdline(cmdline, getexline, NULL, |
277 DOCMD_VERBOSE|DOCMD_EXCRESET); | 276 DOCMD_VERBOSE|DOCMD_EXCRESET); |
278 debug_break_level = n; | 277 debug_break_level = n; |
293 cmd_silent = save_cmd_silent; | 292 cmd_silent = save_cmd_silent; |
294 msg_silent = save_msg_silent; | 293 msg_silent = save_msg_silent; |
295 emsg_silent = save_emsg_silent; | 294 emsg_silent = save_emsg_silent; |
296 redir_off = save_redir_off; | 295 redir_off = save_redir_off; |
297 | 296 |
298 /* Only print the message again when typing a command before coming back | 297 // Only print the message again when typing a command before coming back |
299 * here. */ | 298 // here. |
300 debug_did_msg = TRUE; | 299 debug_did_msg = TRUE; |
301 } | 300 } |
302 | 301 |
303 static int | 302 static int |
304 get_maxbacktrace_level(void) | 303 get_maxbacktrace_level(void) |
426 debug_skipped = FALSE; | 425 debug_skipped = FALSE; |
427 if (debug_breakpoint_name != NULL) | 426 if (debug_breakpoint_name != NULL) |
428 { | 427 { |
429 if (!eap->skip) | 428 if (!eap->skip) |
430 { | 429 { |
431 /* replace K_SNR with "<SNR>" */ | 430 // replace K_SNR with "<SNR>" |
432 if (debug_breakpoint_name[0] == K_SPECIAL | 431 if (debug_breakpoint_name[0] == K_SPECIAL |
433 && debug_breakpoint_name[1] == KS_EXTRA | 432 && debug_breakpoint_name[1] == KS_EXTRA |
434 && debug_breakpoint_name[2] == (int)KE_SNR) | 433 && debug_breakpoint_name[2] == (int)KE_SNR) |
435 p = (char_u *)"<SNR>"; | 434 p = (char_u *)"<SNR>"; |
436 else | 435 else |
470 { | 469 { |
471 int prev_got_int; | 470 int prev_got_int; |
472 | 471 |
473 if (debug_skipped) | 472 if (debug_skipped) |
474 { | 473 { |
475 /* | 474 // Save the value of got_int and reset it. We don't want a previous |
476 * Save the value of got_int and reset it. We don't want a previous | 475 // interruption cause flushing the input buffer. |
477 * interruption cause flushing the input buffer. | |
478 */ | |
479 prev_got_int = got_int; | 476 prev_got_int = got_int; |
480 got_int = FALSE; | 477 got_int = FALSE; |
481 debug_breakpoint_name = debug_skipped_name; | 478 debug_breakpoint_name = debug_skipped_name; |
482 /* eap->skip is TRUE */ | 479 // eap->skip is TRUE |
483 eap->skip = FALSE; | 480 eap->skip = FALSE; |
484 (void)dbg_check_breakpoint(eap); | 481 (void)dbg_check_breakpoint(eap); |
485 eap->skip = TRUE; | 482 eap->skip = TRUE; |
486 got_int |= prev_got_int; | 483 got_int |= prev_got_int; |
487 return TRUE; | 484 return TRUE; |
493 * The list of breakpoints: dbg_breakp. | 490 * The list of breakpoints: dbg_breakp. |
494 * This is a grow-array of structs. | 491 * This is a grow-array of structs. |
495 */ | 492 */ |
496 struct debuggy | 493 struct debuggy |
497 { | 494 { |
498 int dbg_nr; /* breakpoint number */ | 495 int dbg_nr; // breakpoint number |
499 int dbg_type; /* DBG_FUNC, DBG_FILE or DBG_EXPR */ | 496 int dbg_type; // DBG_FUNC, DBG_FILE or DBG_EXPR |
500 char_u *dbg_name; /* function, expression or file name */ | 497 char_u *dbg_name; // function, expression or file name |
501 regprog_T *dbg_prog; /* regexp program */ | 498 regprog_T *dbg_prog; // regexp program |
502 linenr_T dbg_lnum; /* line number in function or file */ | 499 linenr_T dbg_lnum; // line number in function or file |
503 int dbg_forceit; /* ! used */ | 500 int dbg_forceit; // ! used |
504 #ifdef FEAT_EVAL | 501 #ifdef FEAT_EVAL |
505 typval_T *dbg_val; /* last result of watchexpression */ | 502 typval_T *dbg_val; // last result of watchexpression |
506 #endif | 503 #endif |
507 int dbg_level; /* stored nested level for expr */ | 504 int dbg_level; // stored nested level for expr |
508 }; | 505 }; |
509 | 506 |
510 static garray_T dbg_breakp = {0, 0, sizeof(struct debuggy), 4, NULL}; | 507 static garray_T dbg_breakp = {0, 0, sizeof(struct debuggy), 4, NULL}; |
511 #define BREAKP(idx) (((struct debuggy *)dbg_breakp.ga_data)[idx]) | 508 #define BREAKP(idx) (((struct debuggy *)dbg_breakp.ga_data)[idx]) |
512 #define DEBUGGY(gap, idx) (((struct debuggy *)gap->ga_data)[idx]) | 509 #define DEBUGGY(gap, idx) (((struct debuggy *)gap->ga_data)[idx]) |
513 static int last_breakp = 0; /* nr of last defined breakpoint */ | 510 static int last_breakp = 0; // nr of last defined breakpoint |
514 | 511 |
515 #ifdef FEAT_PROFILE | 512 #ifdef FEAT_PROFILE |
516 /* Profiling uses file and func names similar to breakpoints. */ | 513 // Profiling uses file and func names similar to breakpoints. |
517 static garray_T prof_ga = {0, 0, sizeof(struct debuggy), 4, NULL}; | 514 static garray_T prof_ga = {0, 0, sizeof(struct debuggy), 4, NULL}; |
518 #endif | 515 #endif |
519 #define DBG_FUNC 1 | 516 #define DBG_FUNC 1 |
520 #define DBG_FILE 2 | 517 #define DBG_FILE 2 |
521 #define DBG_EXPR 3 | 518 #define DBG_EXPR 3 |
529 * Returns FAIL for failure. | 526 * Returns FAIL for failure. |
530 */ | 527 */ |
531 static int | 528 static int |
532 dbg_parsearg( | 529 dbg_parsearg( |
533 char_u *arg, | 530 char_u *arg, |
534 garray_T *gap) /* either &dbg_breakp or &prof_ga */ | 531 garray_T *gap) // either &dbg_breakp or &prof_ga |
535 { | 532 { |
536 char_u *p = arg; | 533 char_u *p = arg; |
537 char_u *q; | 534 char_u *q; |
538 struct debuggy *bp; | 535 struct debuggy *bp; |
539 int here = FALSE; | 536 int here = FALSE; |
540 | 537 |
541 if (ga_grow(gap, 1) == FAIL) | 538 if (ga_grow(gap, 1) == FAIL) |
542 return FAIL; | 539 return FAIL; |
543 bp = &DEBUGGY(gap, gap->ga_len); | 540 bp = &DEBUGGY(gap, gap->ga_len); |
544 | 541 |
545 /* Find "func" or "file". */ | 542 // Find "func" or "file". |
546 if (STRNCMP(p, "func", 4) == 0) | 543 if (STRNCMP(p, "func", 4) == 0) |
547 bp->dbg_type = DBG_FUNC; | 544 bp->dbg_type = DBG_FUNC; |
548 else if (STRNCMP(p, "file", 4) == 0) | 545 else if (STRNCMP(p, "file", 4) == 0) |
549 bp->dbg_type = DBG_FILE; | 546 bp->dbg_type = DBG_FILE; |
550 else if ( | 547 else if ( |
572 semsg(_(e_invarg2), p); | 569 semsg(_(e_invarg2), p); |
573 return FAIL; | 570 return FAIL; |
574 } | 571 } |
575 p = skipwhite(p + 4); | 572 p = skipwhite(p + 4); |
576 | 573 |
577 /* Find optional line number. */ | 574 // Find optional line number. |
578 if (here) | 575 if (here) |
579 bp->dbg_lnum = curwin->w_cursor.lnum; | 576 bp->dbg_lnum = curwin->w_cursor.lnum; |
580 else if ( | 577 else if ( |
581 #ifdef FEAT_PROFILE | 578 #ifdef FEAT_PROFILE |
582 gap != &prof_ga && | 579 gap != &prof_ga && |
587 p = skipwhite(p); | 584 p = skipwhite(p); |
588 } | 585 } |
589 else | 586 else |
590 bp->dbg_lnum = 0; | 587 bp->dbg_lnum = 0; |
591 | 588 |
592 /* Find the function or file name. Don't accept a function name with (). */ | 589 // Find the function or file name. Don't accept a function name with (). |
593 if ((!here && *p == NUL) | 590 if ((!here && *p == NUL) |
594 || (here && *p != NUL) | 591 || (here && *p != NUL) |
595 || (bp->dbg_type == DBG_FUNC && strstr((char *)p, "()") != NULL)) | 592 || (bp->dbg_type == DBG_FUNC && strstr((char *)p, "()") != NULL)) |
596 { | 593 { |
597 semsg(_(e_invarg2), arg); | 594 semsg(_(e_invarg2), arg); |
608 if (bp->dbg_name != NULL) | 605 if (bp->dbg_name != NULL) |
609 bp->dbg_val = eval_expr(bp->dbg_name, NULL); | 606 bp->dbg_val = eval_expr(bp->dbg_name, NULL); |
610 } | 607 } |
611 else | 608 else |
612 { | 609 { |
613 /* Expand the file name in the same way as do_source(). This means | 610 // Expand the file name in the same way as do_source(). This means |
614 * doing it twice, so that $DIR/file gets expanded when $DIR is | 611 // doing it twice, so that $DIR/file gets expanded when $DIR is |
615 * "~/dir". */ | 612 // "~/dir". |
616 q = expand_env_save(p); | 613 q = expand_env_save(p); |
617 if (q == NULL) | 614 if (q == NULL) |
618 return FAIL; | 615 return FAIL; |
619 p = expand_env_save(q); | 616 p = expand_env_save(q); |
620 vim_free(q); | 617 vim_free(q); |
665 } | 662 } |
666 if (pat == NULL || bp->dbg_prog == NULL) | 663 if (pat == NULL || bp->dbg_prog == NULL) |
667 vim_free(bp->dbg_name); | 664 vim_free(bp->dbg_name); |
668 else | 665 else |
669 { | 666 { |
670 if (bp->dbg_lnum == 0) /* default line number is 1 */ | 667 if (bp->dbg_lnum == 0) // default line number is 1 |
671 bp->dbg_lnum = 1; | 668 bp->dbg_lnum = 1; |
672 #ifdef FEAT_PROFILE | 669 #ifdef FEAT_PROFILE |
673 if (eap->cmdidx != CMD_profile) | 670 if (eap->cmdidx != CMD_profile) |
674 #endif | 671 #endif |
675 { | 672 { |
679 ++gap->ga_len; | 676 ++gap->ga_len; |
680 } | 677 } |
681 } | 678 } |
682 else | 679 else |
683 { | 680 { |
684 /* DBG_EXPR */ | 681 // DBG_EXPR |
685 DEBUGGY(gap, gap->ga_len++).dbg_nr = ++last_breakp; | 682 DEBUGGY(gap, gap->ga_len++).dbg_nr = ++last_breakp; |
686 ++debug_tick; | 683 ++debug_tick; |
687 } | 684 } |
688 } | 685 } |
689 } | 686 } |
725 #endif | 722 #endif |
726 } | 723 } |
727 | 724 |
728 if (vim_isdigit(*eap->arg)) | 725 if (vim_isdigit(*eap->arg)) |
729 { | 726 { |
730 /* ":breakdel {nr}" */ | 727 // ":breakdel {nr}" |
731 nr = atol((char *)eap->arg); | 728 nr = atol((char *)eap->arg); |
732 for (i = 0; i < gap->ga_len; ++i) | 729 for (i = 0; i < gap->ga_len; ++i) |
733 if (DEBUGGY(gap, i).dbg_nr == nr) | 730 if (DEBUGGY(gap, i).dbg_nr == nr) |
734 { | 731 { |
735 todel = i; | 732 todel = i; |
741 todel = 0; | 738 todel = 0; |
742 del_all = TRUE; | 739 del_all = TRUE; |
743 } | 740 } |
744 else | 741 else |
745 { | 742 { |
746 /* ":breakdel {func|file|expr} [lnum] {name}" */ | 743 // ":breakdel {func|file|expr} [lnum] {name}" |
747 if (dbg_parsearg(eap->arg, gap) == FAIL) | 744 if (dbg_parsearg(eap->arg, gap) == FAIL) |
748 return; | 745 return; |
749 bp = &DEBUGGY(gap, gap->ga_len); | 746 bp = &DEBUGGY(gap, gap->ga_len); |
750 for (i = 0; i < gap->ga_len; ++i) | 747 for (i = 0; i < gap->ga_len; ++i) |
751 { | 748 { |
787 ++debug_tick; | 784 ++debug_tick; |
788 if (!del_all) | 785 if (!del_all) |
789 break; | 786 break; |
790 } | 787 } |
791 | 788 |
792 /* If all breakpoints were removed clear the array. */ | 789 // If all breakpoints were removed clear the array. |
793 if (gap->ga_len == 0) | 790 if (gap->ga_len == 0) |
794 ga_clear(gap); | 791 ga_clear(gap); |
795 } | 792 } |
796 } | 793 } |
797 | 794 |
828 * Find a breakpoint for a function or sourced file. | 825 * Find a breakpoint for a function or sourced file. |
829 * Returns line number at which to break; zero when no matching breakpoint. | 826 * Returns line number at which to break; zero when no matching breakpoint. |
830 */ | 827 */ |
831 linenr_T | 828 linenr_T |
832 dbg_find_breakpoint( | 829 dbg_find_breakpoint( |
833 int file, /* TRUE for a file, FALSE for a function */ | 830 int file, // TRUE for a file, FALSE for a function |
834 char_u *fname, /* file or function name */ | 831 char_u *fname, // file or function name |
835 linenr_T after) /* after this line number */ | 832 linenr_T after) // after this line number |
836 { | 833 { |
837 return debuggy_find(file, fname, after, &dbg_breakp, NULL); | 834 return debuggy_find(file, fname, after, &dbg_breakp, NULL); |
838 } | 835 } |
839 | 836 |
840 #if defined(FEAT_PROFILE) || defined(PROTO) | 837 #if defined(FEAT_PROFILE) || defined(PROTO) |
841 /* | 838 /* |
842 * Return TRUE if profiling is on for a function or sourced file. | 839 * Return TRUE if profiling is on for a function or sourced file. |
843 */ | 840 */ |
844 int | 841 int |
845 has_profiling( | 842 has_profiling( |
846 int file, /* TRUE for a file, FALSE for a function */ | 843 int file, // TRUE for a file, FALSE for a function |
847 char_u *fname, /* file or function name */ | 844 char_u *fname, // file or function name |
848 int *fp) /* return: forceit */ | 845 int *fp) // return: forceit |
849 { | 846 { |
850 return (debuggy_find(file, fname, (linenr_T)0, &prof_ga, fp) | 847 return (debuggy_find(file, fname, (linenr_T)0, &prof_ga, fp) |
851 != (linenr_T)0); | 848 != (linenr_T)0); |
852 } | 849 } |
853 #endif | 850 #endif |
855 /* | 852 /* |
856 * Common code for dbg_find_breakpoint() and has_profiling(). | 853 * Common code for dbg_find_breakpoint() and has_profiling(). |
857 */ | 854 */ |
858 static linenr_T | 855 static linenr_T |
859 debuggy_find( | 856 debuggy_find( |
860 int file, /* TRUE for a file, FALSE for a function */ | 857 int file, // TRUE for a file, FALSE for a function |
861 char_u *fname, /* file or function name */ | 858 char_u *fname, // file or function name |
862 linenr_T after, /* after this line number */ | 859 linenr_T after, // after this line number |
863 garray_T *gap, /* either &dbg_breakp or &prof_ga */ | 860 garray_T *gap, // either &dbg_breakp or &prof_ga |
864 int *fp) /* if not NULL: return forceit */ | 861 int *fp) // if not NULL: return forceit |
865 { | 862 { |
866 struct debuggy *bp; | 863 struct debuggy *bp; |
867 int i; | 864 int i; |
868 linenr_T lnum = 0; | 865 linenr_T lnum = 0; |
869 char_u *name = fname; | 866 char_u *name = fname; |
870 int prev_got_int; | 867 int prev_got_int; |
871 | 868 |
872 /* Return quickly when there are no breakpoints. */ | 869 // Return quickly when there are no breakpoints. |
873 if (gap->ga_len == 0) | 870 if (gap->ga_len == 0) |
874 return (linenr_T)0; | 871 return (linenr_T)0; |
875 | 872 |
876 /* Replace K_SNR in function name with "<SNR>". */ | 873 // Replace K_SNR in function name with "<SNR>". |
877 if (!file && fname[0] == K_SPECIAL) | 874 if (!file && fname[0] == K_SPECIAL) |
878 { | 875 { |
879 name = alloc((unsigned)STRLEN(fname) + 3); | 876 name = alloc((unsigned)STRLEN(fname) + 3); |
880 if (name == NULL) | 877 if (name == NULL) |
881 name = fname; | 878 name = fname; |
886 } | 883 } |
887 } | 884 } |
888 | 885 |
889 for (i = 0; i < gap->ga_len; ++i) | 886 for (i = 0; i < gap->ga_len; ++i) |
890 { | 887 { |
891 /* Skip entries that are not useful or are for a line that is beyond | 888 // Skip entries that are not useful or are for a line that is beyond |
892 * an already found breakpoint. */ | 889 // an already found breakpoint. |
893 bp = &DEBUGGY(gap, i); | 890 bp = &DEBUGGY(gap, i); |
894 if (((bp->dbg_type == DBG_FILE) == file && | 891 if (((bp->dbg_type == DBG_FILE) == file && |
895 bp->dbg_type != DBG_EXPR && ( | 892 bp->dbg_type != DBG_EXPR && ( |
896 #ifdef FEAT_PROFILE | 893 #ifdef FEAT_PROFILE |
897 gap == &prof_ga || | 894 gap == &prof_ga || |
898 #endif | 895 #endif |
899 (bp->dbg_lnum > after && (lnum == 0 || bp->dbg_lnum < lnum))))) | 896 (bp->dbg_lnum > after && (lnum == 0 || bp->dbg_lnum < lnum))))) |
900 { | 897 { |
901 /* | 898 // Save the value of got_int and reset it. We don't want a |
902 * Save the value of got_int and reset it. We don't want a | 899 // previous interruption cancel matching, only hitting CTRL-C |
903 * previous interruption cancel matching, only hitting CTRL-C | 900 // while matching should abort it. |
904 * while matching should abort it. | |
905 */ | |
906 prev_got_int = got_int; | 901 prev_got_int = got_int; |
907 got_int = FALSE; | 902 got_int = FALSE; |
908 if (vim_regexec_prog(&bp->dbg_prog, FALSE, name, (colnr_T)0)) | 903 if (vim_regexec_prog(&bp->dbg_prog, FALSE, name, (colnr_T)0)) |
909 { | 904 { |
910 lnum = bp->dbg_lnum; | 905 lnum = bp->dbg_lnum; |
940 { | 935 { |
941 typval_T *v; | 936 typval_T *v; |
942 | 937 |
943 line = TRUE; | 938 line = TRUE; |
944 debug_oldval = typval_tostring(bp->dbg_val); | 939 debug_oldval = typval_tostring(bp->dbg_val); |
945 /* Need to evaluate again, typval_compare() overwrites | 940 // Need to evaluate again, typval_compare() overwrites |
946 * "tv". */ | 941 // "tv". |
947 v = eval_expr(bp->dbg_name, NULL); | 942 v = eval_expr(bp->dbg_name, NULL); |
948 debug_newval = typval_tostring(v); | 943 debug_newval = typval_tostring(v); |
949 free_tv(bp->dbg_val); | 944 free_tv(bp->dbg_val); |
950 bp->dbg_val = v; | 945 bp->dbg_val = v; |
951 } | 946 } |
981 * Called when a breakpoint was encountered. | 976 * Called when a breakpoint was encountered. |
982 */ | 977 */ |
983 void | 978 void |
984 dbg_breakpoint(char_u *name, linenr_T lnum) | 979 dbg_breakpoint(char_u *name, linenr_T lnum) |
985 { | 980 { |
986 /* We need to check if this line is actually executed in do_one_cmd() */ | 981 // We need to check if this line is actually executed in do_one_cmd() |
987 debug_breakpoint_name = name; | 982 debug_breakpoint_name = name; |
988 debug_breakpoint_lnum = lnum; | 983 debug_breakpoint_lnum = lnum; |
989 } | 984 } |
990 #endif | 985 #endif |