Fix compile time warning messages.
[deliverable/binutils-gdb.git] / gdb / top.c
index e5a8bef29cf091361130fcd7ce2f21a4c1dfd4d8..ccd9cc0f560dc186bec8a898a0dbd390bae08728 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
 
 /* Prototypes for local functions */
 
-static void dont_repeat_command PARAMS ((char *, int));
+static void dont_repeat_command (char *, int);
 
-static void source_cleanup_lines PARAMS ((PTR));
+static void source_cleanup_lines (PTR);
 
-static void user_defined_command PARAMS ((char *, int));
+static void user_defined_command (char *, int);
 
-static void init_signals PARAMS ((void));
+static void init_signals (void);
 
 #ifdef STOP_SIGNAL
-static void stop_sig PARAMS ((int));
+static void stop_sig (int);
 #endif
 
-static char *line_completion_function PARAMS ((char *, int, char *, int));
+static char *line_completion_function (char *, int, char *, int);
 
-static char *readline_line_completion_function PARAMS ((char *, int));
+static char *readline_line_completion_function (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));
+static void while_command (char *, int);
 
-static void if_command PARAMS ((char *, int));
+static void if_command (char *, int);
 
-static struct command_line *
-  build_command_line PARAMS ((enum command_control_type, char *));
+static struct command_line *build_command_line (enum command_control_type,
+                                               char *);
 
-static struct command_line *
-  get_command_line PARAMS ((enum command_control_type, char *));
+static struct command_line *get_command_line (enum command_control_type,
+                                             char *);
 
-static void realloc_body_list PARAMS ((struct command_line *, int));
+static void realloc_body_list (struct command_line *, int);
 
-static enum misc_command_type read_next_line PARAMS ((struct command_line **));
+static enum misc_command_type read_next_line (struct command_line **);
 
 static enum command_control_type
-recurse_read_control_structure PARAMS ((struct command_line *));
+recurse_read_control_structure (struct command_line *);
+
+static struct cleanup *setup_user_args (char *);
+
+static char *locate_arg (char *);
 
-static struct cleanup *setup_user_args PARAMS ((char *));
+static char *insert_args (char *);
 
-static char *locate_arg PARAMS ((char *));
+static void arg_cleanup (void *);
 
-static char *insert_args PARAMS ((char *));
+static void init_main (void);
 
-static void arg_cleanup PARAMS ((void));
+static void init_cmd_lists (void);
 
-static void init_main PARAMS ((void));
+static void float_handler (int);
 
-static void init_cmd_lists PARAMS ((void));
+static void init_signals (void);
 
-static void float_handler PARAMS ((int));
+static void set_verbose (char *, int, struct cmd_list_element *);
 
-static void init_signals PARAMS ((void));
+static void show_history (char *, int);
 
-static void set_verbose PARAMS ((char *, int, struct cmd_list_element *));
+static void set_history (char *, int);
 
-static void show_history PARAMS ((char *, int));
+static void set_history_size_command (char *, int, struct cmd_list_element *);
 
-static void set_history PARAMS ((char *, int));
+static void show_commands (char *, int);
 
-static void set_history_size_command PARAMS ((char *, int,
-                                             struct cmd_list_element *));
+static void echo_command (char *, int);
 
-static void show_commands PARAMS ((char *, int));
+static void pwd_command (char *, int);
 
-static void echo_command PARAMS ((char *, int));
+static void show_version (char *, int);
 
-static void pwd_command PARAMS ((char *, int));
+static void document_command (char *, int);
 
-static void show_version PARAMS ((char *, int));
+static void define_command (char *, int);
 
-static void document_command PARAMS ((char *, int));
+static void validate_comname (char *);
 
-static void define_command PARAMS ((char *, int));
+static void help_command (char *, int);
 
-static void validate_comname PARAMS ((char *));
+static void show_command (char *, int);
 
-static void help_command PARAMS ((char *, int));
+static void info_command (char *, int);
 
-static void show_command PARAMS ((char *, int));
+static void complete_command (char *, int);
 
-static void info_command PARAMS ((char *, int));
+static void do_nothing (int);
 
-static void complete_command PARAMS ((char *, int));
+static void show_debug (char *, int);
 
-static void do_nothing PARAMS ((int));
+static void set_debug (char *, int);
 
 #ifdef SIGHUP
 /* NOTE 1999-04-29: This function will be static again, once we modify
    gdb to use the event loop as the default command loop and we merge
    event-top.c into this file, top.c */
-/* static */ int quit_cover PARAMS ((PTR));
+/* static */ int quit_cover (PTR);
 
