Mercurial > vim
annotate src/debugger.c @ 32553:e80fa10e0549 v9.0.1608
patch 9.0.1608: update_topline() is called twice
Commit: https://github.com/vim/vim/commit/5c606846b9a43c7e6b94c7e96838f7532792f557
Author: Luuk van Baal <luukvbaal@gmail.com>
Date: Mon Jun 5 15:00:05 2023 +0100
patch 9.0.1608: update_topline() is called twice
Problem: update_topline() is called twice.
Solution: Do not call update_topline() before curs_columns(). (Luuk van
Baal, closes #12495)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 05 Jun 2023 16:15:04 +0200 |
parents | 87f59a64efab |
children | 448aef880252 |
rev | line source |
---|---|
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 * debugger.c: Vim script debugger functions |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #include "vim.h" |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 #if defined(FEAT_EVAL) || defined(PROTO) |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
17 static int debug_greedy = FALSE; // batch mode debugging: don't save |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
18 // and restore typeahead. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 static void do_setdebugtracelevel(char_u *arg); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 static void do_checkbacktracelevel(void); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 static void do_showbacktrace(char_u *cmd); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
23 static char_u *debug_oldval = NULL; // old and newval for debug expressions |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 static char_u *debug_newval = NULL; |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
25 static int debug_expr = 0; // use debug_expr |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 int |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 has_watchexpr(void) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 return debug_expr; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 * do_debug(): Debug mode. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 * Repeatedly get Ex commands, until told to continue normal execution. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 void |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 do_debug(char_u *cmd) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 int save_msg_scroll = msg_scroll; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 int save_State = State; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 int save_did_emsg = did_emsg; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 int save_cmd_silent = cmd_silent; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 int save_msg_silent = msg_silent; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 int save_emsg_silent = emsg_silent; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 int save_redir_off = redir_off; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 tasave_T typeaheadbuf; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 int typeahead_saved = FALSE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 int save_ignore_script = 0; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 int save_ex_normal_busy; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 int n; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 char_u *cmdline = NULL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 char_u *p; |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
54 char_u *sname; |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 char *tail = NULL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 static int last_cmd = 0; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 #define CMD_CONT 1 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 #define CMD_NEXT 2 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 #define CMD_STEP 3 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 #define CMD_FINISH 4 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 #define CMD_QUIT 5 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 #define CMD_INTERRUPT 6 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 #define CMD_BACKTRACE 7 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 #define CMD_FRAME 8 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 #define CMD_UP 9 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 #define CMD_DOWN 10 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 #ifdef ALWAYS_USE_GUI |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
69 // Can't do this when there is no terminal for input/output. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 if (!gui.in_use) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 { |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
72 // Break as soon as possible. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 debug_break_level = 9999; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 return; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 #endif |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
78 // Make sure we are in raw mode and start termcap mode. Might have side |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
79 // effects... |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 settmode(TMODE_RAW); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 starttermcap(); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
83 ++RedrawingDisabled; // don't redisplay the window |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
84 ++no_wait_return; // don't wait for return |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
85 did_emsg = FALSE; // don't use error from debugged stuff |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
86 cmd_silent = FALSE; // display commands |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
87 msg_silent = FALSE; // display messages |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
88 emsg_silent = FALSE; // display error messages |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
89 redir_off = TRUE; // don't redirect debug commands |
30355
c0be6563fa39
patch 9.0.0513: may not be able to use a pattern ad the debug prompt
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
90 save_timeout_for_debugging(); // disable regexp timeout flag |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28023
diff
changeset
|
92 State = MODE_NORMAL; |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 debug_mode = TRUE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 if (!debug_did_msg) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 msg(_("Entering Debug mode. Type \"cont\" to continue.")); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 if (debug_oldval != NULL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 smsg(_("Oldval = \"%s\""), debug_oldval); |
32120
97255d909654
patch 9.0.1391: "clear" macros are not always used
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
100 VIM_CLEAR(debug_oldval); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 if (debug_newval != NULL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 smsg(_("Newval = \"%s\""), debug_newval); |
32120
97255d909654
patch 9.0.1391: "clear" macros are not always used
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
105 VIM_CLEAR(debug_newval); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 } |
22208
a607f02fd17a
patch 8.2.1653: expand('<stack>') does not include the final line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
107 sname = estack_sfile(ESTACK_NONE); |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
108 if (sname != NULL) |
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
109 msg((char *)sname); |
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
110 vim_free(sname); |
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
111 if (SOURCING_LNUM != 0) |
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
112 smsg(_("line %ld: %s"), SOURCING_LNUM, cmd); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 smsg(_("cmd: %s"), cmd); |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
115 |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
116 // Repeat getting a command and executing it. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 for (;;) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 msg_scroll = TRUE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 need_wait_return = FALSE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
122 // Save the current typeahead buffer and replace it with an empty one. |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
123 // This makes sure we get input from the user here and don't interfere |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
124 // with the commands being executed. Reset "ex_normal_busy" to avoid |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
125 // the side effects of using ":normal". Save the stuff buffer and make |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
126 // it empty. Set ignore_script to avoid reading from script input. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 save_ex_normal_busy = ex_normal_busy; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 ex_normal_busy = 0; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 if (!debug_greedy) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 save_typeahead(&typeaheadbuf); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 typeahead_saved = TRUE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 save_ignore_script = ignore_script; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 ignore_script = TRUE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 |
30325
58fb880f3607
patch 9.0.0498: various small issues
Bram Moolenaar <Bram@vim.org>
parents:
30241
diff
changeset
|
137 // don't debug any function call, e.g. from an expression mapping |
30241
44e53d136c5a
patch 9.0.0456: function called at debug prompt is also debugged
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
138 n = debug_break_level; |
44e53d136c5a
patch 9.0.0456: function called at debug prompt is also debugged
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
139 debug_break_level = -1; |
44e53d136c5a
patch 9.0.0456: function called at debug prompt is also debugged
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
140 |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 vim_free(cmdline); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 cmdline = getcmdline_prompt('>', NULL, 0, EXPAND_NOTHING, NULL); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 |
30241
44e53d136c5a
patch 9.0.0456: function called at debug prompt is also debugged
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
144 debug_break_level = n; |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 if (typeahead_saved) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 { |
24846
fdc6a7769045
patch 8.2.2961: keys typed during a :normal command are discarded
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
147 restore_typeahead(&typeaheadbuf, TRUE); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 ignore_script = save_ignore_script; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 ex_normal_busy = save_ex_normal_busy; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 cmdline_row = msg_row; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 msg_starthere(); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 if (cmdline != NULL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 { |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
156 // If this is a debug command, set "last_cmd". |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
157 // If not, reset "last_cmd". |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
158 // For a blank line use previous command. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 p = skipwhite(cmdline); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 if (*p != NUL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 switch (*p) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 case 'c': last_cmd = CMD_CONT; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 tail = "ont"; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 case 'n': last_cmd = CMD_NEXT; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 tail = "ext"; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 case 's': last_cmd = CMD_STEP; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
171 tail = "tep"; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 case 'f': |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 last_cmd = 0; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 if (p[1] == 'r') |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
176 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 last_cmd = CMD_FRAME; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 tail = "rame"; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 last_cmd = CMD_FINISH; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 tail = "inish"; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 case 'q': last_cmd = CMD_QUIT; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
187 tail = "uit"; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
188 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 case 'i': last_cmd = CMD_INTERRUPT; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 tail = "nterrupt"; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 case 'b': last_cmd = CMD_BACKTRACE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 if (p[1] == 't') |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 tail = "t"; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 tail = "acktrace"; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 case 'w': last_cmd = CMD_BACKTRACE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 tail = "here"; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 case 'u': last_cmd = CMD_UP; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 tail = "p"; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 case 'd': last_cmd = CMD_DOWN; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 tail = "own"; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 default: last_cmd = 0; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 if (last_cmd != 0) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 { |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
211 // Check that the tail matches. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 ++p; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
213 while (*p != NUL && *p == *tail) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 ++p; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 ++tail; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 if (ASCII_ISALPHA(*p) && last_cmd != CMD_FRAME) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 last_cmd = 0; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 if (last_cmd != 0) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 { |
24918
f11779c1d123
patch 8.2.2996: Vim9: when debugging cannot inspect local variables
Bram Moolenaar <Bram@vim.org>
parents:
24846
diff
changeset
|
225 // Execute debug command: decide where to break next and |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
226 // return. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 switch (last_cmd) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 case CMD_CONT: |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 debug_break_level = -1; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 case CMD_NEXT: |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 debug_break_level = ex_nesting_level; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 case CMD_STEP: |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 debug_break_level = 9999; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 case CMD_FINISH: |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 debug_break_level = ex_nesting_level - 1; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 case CMD_QUIT: |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 got_int = TRUE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 debug_break_level = -1; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 case CMD_INTERRUPT: |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 got_int = TRUE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 debug_break_level = 9999; |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
248 // Do not repeat ">interrupt" cmd, continue stepping. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 last_cmd = CMD_STEP; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 case CMD_BACKTRACE: |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 do_showbacktrace(cmd); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 continue; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 case CMD_FRAME: |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 if (*p == NUL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
256 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 do_showbacktrace(cmd); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 p = skipwhite(p); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 do_setdebugtracelevel(p); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 continue; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 case CMD_UP: |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 debug_backtrace_level++; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 do_checkbacktracelevel(); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 continue; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 case CMD_DOWN: |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 debug_backtrace_level--; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 do_checkbacktracelevel(); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 continue; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 } |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
274 // Going out reset backtrace_level |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 debug_backtrace_level = 0; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
279 // don't debug this command |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
280 n = debug_break_level; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 debug_break_level = -1; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
282 (void)do_cmdline(cmdline, getexline, NULL, |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 DOCMD_VERBOSE|DOCMD_EXCRESET); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
284 debug_break_level = n; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
285 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 lines_left = Rows - 1; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 vim_free(cmdline); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 |
32479
87f59a64efab
patch 9.0.1571: RedrawingDisabled not used consistently
Bram Moolenaar <Bram@vim.org>
parents:
32120
diff
changeset
|
290 if (RedrawingDisabled > 0) |
87f59a64efab
patch 9.0.1571: RedrawingDisabled not used consistently
Bram Moolenaar <Bram@vim.org>
parents:
32120
diff
changeset
|
291 --RedrawingDisabled; |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 --no_wait_return; |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
293 redraw_all_later(UPD_NOT_VALID); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 need_wait_return = FALSE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 msg_scroll = save_msg_scroll; |
30355
c0be6563fa39
patch 9.0.0513: may not be able to use a pattern ad the debug prompt
Bram Moolenaar <Bram@vim.org>
parents:
30325
diff
changeset
|
296 restore_timeout_for_debugging(); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 lines_left = Rows - 1; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 State = save_State; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 debug_mode = FALSE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
300 did_emsg = save_did_emsg; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 cmd_silent = save_cmd_silent; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
302 msg_silent = save_msg_silent; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 emsg_silent = save_emsg_silent; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 redir_off = save_redir_off; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
306 // Only print the message again when typing a command before coming back |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
307 // here. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 debug_did_msg = TRUE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
309 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
310 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
311 static int |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
312 get_maxbacktrace_level(char_u *sname) |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 char *p, *q; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
315 int maxbacktrace = 0; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
316 |
31667
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
317 if (sname == NULL) |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
318 return 0; |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
319 |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
320 p = (char *)sname; |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
321 while ((q = strstr(p, "..")) != NULL) |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
322 { |
31667
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
323 p = q + 2; |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
324 maxbacktrace++; |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
325 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 return maxbacktrace; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
327 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 static void |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 do_setdebugtracelevel(char_u *arg) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
332 int level; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 level = atoi((char *)arg); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 if (*arg == '+' || level < 0) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 debug_backtrace_level += level; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 debug_backtrace_level = level; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
339 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
340 do_checkbacktracelevel(); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
341 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
342 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
343 static void |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
344 do_checkbacktracelevel(void) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
345 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
346 if (debug_backtrace_level < 0) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
347 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
348 debug_backtrace_level = 0; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
349 msg(_("frame is zero")); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
350 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
351 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 { |
22208
a607f02fd17a
patch 8.2.1653: expand('<stack>') does not include the final line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
353 char_u *sname = estack_sfile(ESTACK_NONE); |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
354 int max = get_maxbacktrace_level(sname); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
355 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 if (debug_backtrace_level > max) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
357 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
358 debug_backtrace_level = max; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
359 smsg(_("frame at highest level: %d"), max); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
360 } |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
361 vim_free(sname); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
362 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
363 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 static void |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 do_showbacktrace(char_u *cmd) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
367 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
368 char_u *sname; |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 char *cur; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 char *next; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 int i = 0; |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
372 int max; |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 |
22208
a607f02fd17a
patch 8.2.1653: expand('<stack>') does not include the final line number
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
374 sname = estack_sfile(ESTACK_NONE); |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
375 max = get_maxbacktrace_level(sname); |
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
376 if (sname != NULL) |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
378 cur = (char *)sname; |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 while (!got_int) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 next = strstr(cur, ".."); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
382 if (next != NULL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
383 *next = NUL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 if (i == max - debug_backtrace_level) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 smsg("->%d %s", max - i, cur); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 smsg(" %d %s", max - i, cur); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 ++i; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
389 if (next == NULL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 *next = '.'; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 cur = next + 2; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 } |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
394 vim_free(sname); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 } |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
396 |
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
397 if (SOURCING_LNUM != 0) |
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18966
diff
changeset
|
398 smsg(_("line %ld: %s"), (long)SOURCING_LNUM, cmd); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 smsg(_("cmd: %s"), cmd); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
401 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
402 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
403 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
404 * ":debug". |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
405 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 void |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
407 ex_debug(exarg_T *eap) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 int debug_break_level_save = debug_break_level; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
410 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
411 debug_break_level = 9999; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
412 do_cmdline_cmd(eap->arg); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 debug_break_level = debug_break_level_save; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 static char_u *debug_breakpoint_name = NULL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 static linenr_T debug_breakpoint_lnum; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
420 * When debugging or a breakpoint is set on a skipped command, no debug prompt |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 * is shown by do_one_cmd(). This situation is indicated by debug_skipped, and |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 * debug_skipped_name is then set to the source name in the breakpoint case. If |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 * a skipped command decides itself that a debug prompt should be displayed, it |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
424 * can do so by calling dbg_check_skipped(). |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
425 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 static int debug_skipped; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
427 static char_u *debug_skipped_name; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
429 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
430 * Go to debug mode when a breakpoint was encountered or "ex_nesting_level" is |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
431 * at or below the break level. But only when the line is actually |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
432 * executed. Return TRUE and set breakpoint_name for skipped commands that |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
433 * decide to execute something themselves. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
434 * Called from do_one_cmd() before executing a command. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
435 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
436 void |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
437 dbg_check_breakpoint(exarg_T *eap) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
438 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
439 char_u *p; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
440 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
441 debug_skipped = FALSE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 if (debug_breakpoint_name != NULL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
444 if (!eap->skip) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 { |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
446 // replace K_SNR with "<SNR>" |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 if (debug_breakpoint_name[0] == K_SPECIAL |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
448 && debug_breakpoint_name[1] == KS_EXTRA |
25852
336e2d9924e6
patch 8.2.3460: some type casts are not needed
Bram Moolenaar <Bram@vim.org>
parents:
25767
diff
changeset
|
449 && debug_breakpoint_name[2] == KE_SNR) |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 p = (char_u *)"<SNR>"; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
451 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
452 p = (char_u *)""; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
453 smsg(_("Breakpoint in \"%s%s\" line %ld"), |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 p, |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
455 debug_breakpoint_name + (*p == NUL ? 0 : 3), |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
456 (long)debug_breakpoint_lnum); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 debug_breakpoint_name = NULL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
458 do_debug(eap->cmd); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
461 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
462 debug_skipped = TRUE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 debug_skipped_name = debug_breakpoint_name; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
464 debug_breakpoint_name = NULL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
467 else if (ex_nesting_level <= debug_break_level) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
469 if (!eap->skip) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 do_debug(eap->cmd); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
472 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
473 debug_skipped = TRUE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
474 debug_skipped_name = NULL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
475 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
476 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
477 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
478 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
479 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 * Go to debug mode if skipped by dbg_check_breakpoint() because eap->skip was |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
481 * set. Return TRUE when the debug mode is entered this time. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
482 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
483 int |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
484 dbg_check_skipped(exarg_T *eap) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
485 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
486 int prev_got_int; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
487 |
31667
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
488 if (!debug_skipped) |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
489 return FALSE; |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
490 |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
491 // Save the value of got_int and reset it. We don't want a previous |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
492 // interruption cause flushing the input buffer. |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
493 prev_got_int = got_int; |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
494 got_int = FALSE; |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
495 debug_breakpoint_name = debug_skipped_name; |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
496 // eap->skip is TRUE |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
497 eap->skip = FALSE; |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
498 (void)dbg_check_breakpoint(eap); |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
499 eap->skip = TRUE; |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
500 got_int |= prev_got_int; |
b89cfd86e18e
patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31531
diff
changeset
|
501 return TRUE; |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
502 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
503 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
504 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
505 * The list of breakpoints: dbg_breakp. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
506 * This is a grow-array of structs. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
507 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
508 struct debuggy |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
509 { |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
510 int dbg_nr; // breakpoint number |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
511 int dbg_type; // DBG_FUNC, DBG_FILE or DBG_EXPR |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
512 char_u *dbg_name; // function, expression or file name |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
513 regprog_T *dbg_prog; // regexp program |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
514 linenr_T dbg_lnum; // line number in function or file |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
515 int dbg_forceit; // ! used |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 #ifdef FEAT_EVAL |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
517 typval_T *dbg_val; // last result of watchexpression |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
518 #endif |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
519 int dbg_level; // stored nested level for expr |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
520 }; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
521 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
522 static garray_T dbg_breakp = {0, 0, sizeof(struct debuggy), 4, NULL}; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
523 #define BREAKP(idx) (((struct debuggy *)dbg_breakp.ga_data)[idx]) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 #define DEBUGGY(gap, idx) (((struct debuggy *)gap->ga_data)[idx]) |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
525 static int last_breakp = 0; // nr of last defined breakpoint |
25719
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
526 static int has_expr_breakpoint = FALSE; |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
527 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 #ifdef FEAT_PROFILE |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
529 // Profiling uses file and func names similar to breakpoints. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 static garray_T prof_ga = {0, 0, sizeof(struct debuggy), 4, NULL}; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 #endif |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
532 #define DBG_FUNC 1 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 #define DBG_FILE 2 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
534 #define DBG_EXPR 3 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
536 static linenr_T debuggy_find(int file,char_u *fname, linenr_T after, garray_T *gap, int *fp); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
538 /* |
25763
5e7c96e9036d
patch 8.2.3417: Vim9: a failing debug expression aborts script sourcing
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
539 * Evaluate the "bp->dbg_name" expression and return the result. |
25767
dfa045d2cc89
patch 8.2.3419: a failing debug expression may make Vim unusable
Bram Moolenaar <Bram@vim.org>
parents:
25763
diff
changeset
|
540 * Disables error messages. |
25763
5e7c96e9036d
patch 8.2.3417: Vim9: a failing debug expression aborts script sourcing
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
541 */ |
5e7c96e9036d
patch 8.2.3417: Vim9: a failing debug expression aborts script sourcing
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
542 static typval_T * |
25767
dfa045d2cc89
patch 8.2.3419: a failing debug expression may make Vim unusable
Bram Moolenaar <Bram@vim.org>
parents:
25763
diff
changeset
|
543 eval_expr_no_emsg(struct debuggy *bp) |
25763
5e7c96e9036d
patch 8.2.3417: Vim9: a failing debug expression aborts script sourcing
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
544 { |
5e7c96e9036d
patch 8.2.3417: Vim9: a failing debug expression aborts script sourcing
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
545 typval_T *tv; |
5e7c96e9036d
patch 8.2.3417: Vim9: a failing debug expression aborts script sourcing
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
546 |
25767
dfa045d2cc89
patch 8.2.3419: a failing debug expression may make Vim unusable
Bram Moolenaar <Bram@vim.org>
parents:
25763
diff
changeset
|
547 // Disable error messages, a bad expression would make Vim unusable. |
dfa045d2cc89
patch 8.2.3419: a failing debug expression may make Vim unusable
Bram Moolenaar <Bram@vim.org>
parents:
25763
diff
changeset
|
548 ++emsg_off; |
25763
5e7c96e9036d
patch 8.2.3417: Vim9: a failing debug expression aborts script sourcing
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
549 tv = eval_expr(bp->dbg_name, NULL); |
25767
dfa045d2cc89
patch 8.2.3419: a failing debug expression may make Vim unusable
Bram Moolenaar <Bram@vim.org>
parents:
25763
diff
changeset
|
550 --emsg_off; |
25763
5e7c96e9036d
patch 8.2.3417: Vim9: a failing debug expression aborts script sourcing
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
551 |
5e7c96e9036d
patch 8.2.3417: Vim9: a failing debug expression aborts script sourcing
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
552 return tv; |
5e7c96e9036d
patch 8.2.3417: Vim9: a failing debug expression aborts script sourcing
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
553 } |
5e7c96e9036d
patch 8.2.3417: Vim9: a failing debug expression aborts script sourcing
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
554 |
5e7c96e9036d
patch 8.2.3417: Vim9: a failing debug expression aborts script sourcing
Bram Moolenaar <Bram@vim.org>
parents:
25719
diff
changeset
|
555 /* |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 * Parse the arguments of ":profile", ":breakadd" or ":breakdel" and put them |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
557 * in the entry just after the last one in dbg_breakp. Note that "dbg_name" |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 * is allocated. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 * Returns FAIL for failure. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
560 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 static int |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 dbg_parsearg( |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 char_u *arg, |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
564 garray_T *gap) // either &dbg_breakp or &prof_ga |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 char_u *p = arg; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 char_u *q; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 struct debuggy *bp; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 int here = FALSE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 if (ga_grow(gap, 1) == FAIL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
572 return FAIL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 bp = &DEBUGGY(gap, gap->ga_len); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
575 // Find "func" or "file". |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 if (STRNCMP(p, "func", 4) == 0) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 bp->dbg_type = DBG_FUNC; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 else if (STRNCMP(p, "file", 4) == 0) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 bp->dbg_type = DBG_FILE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 else if ( |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 #ifdef FEAT_PROFILE |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 gap != &prof_ga && |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
583 #endif |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 STRNCMP(p, "here", 4) == 0) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 if (curbuf->b_ffname == NULL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24978
diff
changeset
|
588 emsg(_(e_no_file_name)); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 return FAIL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
591 bp->dbg_type = DBG_FILE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
592 here = TRUE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 else if ( |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 #ifdef FEAT_PROFILE |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
596 gap != &prof_ga && |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
597 #endif |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
598 STRNCMP(p, "expr", 4) == 0) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 bp->dbg_type = DBG_EXPR; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
600 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
601 { |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26853
diff
changeset
|
602 semsg(_(e_invalid_argument_str), p); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
603 return FAIL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
604 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
605 p = skipwhite(p + 4); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
606 |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
607 // Find optional line number. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
608 if (here) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
609 bp->dbg_lnum = curwin->w_cursor.lnum; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
610 else if ( |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
611 #ifdef FEAT_PROFILE |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
612 gap != &prof_ga && |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
613 #endif |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
614 VIM_ISDIGIT(*p)) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
615 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
616 bp->dbg_lnum = getdigits(&p); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 p = skipwhite(p); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 bp->dbg_lnum = 0; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
622 // Find the function or file name. Don't accept a function name with (). |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 if ((!here && *p == NUL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
624 || (here && *p != NUL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 || (bp->dbg_type == DBG_FUNC && strstr((char *)p, "()") != NULL)) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
626 { |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26853
diff
changeset
|
627 semsg(_(e_invalid_argument_str), arg); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
628 return FAIL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
629 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
630 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
631 if (bp->dbg_type == DBG_FUNC) |
24978
2818b8108d92
patch 8.2.3026: Vim9: cannot set breakpoint in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
24918
diff
changeset
|
632 bp->dbg_name = vim_strsave(STRNCMP(p, "g:", 2) == 0 ? p + 2 : p); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
633 else if (here) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
634 bp->dbg_name = vim_strsave(curbuf->b_ffname); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 else if (bp->dbg_type == DBG_EXPR) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 bp->dbg_name = vim_strsave(p); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
638 if (bp->dbg_name != NULL) |
25767
dfa045d2cc89
patch 8.2.3419: a failing debug expression may make Vim unusable
Bram Moolenaar <Bram@vim.org>
parents:
25763
diff
changeset
|
639 bp->dbg_val = eval_expr_no_emsg(bp); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
642 { |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
643 // Expand the file name in the same way as do_source(). This means |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
644 // doing it twice, so that $DIR/file gets expanded when $DIR is |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
645 // "~/dir". |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 q = expand_env_save(p); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
647 if (q == NULL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
648 return FAIL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
649 p = expand_env_save(q); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
650 vim_free(q); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 if (p == NULL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
652 return FAIL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
653 if (*p != '*') |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
654 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 bp->dbg_name = fix_fname(p); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 vim_free(p); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
657 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
658 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
659 bp->dbg_name = p; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
660 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
661 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
662 if (bp->dbg_name == NULL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
663 return FAIL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
664 return OK; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
665 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
666 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
667 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
668 * ":breakadd". Also used for ":profile". |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
669 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
670 void |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
671 ex_breakadd(exarg_T *eap) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
672 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
673 struct debuggy *bp; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
674 char_u *pat; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
675 garray_T *gap; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
676 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
677 gap = &dbg_breakp; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
678 #ifdef FEAT_PROFILE |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
679 if (eap->cmdidx == CMD_profile) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 gap = &prof_ga; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
681 #endif |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
682 |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
683 if (dbg_parsearg(eap->arg, gap) != OK) |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
684 return; |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
685 |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
686 bp = &DEBUGGY(gap, gap->ga_len); |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
687 bp->dbg_forceit = eap->forceit; |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
688 |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
689 if (bp->dbg_type != DBG_EXPR) |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
690 { |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
691 pat = file_pat_to_reg_pat(bp->dbg_name, NULL, NULL, FALSE); |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
692 if (pat != NULL) |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
693 { |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
694 bp->dbg_prog = vim_regcomp(pat, RE_MAGIC + RE_STRING); |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
695 vim_free(pat); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
696 } |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
697 if (pat == NULL || bp->dbg_prog == NULL) |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
698 vim_free(bp->dbg_name); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
699 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
700 { |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
701 if (bp->dbg_lnum == 0) // default line number is 1 |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
702 bp->dbg_lnum = 1; |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
703 #ifdef FEAT_PROFILE |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
704 if (eap->cmdidx != CMD_profile) |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
705 #endif |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
706 { |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
707 DEBUGGY(gap, gap->ga_len).dbg_nr = ++last_breakp; |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
708 ++debug_tick; |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
709 } |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
710 ++gap->ga_len; |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
711 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 } |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
713 else |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
714 { |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
715 // DBG_EXPR |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
716 DEBUGGY(gap, gap->ga_len++).dbg_nr = ++last_breakp; |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
717 ++debug_tick; |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
718 if (gap == &dbg_breakp) |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
719 has_expr_breakpoint = TRUE; |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
720 } |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
721 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
722 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
724 * ":debuggreedy". |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
725 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
726 void |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
727 ex_debuggreedy(exarg_T *eap) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
728 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
729 if (eap->addr_count == 0 || eap->line2 != 0) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
730 debug_greedy = TRUE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
731 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
732 debug_greedy = FALSE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
733 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
734 |
25719
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
735 static void |
32009
4545f58c8490
patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents:
31667
diff
changeset
|
736 update_has_expr_breakpoint(void) |
25719
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
737 { |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
738 int i; |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
739 |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
740 has_expr_breakpoint = FALSE; |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
741 for (i = 0; i < dbg_breakp.ga_len; ++i) |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
742 if (BREAKP(i).dbg_type == DBG_EXPR) |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
743 { |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
744 has_expr_breakpoint = TRUE; |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
745 break; |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
746 } |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
747 } |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
748 |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
749 /* |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
750 * Return TRUE if there is any expression breakpoint. |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
751 */ |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
752 int |
32009
4545f58c8490
patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents:
31667
diff
changeset
|
753 debug_has_expr_breakpoint(void) |
25719
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
754 { |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
755 return has_expr_breakpoint; |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
756 } |
154663508d9b
patch 8.2.3395: Vim9: expression breakpoint not checked in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
757 |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
758 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 * ":breakdel" and ":profdel". |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 void |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
762 ex_breakdel(exarg_T *eap) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 struct debuggy *bp, *bpi; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 int nr; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 int todel = -1; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 int del_all = FALSE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 int i; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 linenr_T best_lnum = 0; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
770 garray_T *gap; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 gap = &dbg_breakp; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 if (eap->cmdidx == CMD_profdel) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
775 #ifdef FEAT_PROFILE |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 gap = &prof_ga; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 #else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
778 ex_ni(eap); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 return; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 #endif |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
781 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 if (vim_isdigit(*eap->arg)) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 { |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
785 // ":breakdel {nr}" |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
786 nr = atol((char *)eap->arg); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
787 for (i = 0; i < gap->ga_len; ++i) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 if (DEBUGGY(gap, i).dbg_nr == nr) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
789 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 todel = i; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
792 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
793 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
794 else if (*eap->arg == '*') |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 todel = 0; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
797 del_all = TRUE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
798 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 { |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
801 // ":breakdel {func|file|expr} [lnum] {name}" |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 if (dbg_parsearg(eap->arg, gap) == FAIL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 return; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 bp = &DEBUGGY(gap, gap->ga_len); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 for (i = 0; i < gap->ga_len; ++i) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
807 bpi = &DEBUGGY(gap, i); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 if (bp->dbg_type == bpi->dbg_type |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
809 && STRCMP(bp->dbg_name, bpi->dbg_name) == 0 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 && (bp->dbg_lnum == bpi->dbg_lnum |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 || (bp->dbg_lnum == 0 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
812 && (best_lnum == 0 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
813 || bpi->dbg_lnum < best_lnum)))) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
814 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
815 todel = i; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
816 best_lnum = bpi->dbg_lnum; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
817 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
818 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
819 vim_free(bp->dbg_name); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
820 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
821 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
822 if (todel < 0) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
823 { |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
824 semsg(_(e_breakpoint_not_found_str), eap->arg); |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
825 return; |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
826 } |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
827 |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
828 while (gap->ga_len > 0) |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
829 { |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
830 vim_free(DEBUGGY(gap, todel).dbg_name); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
831 #ifdef FEAT_EVAL |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
832 if (DEBUGGY(gap, todel).dbg_type == DBG_EXPR |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
833 && DEBUGGY(gap, todel).dbg_val != NULL) |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
834 free_tv(DEBUGGY(gap, todel).dbg_val); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
835 #endif |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
836 vim_regfree(DEBUGGY(gap, todel).dbg_prog); |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
837 --gap->ga_len; |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
838 if (todel < gap->ga_len) |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
839 mch_memmove(&DEBUGGY(gap, todel), &DEBUGGY(gap, todel + 1), |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
840 (gap->ga_len - todel) * sizeof(struct debuggy)); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
841 #ifdef FEAT_PROFILE |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
842 if (eap->cmdidx == CMD_breakdel) |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
843 #endif |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
844 ++debug_tick; |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
845 if (!del_all) |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
846 break; |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
847 } |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
848 |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
849 // If all breakpoints were removed clear the array. |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
850 if (gap->ga_len == 0) |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
851 ga_clear(gap); |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
852 if (gap == &dbg_breakp) |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
853 update_has_expr_breakpoint(); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
856 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
857 * ":breaklist". |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
858 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 void |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
860 ex_breaklist(exarg_T *eap UNUSED) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 struct debuggy *bp; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 int i; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
864 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
865 if (dbg_breakp.ga_len == 0) |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
866 { |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 msg(_("No breakpoints defined")); |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
868 return; |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
869 } |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
870 |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
871 for (i = 0; i < dbg_breakp.ga_len; ++i) |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
872 { |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
873 bp = &BREAKP(i); |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
874 if (bp->dbg_type == DBG_FILE) |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
875 home_replace(NULL, bp->dbg_name, NameBuff, MAXPATHL, TRUE); |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
876 if (bp->dbg_type != DBG_EXPR) |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
877 smsg(_("%3d %s %s line %ld"), |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 bp->dbg_nr, |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 bp->dbg_type == DBG_FUNC ? "func" : "file", |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
880 bp->dbg_type == DBG_FUNC ? bp->dbg_name : NameBuff, |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
881 (long)bp->dbg_lnum); |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
882 else |
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
883 smsg(_("%3d expr %s"), |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 bp->dbg_nr, bp->dbg_name); |
31531
6e24001000ed
patch 9.0.1098: code uses too much indent
Bram Moolenaar <Bram@vim.org>
parents:
30355
diff
changeset
|
885 } |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
886 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
889 * Find a breakpoint for a function or sourced file. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 * Returns line number at which to break; zero when no matching breakpoint. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 linenr_T |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 dbg_find_breakpoint( |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
894 int file, // TRUE for a file, FALSE for a function |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
895 char_u *fname, // file or function name |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
896 linenr_T after) // after this line number |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 return debuggy_find(file, fname, after, &dbg_breakp, NULL); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
900 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 #if defined(FEAT_PROFILE) || defined(PROTO) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
903 * Return TRUE if profiling is on for a function or sourced file. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
904 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 int |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 has_profiling( |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
907 int file, // TRUE for a file, FALSE for a function |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
908 char_u *fname, // file or function name |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
909 int *fp) // return: forceit |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
910 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 return (debuggy_find(file, fname, (linenr_T)0, &prof_ga, fp) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 != (linenr_T)0); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 #endif |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 * Common code for dbg_find_breakpoint() and has_profiling(). |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 static linenr_T |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 debuggy_find( |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
921 int is_file, // TRUE for a file, FALSE for a function |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
922 char_u *fname, // file or function name |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
923 linenr_T after, // after this line number |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
924 garray_T *gap, // either &dbg_breakp or &prof_ga |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
925 int *fp) // if not NULL: return forceit |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
926 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
927 struct debuggy *bp; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 int i; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 linenr_T lnum = 0; |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
930 char_u *name = NULL; |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
931 char_u *short_name = fname; |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 int prev_got_int; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
934 // Return quickly when there are no breakpoints. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 if (gap->ga_len == 0) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 return (linenr_T)0; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
938 // For a script-local function remove the prefix, so that |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
939 // "profile func Func" matches "Func" in any script. Otherwise it's very |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
940 // difficult to profile/debug a script-local function. It may match a |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
941 // function in the wrong script, but that is much better than not being |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
942 // able to profile/debug a function in a script with unknown ID. |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
943 // Also match a script-specific name. |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
944 if (!is_file && fname[0] == K_SPECIAL) |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 { |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
946 short_name = vim_strchr(fname, '_') + 1; |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16391
diff
changeset
|
947 name = alloc(STRLEN(fname) + 3); |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
948 if (name != NULL) |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
950 STRCPY(name, "<SNR>"); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 STRCPY(name + 5, fname + 3); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
952 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
953 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
954 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
955 for (i = 0; i < gap->ga_len; ++i) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 { |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
957 // Skip entries that are not useful or are for a line that is beyond |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
958 // an already found breakpoint. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
959 bp = &DEBUGGY(gap, i); |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
960 if (((bp->dbg_type == DBG_FILE) == is_file |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
961 && bp->dbg_type != DBG_EXPR && ( |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 #ifdef FEAT_PROFILE |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
963 gap == &prof_ga || |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
964 #endif |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
965 (bp->dbg_lnum > after && (lnum == 0 || bp->dbg_lnum < lnum))))) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 { |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
967 // Save the value of got_int and reset it. We don't want a |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
968 // previous interruption cancel matching, only hitting CTRL-C |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
969 // while matching should abort it. |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 prev_got_int = got_int; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 got_int = FALSE; |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
972 if ((name != NULL |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
973 && vim_regexec_prog(&bp->dbg_prog, FALSE, name, (colnr_T)0)) |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
974 || vim_regexec_prog(&bp->dbg_prog, FALSE, |
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
975 short_name, (colnr_T)0)) |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
976 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 lnum = bp->dbg_lnum; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
978 if (fp != NULL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 *fp = bp->dbg_forceit; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
980 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
981 got_int |= prev_got_int; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
982 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
983 #ifdef FEAT_EVAL |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 else if (bp->dbg_type == DBG_EXPR) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
985 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
986 typval_T *tv; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
987 int line = FALSE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 |
25767
dfa045d2cc89
patch 8.2.3419: a failing debug expression may make Vim unusable
Bram Moolenaar <Bram@vim.org>
parents:
25763
diff
changeset
|
989 tv = eval_expr_no_emsg(bp); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 if (tv != NULL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 if (bp->dbg_val == NULL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 { |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
994 debug_oldval = typval_tostring(NULL, TRUE); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 bp->dbg_val = tv; |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
996 debug_newval = typval_tostring(bp->dbg_val, TRUE); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 line = TRUE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
998 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
999 else |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1000 { |
28023
146817021fc3
patch 8.2.4536: debugger test fails when breaking on expression
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
1001 // Use "==" instead of "is" for strings, that is what we |
146817021fc3
patch 8.2.4536: debugger test fails when breaking on expression
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
1002 // always have done. |
146817021fc3
patch 8.2.4536: debugger test fails when breaking on expression
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
1003 exprtype_T type = tv->v_type == VAR_STRING |
146817021fc3
patch 8.2.4536: debugger test fails when breaking on expression
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
1004 ? EXPR_EQUAL : EXPR_IS; |
146817021fc3
patch 8.2.4536: debugger test fails when breaking on expression
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
1005 |
146817021fc3
patch 8.2.4536: debugger test fails when breaking on expression
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
1006 if (typval_compare(tv, bp->dbg_val, type, FALSE) == OK |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1007 && tv->vval.v_number == FALSE) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1009 typval_T *v; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1010 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1011 line = TRUE; |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
1012 debug_oldval = typval_tostring(bp->dbg_val, TRUE); |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
1013 // Need to evaluate again, typval_compare() overwrites |
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
1014 // "tv". |
25767
dfa045d2cc89
patch 8.2.3419: a failing debug expression may make Vim unusable
Bram Moolenaar <Bram@vim.org>
parents:
25763
diff
changeset
|
1015 v = eval_expr_no_emsg(bp); |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
1016 debug_newval = typval_tostring(v, TRUE); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1017 free_tv(bp->dbg_val); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1018 bp->dbg_val = v; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1019 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1020 free_tv(tv); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1021 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1022 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1023 else if (bp->dbg_val != NULL) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1024 { |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
1025 debug_oldval = typval_tostring(bp->dbg_val, TRUE); |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
1026 debug_newval = typval_tostring(NULL, TRUE); |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1027 free_tv(bp->dbg_val); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 bp->dbg_val = NULL; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 line = TRUE; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1032 if (line) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 { |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1034 lnum = after > 0 ? after : 1; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1035 break; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1036 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1037 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1038 #endif |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 if (name != fname) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 vim_free(name); |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1043 return lnum; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1045 |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 /* |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1047 * Called when a breakpoint was encountered. |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 */ |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1049 void |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 dbg_breakpoint(char_u *name, linenr_T lnum) |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 { |
16391
3fc956fc63b6
patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
1052 // We need to check if this line is actually executed in do_one_cmd() |
16381
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 debug_breakpoint_name = name; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1054 debug_breakpoint_lnum = lnum; |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1055 } |
1dcbaa780b8e
patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1056 #endif |