This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
[patch] remove make_cleanup_func from top.c.
- To: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- Subject: [patch] remove make_cleanup_func from top.c.
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Mon, 22 May 2000 15:41:37 +1000
- Organization: Cygnus Solutions
Just FYI,
Andrew
Mon May 22 15:21:38 2000 Andrew Cagney <cagney@b1.cygnus.com>
* top.h (command_loop_marker): Change signature to match
make_cleanup_ftype.
* top.c (command_loop_marker): Update.
(command_loop, simplified_command_loop), event-top.c
(command_handler): Remove cast using make_cleanup_func.
* event-top.c (command_handler): Ditto.
* top.c (do_chdir_cleanup): New function.
(gdb_init): Use. Use xstrdup instead of strsave.
* top.c (do_fclose_cleanup): New function.
(source_command): Use.
* top.c (do_restore_instream_cleanup): Rename
source_cleanup. Change signature to match make_cleanup.
(read_command_filem execute_user_command): Update. Remove cast
using make_cleanup_func.
* top.c (do_free_command_lines_cleanup,
make_cleanup_free_command_lines): New funtions.
(get_command_line, read_command_lines): Use.
* top.c (arg_cleanup): Change signature to match make_cleanup.
(setup_user_args): Remove cast using make_cleanup_func.
Index: event-top.c
===================================================================
RCS file: /cvs/src/src/gdb/event-top.c,v
retrieving revision 1.5
diff -p -r1.5 event-top.c
*** event-top.c 2000/03/30 18:54:28 1.5
--- event-top.c 2000/05/22 05:38:52
*************** command_handler (char *command)
*** 487,493 ****
quit_flag = 0;
if (instream == stdin && stdin_is_tty)
reinitialize_more_filter ();
! old_chain = make_cleanup ((make_cleanup_func) command_loop_marker, 0);
#if defined(TUI)
insert_mode = 0;
--- 487,493 ----
quit_flag = 0;
if (instream == stdin && stdin_is_tty)
reinitialize_more_filter ();
! old_chain = make_cleanup (command_loop_marker, 0);
#if defined(TUI)
insert_mode = 0;
Index: top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.11
diff -p -r1.11 top.c
*** top.c 2000/04/26 12:41:48 1.11
--- top.c 2000/05/22 05:39:04
*************** static char *readline_line_completion_fu
*** 76,82 ****
/* 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 while_command PARAMS ((char *, int));
--- 76,82 ----
/* 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 (void *);
static void while_command PARAMS ((char *, int));
*************** static char *locate_arg PARAMS ((char *)
*** 101,107 ****
static char *insert_args PARAMS ((char *));
! static void arg_cleanup PARAMS ((void));
static void init_main PARAMS ((void));
--- 101,107 ----
static char *insert_args PARAMS ((char *));
! static void arg_cleanup (void *);
static void init_main PARAMS ((void));
*************** static void set_debug PARAMS ((char *, i
*** 157,164 ****
static void disconnect PARAMS ((int));
#endif
! static void source_cleanup PARAMS ((FILE *));
/* Default command line prompt. This is overriden in some configs. */
#ifndef DEFAULT_PROMPT
--- 157,166 ----
static void disconnect PARAMS ((int));
#endif
! 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. */
#ifndef DEFAULT_PROMPT
*************** static int source_error_allocated;
*** 760,767 ****
user-defined command). */
static void
! source_cleanup (stream)
! FILE *stream;
{
/* Restore the previous input stream. */
instream = stream;
--- 762,768 ----
user-defined command). */
static void
! do_restore_instream_cleanup (void *stream)
{
/* Restore the previous input stream. */
instream = stream;
*************** read_command_file (stream)
*** 774,780 ****
{
struct cleanup *cleanups;
! cleanups = make_cleanup ((make_cleanup_func) source_cleanup, instream);
instream = stream;
command_loop ();
do_cleanups (cleanups);
--- 775,781 ----
{
struct cleanup *cleanups;
! cleanups = make_cleanup (do_restore_instream_cleanup, instream);
instream = stream;
command_loop ();
do_cleanups (cleanups);
*************** extern void init_proc PARAMS ((void));
*** 784,789 ****
--- 785,799 ----
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;
*************** gdb_init (argv0)
*** 799,805 ****
#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));
#endif
init_cmd_lists (); /* This needs to be done first */
--- 809,815 ----
#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 (do_chdir_cleanup, xstrdup (current_directory));
#endif
init_cmd_lists (); /* This needs to be done first */
*************** get_command_line (type, arg)
*** 884,890 ****
/* 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);
/* Read in the body of this command. */
if (recurse_read_control_structure (cmd) == invalid_control)
--- 894,900 ----
/* Allocate and build a new command line structure. */
cmd = build_command_line (type, arg);
! old_chain = make_cleanup_free_command_lines (&cmd);
/* Read in the body of this command. */
if (recurse_read_control_structure (cmd) == invalid_control)
*************** if_command (arg, from_tty)
*** 1261,1267 ****
/* Cleanup */
static void
! arg_cleanup ()
{
struct user_args *oargs = user_args;
if (!user_args)
--- 1271,1277 ----
/* Cleanup */
static void
! arg_cleanup (void *ignore)
{
struct user_args *oargs = user_args;
if (!user_args)
*************** setup_user_args (p)
*** 1288,1294 ****
args->next = user_args;
user_args = args;
! old_chain = make_cleanup ((make_cleanup_func) arg_cleanup, 0);
if (p == NULL)
return old_chain;
--- 1298,1304 ----
args->next = user_args;
user_args = args;
! old_chain = make_cleanup (arg_cleanup, 0/*ignored*/);
if (p == NULL)
return old_chain;
*************** execute_user_command (c, args)
*** 1452,1458 ****
/* Set the instream to 0, indicating execution of a
user-defined function. */
! old_chain = make_cleanup ((make_cleanup_func) source_cleanup, instream);
instream = (FILE *) 0;
while (cmdlines)
{
--- 1462,1468 ----
/* Set the instream to 0, indicating execution of a
user-defined function. */
! old_chain = make_cleanup (do_restore_instream_cleanup, instream);
instream = (FILE *) 0;
while (cmdlines)
{
*************** execute_command (p, from_tty)
*** 1577,1584 ****
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;
{
}
--- 1587,1593 ----
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 (void *foo)
{
}
*************** command_loop ()
*** 1609,1615 ****
quit_flag = 0;
if (instream == stdin && stdin_is_tty)
reinitialize_more_filter ();
! old_chain = make_cleanup ((make_cleanup_func) command_loop_marker, 0);
#if defined(TUI)
/* A bit of paranoia: I want to make sure the "insert_mode" global
--- 1618,1624 ----
quit_flag = 0;
if (instream == stdin && stdin_is_tty)
reinitialize_more_filter ();
! old_chain = make_cleanup (command_loop_marker, 0);
#if defined(TUI)
/* A bit of paranoia: I want to make sure the "insert_mode" global
*************** simplified_command_loop (read_input_func
*** 1690,1696 ****
quit_flag = 0;
if (instream == stdin && stdin_is_tty)
reinitialize_more_filter ();
! old_chain = make_cleanup ((make_cleanup_func) command_loop_marker, 0);
/* Get a command-line. */
command = (*read_input_func) (instream == stdin ?
--- 1699,1705 ----
quit_flag = 0;
if (instream == stdin && stdin_is_tty)
reinitialize_more_filter ();
! old_chain = make_cleanup (command_loop_marker, 0);
/* Get a command-line. */
command = (*read_input_func) (instream == stdin ?
*************** read_command_lines (prompt_arg, from_tty
*** 2864,2871 ****
else
{
head = next;
! old_chain = make_cleanup ((make_cleanup_func) free_command_lines,
! &head);
}
tail = next;
}
--- 2873,2879 ----
else
{
head = next;
! old_chain = make_cleanup_free_command_lines (&head);
}
tail = next;
}
*************** free_command_lines (lptr)
*** 2914,2919 ****
--- 2922,2939 ----
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. */
*************** source_cleanup_lines (args)
*** 3748,3753 ****
--- 3768,3779 ----
}
/* ARGSUSED */
+ static void
+ do_fclose_cleanup (void *stream)
+ {
+ fclose (stream);
+ }
+
void
source_command (args, from_tty)
char *args;
*************** source_command (args, from_tty)
*** 3776,3782 ****
return;
}
! make_cleanup ((make_cleanup_func) fclose, stream);
old_lines.old_line = source_line_number;
old_lines.old_file = source_file_name;
--- 3802,3808 ----
return;
}
! make_cleanup (do_fclose_cleanup, stream);
old_lines.old_line = source_line_number;
old_lines.old_file = source_file_name;
Index: top.h
===================================================================
RCS file: /cvs/src/src/gdb/top.h,v
retrieving revision 1.1.1.11
diff -p -r1.1.1.11 top.h
*** top.h 2000/02/03 04:14:30 1.1.1.11
--- top.h 2000/05/22 05:39:04
*************** extern void simplified_command_loop PARA
*** 39,45 ****
extern int quit_confirm PARAMS ((void));
extern void quit_force PARAMS ((char *, int));
extern void quit_command PARAMS ((char *, int));
! extern void command_loop_marker PARAMS ((int));
extern int quit_cover PARAMS ((PTR));
extern void execute_command PARAMS ((char *, int));
--- 39,45 ----
extern int quit_confirm PARAMS ((void));
extern void quit_force PARAMS ((char *, int));
extern void quit_command PARAMS ((char *, int));
! extern void command_loop_marker (void *);
extern int quit_cover PARAMS ((PTR));
extern void execute_command PARAMS ((char *, int));