summaryrefslogtreecommitdiff
path: root/gdb/top.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/top.c')
-rw-r--r--gdb/top.c87
1 files changed, 61 insertions, 26 deletions
diff --git a/gdb/top.c b/gdb/top.c
index 7c996499db7..15aa1c1930e 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -76,7 +76,7 @@ static char *readline_line_completion_function PARAMS ((char *, int));
/* NOTE 1999-04-29: this function will be static again, after we make the
event loop be the default command loop for gdb, and we merge
event-top.c into this file, top.c */
-/* static */ void command_loop_marker PARAMS ((int));
+/* static */ void command_loop_marker (void *);
static void while_command PARAMS ((char *, int));
@@ -101,7 +101,7 @@ static char *locate_arg PARAMS ((char *));
static char *insert_args PARAMS ((char *));
-static void arg_cleanup PARAMS ((void));
+static void arg_cleanup (void *);
static void init_main PARAMS ((void));
@@ -157,7 +157,9 @@ static void set_debug PARAMS ((char *, int));
static void disconnect PARAMS ((int));
#endif
-static void source_cleanup PARAMS ((FILE *));
+static void do_restore_instream_cleanup (void *stream);
+
+static struct cleanup *make_cleanup_free_command_lines (struct command_line **);
/* Default command line prompt. This is overriden in some configs. */
@@ -760,8 +762,7 @@ static int source_error_allocated;
user-defined command). */
static void
-source_cleanup (stream)
- FILE *stream;
+do_restore_instream_cleanup (void *stream)
{
/* Restore the previous input stream. */
instream = stream;
@@ -774,7 +775,7 @@ read_command_file (stream)
{
struct cleanup *cleanups;
- cleanups = make_cleanup ((make_cleanup_func) source_cleanup, instream);
+ cleanups = make_cleanup (do_restore_instream_cleanup, instream);
instream = stream;
command_loop ();
do_cleanups (cleanups);
@@ -784,6 +785,15 @@ extern void init_proc PARAMS ((void));
void (*pre_init_ui_hook) PARAMS ((void));
+#ifdef __MSDOS__
+void
+do_chdir_cleanup (void *old_dir)
+{
+ chdir (old_dir);
+ free (old_dir);
+}
+#endif
+
void
gdb_init (argv0)
char *argv0;
@@ -799,7 +809,7 @@ gdb_init (argv0)
#ifdef __MSDOS__
/* Make sure we return to the original directory upon exit, come
what may, since the OS doesn't do that for us. */
- make_final_cleanup ((make_cleanup_func) chdir, strsave (current_directory));
+ make_final_cleanup (do_chdir_cleanup, xstrdup (current_directory));
#endif
init_cmd_lists (); /* This needs to be done first */
@@ -884,7 +894,7 @@ get_command_line (type, arg)
/* Allocate and build a new command line structure. */
cmd = build_command_line (type, arg);
- old_chain = make_cleanup ((make_cleanup_func) free_command_lines, &cmd);
+ old_chain = make_cleanup_free_command_lines (&cmd);
/* Read in the body of this command. */
if (recurse_read_control_structure (cmd) == invalid_control)
@@ -1094,8 +1104,7 @@ execute_control_command (cmd)
new_line = insert_args (cmd->line);
if (!new_line)
return invalid_control;
- old_chain = make_cleanup ((make_cleanup_func) free_current_contents,
- &new_line);
+ old_chain = make_cleanup (free_current_contents, &new_line);
execute_command (new_line, 0);
ret = cmd->control_type;
break;
@@ -1113,10 +1122,9 @@ execute_control_command (cmd)
new_line = insert_args (cmd->line);
if (!new_line)
return invalid_control;
- old_chain = make_cleanup ((make_cleanup_func) free_current_contents,
- &new_line);
+ old_chain = make_cleanup (free_current_contents, &new_line);
expr = parse_expression (new_line);
- make_cleanup ((make_cleanup_func) free_current_contents, &expr);
+ make_cleanup (free_current_contents, &expr);
ret = simple_control;
loop = 1;
@@ -1174,11 +1182,10 @@ execute_control_command (cmd)
new_line = insert_args (cmd->line);
if (!new_line)
return invalid_control;
- old_chain = make_cleanup ((make_cleanup_func) free_current_contents,
- &new_line);
+ old_chain = make_cleanup (free_current_contents, &new_line);
/* Parse the conditional for the if statement. */
expr = parse_expression (new_line);
- make_cleanup ((make_cleanup_func) free_current_contents, &expr);
+ make_cleanup (free_current_contents, &expr);
current = NULL;
ret = simple_control;
@@ -1264,7 +1271,7 @@ if_command (arg, from_tty)
/* Cleanup */
static void
-arg_cleanup ()
+arg_cleanup (void *ignore)
{
struct user_args *oargs = user_args;
if (!user_args)
@@ -1291,7 +1298,7 @@ setup_user_args (p)
args->next = user_args;
user_args = args;
- old_chain = make_cleanup ((make_cleanup_func) arg_cleanup, 0);
+ old_chain = make_cleanup (arg_cleanup, 0/*ignored*/);
if (p == NULL)
return old_chain;
@@ -1455,7 +1462,7 @@ execute_user_command (c, args)
/* Set the instream to 0, indicating execution of a
user-defined function. */
- old_chain = make_cleanup ((make_cleanup_func) source_cleanup, instream);
+ old_chain = make_cleanup (do_restore_instream_cleanup, instream);
instream = (FILE *) 0;
while (cmdlines)
{
@@ -1580,8 +1587,7 @@ execute_command (p, from_tty)
gdb to use the event loop as the default command loop and we merge
event-top.c into this file, top.c */
/* static */ void
-command_loop_marker (foo)
- int foo;
+command_loop_marker (void *foo)
{
}
@@ -1612,7 +1618,7 @@ command_loop ()
quit_flag = 0;
if (instream == stdin && stdin_is_tty)
reinitialize_more_filter ();
- old_chain = make_cleanup ((make_cleanup_func) command_loop_marker, 0);
+ old_chain = make_cleanup (command_loop_marker, 0);
#if defined(TUI)
/* A bit of paranoia: I want to make sure the "insert_mode" global
@@ -1693,7 +1699,7 @@ simplified_command_loop (read_input_func, execute_command_func)
quit_flag = 0;
if (instream == stdin && stdin_is_tty)
reinitialize_more_filter ();
- old_chain = make_cleanup ((make_cleanup_func) command_loop_marker, 0);
+ old_chain = make_cleanup (command_loop_marker, 0);
/* Get a command-line. */
command = (*read_input_func) (instream == stdin ?
@@ -1833,6 +1839,12 @@ char *gdb_completer_word_break_characters =
char *gdb_completer_command_word_break_characters =
" \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,";
+/* When completing on file names, we remove from the list of word
+ break characters any characters that are commonly used in file
+ names, such as '-', '+', '~', etc. Otherwise, readline displays
+ incorrect completion candidates. */
+char *gdb_completer_file_name_break_characters = " \t\n*|\"';:?/><";
+
/* Characters that can be used to quote completion strings. Note that we
can't include '"' because the gdb C parser treats such quoted sequences
as strings. */
@@ -2122,6 +2134,9 @@ line_completion_function (text, matches, line_buffer, point)
/* It is a normal command; what comes after it is
completed by the command's completer function. */
list = (*c->completer) (p, word);
+ if (c->completer == filename_completer)
+ rl_completer_word_break_characters =
+ gdb_completer_file_name_break_characters;
}
}
else
@@ -2168,6 +2183,9 @@ line_completion_function (text, matches, line_buffer, point)
{
/* It is a normal command. */
list = (*c->completer) (p, word);
+ if (c->completer == filename_completer)
+ rl_completer_word_break_characters =
+ gdb_completer_file_name_break_characters;
}
}
}
@@ -2855,8 +2873,7 @@ read_command_lines (prompt_arg, from_tty)
else
{
head = next;
- old_chain = make_cleanup ((make_cleanup_func) free_command_lines,
- &head);
+ old_chain = make_cleanup_free_command_lines (&head);
}
tail = next;
}
@@ -2905,6 +2922,18 @@ free_command_lines (lptr)
l = next;
}
}
+
+static void
+do_free_command_lines_cleanup (void *arg)
+{
+ free_command_lines (arg);
+}
+
+static struct cleanup *
+make_cleanup_free_command_lines (struct command_line **arg)
+{
+ return make_cleanup (do_free_command_lines_cleanup, arg);
+}
/* Add an element to the list of info subcommands. */
@@ -3739,6 +3768,12 @@ source_cleanup_lines (args)
}
/* ARGSUSED */
+static void
+do_fclose_cleanup (void *stream)
+{
+ fclose (stream);
+}
+
void
source_command (args, from_tty)
char *args;
@@ -3767,7 +3802,7 @@ source_command (args, from_tty)
return;
}
- make_cleanup ((make_cleanup_func) fclose, stream);
+ make_cleanup (do_fclose_cleanup, stream);
old_lines.old_line = source_line_number;
old_lines.old_file = source_file_name;