-static void disconnect PARAMS ((int));
+static void disconnect (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. */
 
@@ -255,6 +260,10 @@ struct cmd_list_element *setprintlist;
 
 struct cmd_list_element *showprintlist;
 
+struct cmd_list_element *setdebuglist;
+
+struct cmd_list_element *showdebuglist;
+
 struct cmd_list_element *setchecklist;
 
 struct cmd_list_element *showchecklist;
@@ -283,7 +292,7 @@ int xgdb_verbose;
 
 /* gdb prints this when reading a command interactively */
 static char *gdb_prompt_string;        /* the global prompt string */
-extern char *get_prompt PARAMS ((void));       /* access function for prompt string */
+extern char *get_prompt (void);        /* access function for prompt string */
 
 /* Buffer used for reading command lines, and the size
    allocated for it so far.  */
@@ -361,7 +370,7 @@ struct user_args
 #ifndef STOP_SIGNAL
 #ifdef SIGTSTP
 #define STOP_SIGNAL SIGTSTP
-static void stop_sig PARAMS ((int));
+static void stop_sig (int);
 #endif
 #endif
 
@@ -469,7 +478,7 @@ void (*call_command_hook) PARAMS ((struct cmd_list_element * c, char *cmd,
 /* Called after a `set' command has finished.  Is only run if the
    `set' command succeeded.  */
 
-void (*set_hook) PARAMS ((struct cmd_list_element *c));
+void (*set_hook) (struct cmd_list_element * c);
 
 /* Called when the current thread changes.  Argument is thread id.  */
 
@@ -478,8 +487,7 @@ void (*context_hook) PARAMS ((int id));
 /* Takes control from error ().  Typically used to prevent longjmps out of the
    middle of the GUI.  Usually used in conjunction with a catch routine.  */
 
-NORETURN void (*error_hook)
-PARAMS ((void)) ATTR_NORETURN;
+NORETURN void (*error_hook) (void) ATTR_NORETURN;
 \f
 
 /* One should use catch_errors rather than manipulating these
@@ -532,7 +540,7 @@ return_to_top_level (reason)
      to that call via setjmp's return value.  Note that REASON can't
      be zero, by definition in defs.h. */
 
-  (NORETURN void) SIGLONGJMP (*catch_return, (int)reason);
+  (NORETURN void) SIGLONGJMP (*catch_return, (int) reason);
 }
 
 /* Call FUNC with arg ARGS, catching any errors.  If there is no
@@ -682,7 +690,7 @@ do_captured_command (void *data)
 }
 
 int
-catch_command_errors (catch_command_errors_ftype *command,
+catch_command_errors (catch_command_errors_ftype * command,
                      char *arg, int from_tty, return_mask mask)
 {
   struct captured_command_args args;
@@ -753,8 +761,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;
@@ -767,16 +774,25 @@ 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);
 }
 \f
-extern void init_proc PARAMS ((void));
+extern void init_proc (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;
@@ -792,7 +808,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 */
@@ -877,7 +893,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)
@@ -1087,8 +1103,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;
@@ -1106,10 +1121,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;
@@ -1167,11 +1181,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;
@@ -1257,7 +1270,7 @@ if_command (arg, from_tty)
 
 /* Cleanup */
 static void
-arg_cleanup ()
+arg_cleanup (void *ignore)
 {
   struct user_args *oargs = user_args;
   if (!user_args)
@@ -1284,7 +1297,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;
@@ -1448,7 +1461,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)
     {
@@ -1476,7 +1489,7 @@ execute_command (p, from_tty)
   static int warned = 0;
   char *line;
   /* FIXME: These should really be in an appropriate header file */
-  extern void serial_log_command PARAMS ((const char *));
+extern void serial_log_command (const char *);
 
   free_all_values ();
 
@@ -1496,7 +1509,7 @@ execute_command (p, from_tty)
     {
       char *arg;
       line = p;
-      
+
       c = lookup_cmd (&p, cmdlist, "", 0, 1);
 
       /* If the target is running, we allow only a limited set of
@@ -1519,13 +1532,13 @@ execute_command (p, from_tty)
            p--;
          *(p + 1) = '\0';
        }
-      
+
       /* If this command has been hooked, run the hook first. */
       if (c->hook)
        execute_user_command (c->hook, (char *) 0);
 
       if (c->flags & DEPRECATED_WARN_USER)
-      deprecated_cmd_warning (&line);
+       deprecated_cmd_warning (&line);
 
       if (c->class == class_user)
        execute_user_command (c, arg);
@@ -1573,8 +1586,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)
 {
 }
 
@@ -1605,7 +1617,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
@@ -1686,7 +1698,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 ?
@@ -1826,6 +1838,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. */
@@ -1852,7 +1870,7 @@ filename_completer (text, word)
      char *word;
 {
   /* From readline.  */
-  extern char *filename_completion_function PARAMS ((char *, int));
+extern char *filename_completion_function (char *, int);
   int subsequent_name;
   char **return_val;
   int return_val_used;
@@ -1880,6 +1898,11 @@ filename_completer (text, word)
          return_val[return_val_used++] = p;
          break;
        }
+      /* We need to set subsequent_name to a non-zero value before the
+        continue line below, because otherwise, if the first file seen
+        by GDB is a backup file whose name ends in a `~', we will loop
+        indefinitely.  */
+      subsequent_name = 1;
       /* Like emacs, don't complete on old versions.  Especially useful
          in the "source" command.  */
       if (p[strlen (p) - 1] == '~')
@@ -1909,7 +1932,6 @@ filename_completer (text, word)
            free (p);
          }
       }
