Newer
Older
*
* VIM - Vi IMproved by Bram Moolenaar
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
/*
* ex_cmds2.c: some more functions for command line commands
*/
#include "vim.h"
#include "version.h"
/* Growarray to store info about already sourced scripts.
* For Unix also store the dev/ino, so that we don't have to stat() each
* script when going through the list. */
typedef struct scriptitem_S
{
char_u *sn_name;
# ifdef UNIX
ino_t sn_ino;
# endif
# ifdef FEAT_PROFILE
int sn_prof_on; /* TRUE when script is/was profiled */
int sn_pr_force; /* forceit: profile functions in this script */
proftime_T sn_pr_child; /* time set when going into first child */
int sn_pr_nest; /* nesting for sn_pr_child */
/* profiling the script as a whole */
int sn_pr_count; /* nr of times sourced */
proftime_T sn_pr_total; /* time spent in script + children */
proftime_T sn_pr_self; /* time spent in script itself */
proftime_T sn_pr_start; /* time at script start */
proftime_T sn_pr_children; /* time in children after script start */
/* profiling the script per line */
garray_T sn_prl_ga; /* things stored for every line */
proftime_T sn_prl_start; /* start time for current line */
proftime_T sn_prl_children; /* time spent in children for this line */
proftime_T sn_prl_wait; /* wait start time for current line */
int sn_prl_idx; /* index of line being timed; -1 if none */
int sn_prl_execed; /* line being timed was executed */
# endif
} scriptitem_T;
static garray_T script_items = {0, 0, sizeof(scriptitem_T), 4, NULL};
#define SCRIPT_ITEM(id) (((scriptitem_T *)script_items.ga_data)[(id) - 1])
# ifdef FEAT_PROFILE
/* Struct used in sn_prl_ga for every line of a script. */
typedef struct sn_prl_S
{
int snp_count; /* nr of times line was executed */
proftime_T sn_prl_total; /* time spent in a line + children */
proftime_T sn_prl_self; /* time spent in a line itself */
} sn_prl_T;
# define PRL_ITEM(si, idx) (((sn_prl_T *)(si)->sn_prl_ga.ga_data)[(idx)])
# endif
#endif
#if defined(FEAT_EVAL) || defined(PROTO)
static int debug_greedy = FALSE; /* batch mode debugging: don't save
and restore typeahead. */
static int get_maxbacktrace_level(void);
static void do_setdebugtracelevel(char_u *arg);
static void do_checkbacktracelevel(void);
static void do_showbacktrace(char_u *cmd);
static char_u *debug_oldval = NULL; /* old and newval for debug expressions */
static char_u *debug_newval = NULL;
static int debug_expr = 0; /* use debug_expr */
int
has_watchexpr(void)
{
return debug_expr;
}
/*
* do_debug(): Debug mode.
* Repeatedly get Ex commands, until told to continue normal execution.
*/
void
{
int save_msg_scroll = msg_scroll;
int save_State = State;
int save_did_emsg = did_emsg;
int save_cmd_silent = cmd_silent;
int save_msg_silent = msg_silent;
int save_emsg_silent = emsg_silent;
int save_redir_off = redir_off;
tasave_T typeaheadbuf;
int save_ex_normal_busy;
int n;
char_u *cmdline = NULL;
char_u *p;
char *tail = NULL;
static int last_cmd = 0;
#define CMD_CONT 1
#define CMD_NEXT 2
#define CMD_STEP 3
#define CMD_FINISH 4
#define CMD_QUIT 5
#define CMD_INTERRUPT 6
#define CMD_BACKTRACE 7
#define CMD_FRAME 8
#define CMD_UP 9
#define CMD_DOWN 10
#ifdef ALWAYS_USE_GUI
/* Can't do this when there is no terminal for input/output. */
if (!gui.in_use)
{
/* Break as soon as possible. */
debug_break_level = 9999;
return;
}
#endif
/* Make sure we are in raw mode and start termcap mode. Might have side
* effects... */
settmode(TMODE_RAW);
starttermcap();
++RedrawingDisabled; /* don't redisplay the window */
++no_wait_return; /* don't wait for return */
did_emsg = FALSE; /* don't use error from debugged stuff */
cmd_silent = FALSE; /* display commands */
msg_silent = FALSE; /* display messages */
emsg_silent = FALSE; /* display error messages */
redir_off = TRUE; /* don't redirect debug commands */
State = NORMAL;
debug_mode = TRUE;
if (!debug_did_msg)
MSG(_("Entering Debug mode. Type \"cont\" to continue."));
if (debug_oldval != NULL)
{
smsg((char_u *)_("Oldval = \"%s\""), debug_oldval);
vim_free(debug_oldval);
debug_oldval = NULL;
}
if (debug_newval != NULL)
{
smsg((char_u *)_("Newval = \"%s\""), debug_newval);
vim_free(debug_newval);
debug_newval = NULL;
}
if (sourcing_name != NULL)
msg(sourcing_name);
if (sourcing_lnum != 0)
smsg((char_u *)_("line %ld: %s"), (long)sourcing_lnum, cmd);
/*
* Repeat getting a command and executing it.
*/
for (;;)
{
msg_scroll = TRUE;
need_wait_return = FALSE;
/* Save the current typeahead buffer and replace it with an empty one.
* This makes sure we get input from the user here and don't interfere
* with the commands being executed. Reset "ex_normal_busy" to avoid
* the side effects of using ":normal". Save the stuff buffer and make
* it empty. Set ignore_script to avoid reading from script input. */
save_ex_normal_busy = ex_normal_busy;
ex_normal_busy = 0;
if (!debug_greedy)
typeahead_saved = TRUE;
save_ignore_script = ignore_script;
ignore_script = TRUE;
}
cmdline = getcmdline_prompt('>', NULL, 0, EXPAND_NOTHING, NULL);
ex_normal_busy = save_ex_normal_busy;
cmdline_row = msg_row;
Loading
Loading full blame...