annotate src/debugger.c @ 18150:0ec6521e9d80 v8.1.2070

patch 8.1.2070: mouse code is spread out Commit: https://github.com/vim/vim/commit/b8ff5c271ee5dcef6f63436b77e228e062ff9a0e Author: Bram Moolenaar <Bram@vim.org> Date: Mon Sep 23 21:16:54 2019 +0200 patch 8.1.2070: mouse code is spread out Problem: Mouse code is spread out. Solution: Move mouse terminal code parsing to mouse.c. (Yegappan Lakshmanan, closes #4966)
author Bram Moolenaar <Bram@vim.org>
date Mon, 23 Sep 2019 21:30:04 +0200
parents ef00b6bc186b
children 6bd715870e32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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;
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
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;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 char *tail = NULL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 static int last_cmd = 0;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 #define CMD_CONT 1
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 #define CMD_NEXT 2
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 #define CMD_STEP 3
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 #define CMD_FINISH 4
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 #define CMD_QUIT 5
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 #define CMD_INTERRUPT 6
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 #define CMD_BACKTRACE 7
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 #define CMD_FRAME 8
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 #define CMD_UP 9
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 #define CMD_DOWN 10
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 #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
68 // 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
69 if (!gui.in_use)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
71 // 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
72 debug_break_level = 9999;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 return;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 #endif
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
77 // 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
78 // effects...
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 settmode(TMODE_RAW);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 starttermcap();
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
82 ++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
83 ++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
84 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
85 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
86 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
87 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
88 redir_off = TRUE; // don't redirect debug commands
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 State = NORMAL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 debug_mode = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 if (!debug_did_msg)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 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
95 if (debug_oldval != NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 smsg(_("Oldval = \"%s\""), debug_oldval);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 vim_free(debug_oldval);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 debug_oldval = NULL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 if (debug_newval != NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 smsg(_("Newval = \"%s\""), debug_newval);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 vim_free(debug_newval);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 debug_newval = NULL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 if (sourcing_name != NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 msg((char *)sourcing_name);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 if (sourcing_lnum != 0)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 smsg(_("line %ld: %s"), (long)sourcing_lnum, cmd);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 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
113
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
114 // 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
115 for (;;)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 msg_scroll = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 need_wait_return = FALSE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
120 // 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
121 // 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
122 // 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
123 // 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
124 // 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
125 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
126 ex_normal_busy = 0;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 if (!debug_greedy)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 save_typeahead(&typeaheadbuf);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 typeahead_saved = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 save_ignore_script = ignore_script;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 ignore_script = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 vim_free(cmdline);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 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
137
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 if (typeahead_saved)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 restore_typeahead(&typeaheadbuf);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 ignore_script = save_ignore_script;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 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
144
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 cmdline_row = msg_row;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 msg_starthere();
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 if (cmdline != NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
149 // 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
150 // 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
151 // 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
152 p = skipwhite(cmdline);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 if (*p != NUL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 switch (*p)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 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
158 tail = "ont";
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 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
161 tail = "ext";
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 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
164 tail = "tep";
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 case 'f':
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 last_cmd = 0;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 if (p[1] == 'r')
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 last_cmd = CMD_FRAME;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 tail = "rame";
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 last_cmd = CMD_FINISH;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 tail = "inish";
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 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
180 tail = "uit";
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 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
183 tail = "nterrupt";
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 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
186 if (p[1] == 't')
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 tail = "t";
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 tail = "acktrace";
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 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
192 tail = "here";
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 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
195 tail = "p";
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 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
198 tail = "own";
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 default: last_cmd = 0;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 if (last_cmd != 0)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
204 // 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
205 ++p;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 while (*p != NUL && *p == *tail)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 ++p;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 ++tail;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 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
212 last_cmd = 0;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 }
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
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 if (last_cmd != 0)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
218 // Execute debug command: decided where to break next and
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
219 // return.
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 switch (last_cmd)
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 case CMD_CONT:
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 debug_break_level = -1;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 case CMD_NEXT:
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 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
227 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 case CMD_STEP:
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 debug_break_level = 9999;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 case CMD_FINISH:
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 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
233 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 case CMD_QUIT:
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 got_int = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 debug_break_level = -1;
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_INTERRUPT:
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 got_int = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 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
241 // 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
242 last_cmd = CMD_STEP;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 case CMD_BACKTRACE:
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 do_showbacktrace(cmd);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 continue;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 case CMD_FRAME:
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 if (*p == NUL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 do_showbacktrace(cmd);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 p = skipwhite(p);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 do_setdebugtracelevel(p);
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 continue;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 case CMD_UP:
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 debug_backtrace_level++;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 do_checkbacktracelevel();
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 continue;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 case CMD_DOWN:
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 debug_backtrace_level--;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 do_checkbacktracelevel();
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 continue;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 }
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
267 // 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
268 debug_backtrace_level = 0;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
272 // 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
273 n = debug_break_level;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 debug_break_level = -1;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 (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
276 DOCMD_VERBOSE|DOCMD_EXCRESET);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 debug_break_level = n;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 lines_left = Rows - 1;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 vim_free(cmdline);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 --RedrawingDisabled;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 --no_wait_return;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 redraw_all_later(NOT_VALID);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 need_wait_return = FALSE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 msg_scroll = save_msg_scroll;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 lines_left = Rows - 1;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 State = save_State;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 debug_mode = FALSE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 did_emsg = save_did_emsg;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 cmd_silent = save_cmd_silent;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 msg_silent = save_msg_silent;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 emsg_silent = save_emsg_silent;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 redir_off = save_redir_off;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
297 // 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
298 // here.
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299 debug_did_msg = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302 static int
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303 get_maxbacktrace_level(void)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 char *p, *q;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 int maxbacktrace = 0;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 if (sourcing_name != NULL)
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 p = (char *)sourcing_name;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 while ((q = strstr(p, "..")) != NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 p = q + 2;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314 maxbacktrace++;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 return maxbacktrace;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 static void
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 do_setdebugtracelevel(char_u *arg)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 int level;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 level = atoi((char *)arg);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 if (*arg == '+' || level < 0)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 debug_backtrace_level += level;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 debug_backtrace_level = level;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 do_checkbacktracelevel();
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332 }
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 static void
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335 do_checkbacktracelevel(void)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 if (debug_backtrace_level < 0)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 debug_backtrace_level = 0;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340 msg(_("frame is zero"));
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 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 int max = get_maxbacktrace_level();
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 > max)
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 = max;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349 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
350 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 static void
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 do_showbacktrace(char_u *cmd)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 char *cur;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358 char *next;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 int i = 0;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360 int max = get_maxbacktrace_level();
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362 if (sourcing_name != NULL)
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 cur = (char *)sourcing_name;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 while (!got_int)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 next = strstr(cur, "..");
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 if (next != NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 *next = NUL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 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
371 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
372 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 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
374 ++i;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 if (next == NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377 *next = '.';
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378 cur = next + 2;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 }
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 if (sourcing_lnum != 0)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 smsg(_("line %ld: %s"), (long)sourcing_lnum, cmd);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 smsg(_("cmd: %s"), cmd);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 /*
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 * ":debug".
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 */
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 void
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 ex_debug(exarg_T *eap)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 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
394
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 debug_break_level = 9999;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 do_cmdline_cmd(eap->arg);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 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
398 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 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
401 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
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 * 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
405 * 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
406 * 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
407 * 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
408 * 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
409 */
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 static int debug_skipped;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 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
412
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 /*
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 * 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
415 * 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
416 * 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
417 * decide to execute something themselves.
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 * 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
419 */
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 void
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 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
422 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 char_u *p;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 debug_skipped = FALSE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 if (debug_breakpoint_name != NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 if (!eap->skip)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
430 // 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
431 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
432 && debug_breakpoint_name[1] == KS_EXTRA
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 && debug_breakpoint_name[2] == (int)KE_SNR)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434 p = (char_u *)"<SNR>";
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 p = (char_u *)"";
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 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
438 p,
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 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
440 (long)debug_breakpoint_lnum);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 debug_breakpoint_name = NULL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 do_debug(eap->cmd);
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 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 debug_skipped = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 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
448 debug_breakpoint_name = NULL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451 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
452 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 if (!eap->skip)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 do_debug(eap->cmd);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 debug_skipped = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 debug_skipped_name = NULL;
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 }
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
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 /*
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 * 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
465 * 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
466 */
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 int
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468 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
469 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 int prev_got_int;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 if (debug_skipped)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
474 // Save the value of got_int and reset it. We don't want a previous
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
475 // interruption cause flushing the input buffer.
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 prev_got_int = got_int;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 got_int = FALSE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 debug_breakpoint_name = debug_skipped_name;
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
479 // eap->skip is TRUE
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 eap->skip = FALSE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 (void)dbg_check_breakpoint(eap);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 eap->skip = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 got_int |= prev_got_int;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 return TRUE;
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 return FALSE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 /*
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 * 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
491 * 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
492 */
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 struct debuggy
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
495 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
496 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
497 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
498 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
499 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
500 int dbg_forceit; // ! used
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 #ifdef FEAT_EVAL
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
502 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
503 #endif
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
504 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
505 };
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 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
508 #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
509 #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
510 static int last_breakp = 0; // nr of last defined breakpoint
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 #ifdef FEAT_PROFILE
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
513 // 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
514 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
515 #endif
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 #define DBG_FUNC 1
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 #define DBG_FILE 2
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 #define DBG_EXPR 3
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 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
521
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
522 /*
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523 * 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
524 * 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
525 * is allocated.
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 * Returns FAIL for failure.
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 static int
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 dbg_parsearg(
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 char_u *arg,
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
531 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
532 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
533 char_u *p = arg;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 char_u *q;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
535 struct debuggy *bp;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536 int here = FALSE;
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 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
539 return FAIL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540 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
541
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
542 // Find "func" or "file".
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 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
544 bp->dbg_type = DBG_FUNC;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
545 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
546 bp->dbg_type = DBG_FILE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547 else if (
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
548 #ifdef FEAT_PROFILE
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549 gap != &prof_ga &&
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
550 #endif
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551 STRNCMP(p, "here", 4) == 0)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553 if (curbuf->b_ffname == NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
554 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555 emsg(_(e_noname));
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 return FAIL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
557 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 bp->dbg_type = DBG_FILE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559 here = TRUE;
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 else if (
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
562 #ifdef FEAT_PROFILE
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563 gap != &prof_ga &&
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 #endif
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565 STRNCMP(p, "expr", 4) == 0)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566 bp->dbg_type = DBG_EXPR;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
568 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
569 semsg(_(e_invarg2), p);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570 return FAIL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572 p = skipwhite(p + 4);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
574 // Find optional line number.
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
575 if (here)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
576 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
577 else if (
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
578 #ifdef FEAT_PROFILE
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
579 gap != &prof_ga &&
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
580 #endif
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581 VIM_ISDIGIT(*p))
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
582 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
583 bp->dbg_lnum = getdigits(&p);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584 p = skipwhite(p);
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 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 bp->dbg_lnum = 0;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
589 // 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
590 if ((!here && *p == NUL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 || (here && *p != NUL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 || (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
593 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594 semsg(_(e_invarg2), arg);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595 return FAIL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
597
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598 if (bp->dbg_type == DBG_FUNC)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599 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
600 else if (here)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
601 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
602 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
603 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
604 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
605 if (bp->dbg_name != NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
606 bp->dbg_val = eval_expr(bp->dbg_name, NULL);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
607 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
609 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
610 // 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
611 // 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
612 // "~/dir".
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613 q = expand_env_save(p);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
614 if (q == NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
615 return FAIL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
616 p = expand_env_save(q);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
617 vim_free(q);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
618 if (p == NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
619 return FAIL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
620 if (*p != '*')
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
621 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
622 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
623 vim_free(p);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
624 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
625 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
626 bp->dbg_name = p;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
627 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
628
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
629 if (bp->dbg_name == NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
630 return FAIL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
631 return OK;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
632 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
633
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 /*
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
635 * ":breakadd". Also used for ":profile".
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 void
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
638 ex_breakadd(exarg_T *eap)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
639 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
640 struct debuggy *bp;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
641 char_u *pat;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
642 garray_T *gap;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
643
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
644 gap = &dbg_breakp;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
645 #ifdef FEAT_PROFILE
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
646 if (eap->cmdidx == CMD_profile)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
647 gap = &prof_ga;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
648 #endif
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
649
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
650 if (dbg_parsearg(eap->arg, gap) == OK)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
651 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
652 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
653 bp->dbg_forceit = eap->forceit;
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 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
656 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
657 pat = file_pat_to_reg_pat(bp->dbg_name, NULL, NULL, FALSE);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
658 if (pat != NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
659 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
660 bp->dbg_prog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661 vim_free(pat);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
663 if (pat == NULL || bp->dbg_prog == NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
664 vim_free(bp->dbg_name);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
665 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
666 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
667 if (bp->dbg_lnum == 0) // default line number is 1
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
668 bp->dbg_lnum = 1;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
669 #ifdef FEAT_PROFILE
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
670 if (eap->cmdidx != CMD_profile)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671 #endif
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 DEBUGGY(gap, gap->ga_len).dbg_nr = ++last_breakp;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674 ++debug_tick;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
676 ++gap->ga_len;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
677 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
678 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
680 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
681 // DBG_EXPR
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
682 DEBUGGY(gap, gap->ga_len++).dbg_nr = ++last_breakp;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
683 ++debug_tick;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
684 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
685 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
686 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
687
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
688 /*
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
689 * ":debuggreedy".
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
690 */
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
691 void
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
692 ex_debuggreedy(exarg_T *eap)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
693 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
694 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
695 debug_greedy = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
696 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
697 debug_greedy = FALSE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
698 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
699
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
700 /*
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
701 * ":breakdel" and ":profdel".
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
702 */
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
703 void
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
704 ex_breakdel(exarg_T *eap)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
705 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
706 struct debuggy *bp, *bpi;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
707 int nr;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
708 int todel = -1;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
709 int del_all = FALSE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
710 int i;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
711 linenr_T best_lnum = 0;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
712 garray_T *gap;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
713
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
714 gap = &dbg_breakp;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
715 if (eap->cmdidx == CMD_profdel)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
716 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
717 #ifdef FEAT_PROFILE
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
718 gap = &prof_ga;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
719 #else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
720 ex_ni(eap);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
721 return;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
722 #endif
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
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725 if (vim_isdigit(*eap->arg))
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
727 // ":breakdel {nr}"
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728 nr = atol((char *)eap->arg);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
729 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
730 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
731 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
732 todel = i;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
733 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
734 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
735 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
736 else if (*eap->arg == '*')
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
737 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
738 todel = 0;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
739 del_all = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
740 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
741 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
742 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
743 // ":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
744 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
745 return;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
746 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
747 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
748 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
749 bpi = &DEBUGGY(gap, i);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
750 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
751 && 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
752 && (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
753 || (bp->dbg_lnum == 0
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
754 && (best_lnum == 0
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
755 || bpi->dbg_lnum < best_lnum))))
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
756 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
757 todel = i;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
758 best_lnum = bpi->dbg_lnum;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
759 }
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 vim_free(bp->dbg_name);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
762 }
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 if (todel < 0)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765 semsg(_("E161: Breakpoint not found: %s"), eap->arg);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
766 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
767 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
768 while (gap->ga_len > 0)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
769 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
770 vim_free(DEBUGGY(gap, todel).dbg_name);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
771 #ifdef FEAT_EVAL
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
772 if (DEBUGGY(gap, todel).dbg_type == DBG_EXPR
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
773 && DEBUGGY(gap, todel).dbg_val != NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
774 free_tv(DEBUGGY(gap, todel).dbg_val);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
775 #endif
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
776 vim_regfree(DEBUGGY(gap, todel).dbg_prog);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
777 --gap->ga_len;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
778 if (todel < gap->ga_len)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
779 mch_memmove(&DEBUGGY(gap, todel), &DEBUGGY(gap, todel + 1),
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
780 (gap->ga_len - todel) * sizeof(struct debuggy));
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 #ifdef FEAT_PROFILE
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782 if (eap->cmdidx == CMD_breakdel)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
783 #endif
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
784 ++debug_tick;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
785 if (!del_all)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
786 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
787 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
788
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
789 // If all breakpoints were removed clear the array.
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
790 if (gap->ga_len == 0)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
791 ga_clear(gap);
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
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 * ":breaklist".
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
797 */
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
798 void
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
799 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
800 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
801 struct debuggy *bp;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
802 int i;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
803
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
804 if (dbg_breakp.ga_len == 0)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
805 msg(_("No breakpoints defined"));
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
806 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
807 for (i = 0; i < dbg_breakp.ga_len; ++i)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
808 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
809 bp = &BREAKP(i);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
810 if (bp->dbg_type == DBG_FILE)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
811 home_replace(NULL, bp->dbg_name, NameBuff, MAXPATHL, TRUE);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
812 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
813 smsg(_("%3d %s %s line %ld"),
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
814 bp->dbg_nr,
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
815 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
816 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
817 (long)bp->dbg_lnum);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
818 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
819 smsg(_("%3d expr %s"),
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
820 bp->dbg_nr, bp->dbg_name);
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 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
823
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
824 /*
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
825 * 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
826 * 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
827 */
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
828 linenr_T
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
829 dbg_find_breakpoint(
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
830 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
831 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
832 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
833 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
834 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
835 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
836
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
837 #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
838 /*
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
839 * 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
840 */
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
841 int
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
842 has_profiling(
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
843 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
844 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
845 int *fp) // return: forceit
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
846 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
847 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
848 != (linenr_T)0);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
849 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
850 #endif
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
851
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
852 /*
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
853 * 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
854 */
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
855 static linenr_T
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
856 debuggy_find(
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
857 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
858 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
859 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
860 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
861 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
862 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
863 struct debuggy *bp;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
864 int i;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
865 linenr_T lnum = 0;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
866 char_u *name = fname;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
867 int prev_got_int;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
868
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
869 // 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
870 if (gap->ga_len == 0)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
871 return (linenr_T)0;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
872
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
873 // Replace K_SNR in function name with "<SNR>".
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
874 if (!file && fname[0] == K_SPECIAL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
875 {
16764
ef00b6bc186b patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 16391
diff changeset
876 name = alloc(STRLEN(fname) + 3);
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
877 if (name == NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
878 name = fname;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
879 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
880 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
881 STRCPY(name, "<SNR>");
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
882 STRCPY(name + 5, fname + 3);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
883 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
884 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
885
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886 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
887 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
888 // 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
889 // an already found breakpoint.
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
890 bp = &DEBUGGY(gap, i);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
891 if (((bp->dbg_type == DBG_FILE) == file &&
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
892 bp->dbg_type != DBG_EXPR && (
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
893 #ifdef FEAT_PROFILE
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
894 gap == &prof_ga ||
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
895 #endif
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
896 (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
897 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
898 // 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
899 // 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
900 // 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
901 prev_got_int = got_int;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
902 got_int = FALSE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
903 if (vim_regexec_prog(&bp->dbg_prog, FALSE, name, (colnr_T)0))
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 lnum = bp->dbg_lnum;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
906 if (fp != NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
907 *fp = bp->dbg_forceit;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
908 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
909 got_int |= prev_got_int;
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 #ifdef FEAT_EVAL
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
912 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
913 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
914 typval_T *tv;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
915 int line = FALSE;
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 prev_got_int = got_int;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
918 got_int = FALSE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
919
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
920 tv = eval_expr(bp->dbg_name, NULL);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
921 if (tv != NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
923 if (bp->dbg_val == NULL)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
924 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
925 debug_oldval = typval_tostring(NULL);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
926 bp->dbg_val = tv;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
927 debug_newval = typval_tostring(bp->dbg_val);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
928 line = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
929 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
930 else
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
931 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
932 if (typval_compare(tv, bp->dbg_val, TYPE_EQUAL,
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
933 TRUE, FALSE) == OK
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
934 && tv->vval.v_number == FALSE)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
935 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
936 typval_T *v;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
937
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
938 line = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
939 debug_oldval = typval_tostring(bp->dbg_val);
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
940 // 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
941 // "tv".
16381
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
942 v = eval_expr(bp->dbg_name, NULL);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
943 debug_newval = typval_tostring(v);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
944 free_tv(bp->dbg_val);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
945 bp->dbg_val = v;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
946 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
947 free_tv(tv);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
948 }
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 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
951 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
952 debug_oldval = typval_tostring(bp->dbg_val);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
953 debug_newval = typval_tostring(NULL);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
954 free_tv(bp->dbg_val);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
955 bp->dbg_val = NULL;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
956 line = TRUE;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
957 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
958
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
959 if (line)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
960 {
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
961 lnum = after > 0 ? after : 1;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
962 break;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
963 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
964
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
965 got_int |= prev_got_int;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
966 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
967 #endif
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
968 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
969 if (name != fname)
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
970 vim_free(name);
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
971
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
972 return lnum;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
973 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
974
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
975 /*
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
976 * 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
977 */
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
978 void
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
979 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
980 {
16391
3fc956fc63b6 patch 8.1.1200: old style comments in debugger source
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
981 // 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
982 debug_breakpoint_name = name;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
983 debug_breakpoint_lnum = lnum;
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
984 }
1dcbaa780b8e patch 8.1.1195: Vim script debugger functionality needs cleanup
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
985 #endif