-      subsequent_name = 1;
     }
 #if 0
   /* There is no way to do this just long enough to affect quote inserting
@@ -2111,6 +2133,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
@@ -2157,6 +2182,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;
                }
            }
        }
@@ -2844,8 +2872,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;
     }
@@ -2894,6 +2921,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);
+}
 \f
 /* Add an element to the list of info subcommands.  */
 
@@ -3637,13 +3676,13 @@ cd_command (dir, from_tty)
 #endif
 
   len = strlen (dir);
-  if (SLASH_P (dir[len-1]))
+  if (SLASH_P (dir[len - 1]))
     {
       /* Remove the trailing slash unless this is a root directory
-        (including a drive letter on non-Unix systems).  */
-      if (!(len == 1) /* "/" */
+         (including a drive letter on non-Unix systems).  */
+      if (!(len == 1)          /* "/" */
 #if defined(_WIN32) || defined(__MSDOS__)
-         && !(!SLASH_P (*dir) && ROOTED_P (dir) && len <= 3) /* "d:/" */
+         && !(!SLASH_P (*dir) && ROOTED_P (dir) && len <= 3)   /* "d:/" */
 #endif
          )
        len--;
@@ -3728,6 +3767,12 @@ source_cleanup_lines (args)
 }
 
 /* ARGSUSED */
+static void
+do_fclose_cleanup (void *stream)
+{
+  fclose (stream);
+}
+
 void
 source_command (args, from_tty)
      char *args;
@@ -3756,7 +3801,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;
@@ -3851,7 +3896,7 @@ show_commands (args, from_tty)
      than the number of the last command).  Relative to history_base.  */
   int hist_len;
 
-  extern HIST_ENTRY *history_get PARAMS ((int));
+extern HIST_ENTRY *history_get (int);
 
   /* Print out some of the commands from the command history.  */
   /* First determine the length of the history list.  */
@@ -3986,7 +4031,23 @@ float_handler (signo)
   signal (SIGFPE, float_handler);
   error ("Erroneous arithmetic operation.");
 }
-\f
+
+static void
+set_debug (arg, from_tty)
+     char *arg;
+     int from_tty;
+{
+  printf_unfiltered ("\"set debug\" must be followed by the name of a print subcommand.\n");
+  help_list (setdebuglist, "set debug ", -1, gdb_stdout);
+}
+
+static void
+show_debug (args, from_tty)
+     char *args;
+     int from_tty;
+{
+  cmd_show_list (showdebuglist, from_tty, "");
+}
 
 static void
 init_cmd_lists ()
@@ -4042,8 +4103,8 @@ init_history ()
          directories the file written will be the same as the one
          that was read.  */
 #ifdef __MSDOS__
-    /* No leading dots in file names are allowed on MSDOS.  */
-    history_filename = concat (current_directory, "/_gdb_history", NULL);
+      /* No leading dots in file names are allowed on MSDOS.  */
+      history_filename = concat (current_directory, "/_gdb_history", NULL);
 #else
       history_filename = concat (current_directory, "/.gdb_history", NULL);
 #endif
@@ -4313,12 +4374,20 @@ This value is used to set the speed of the serial port when debugging\n\
 using remote targets.", &setlist),
                     &showlist);
 
-  add_show_from_set (
-  add_set_cmd ("remotedebug", no_class, var_zinteger, (char *) &remote_debug,
-              "Set debugging of remote protocol.\n\
+  c = add_set_cmd ("remotedebug", no_class, var_zinteger,
+                  (char *) &remote_debug,
+                  "Set debugging of remote protocol.\n\
 When enabled, each packet sent or received with the remote target\n\
-is displayed.", &setlist),
-                     &showlist);
+is displayed.", &setlist);
+  deprecate_cmd (c, "set debug remote");
+  deprecate_cmd (add_show_from_set (c, &showlist), "show debug remote");
+
+  add_show_from_set (add_set_cmd ("remote", no_class, var_zinteger,
+                                 (char *) &remote_debug,
+                                 "Set debugging of remote protocol.\n\
+When enabled, each packet sent or received with the remote target\n\
+is displayed.", &setdebuglist),
+                    &showdebuglist);
 
   add_show_from_set (
                      add_set_cmd ("remotetimeout", no_class, var_integer, (char *) &remote_timeout,
@@ -4358,4 +4427,11 @@ from the target.", &setlist),
 Use \"on\" to enable the notification, and \"off\" to disable it.", &setlist),
         &showlist);
     }
+  add_prefix_cmd ("debug", no_class, set_debug,
+                 "Generic command for setting gdb debugging flags",
+                 &setdebuglist, "set debug ", 0, &setlist);
+
+  add_prefix_cmd ("debug", no_class, show_debug,
+                 "Generic command for showing gdb debugging flags",
+                 &showdebuglist, "show debug ", 0, &showlist);
 }
This page took 0.033897 seconds and 4 git commands to generate.