* infrun.c (IN_SOLIB_TRAMPOLINE): Correct comment, trampolines
[binutils-gdb.git] / gdb / main.c
index 1dafb9f03b7bdb323c165ec45ef41ce551ab2d8e..38771daed2b5f0a3da100007a8e3539ddcd74bea 100644 (file)
@@ -40,8 +40,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 /* readline defines this.  */
 #undef savestring
 
-#ifdef USG
 #include <sys/types.h>
+#ifdef USG
+/* What is this for?  X_OK?  */
 #include <unistd.h>
 #endif
 
@@ -146,6 +147,9 @@ show_command PARAMS ((char *, int));
 static void
 info_command PARAMS ((char *, int));
 
+static void
+complete_command PARAMS ((char *, int));
+
 static void
 do_nothing PARAMS ((int));
 
@@ -180,11 +184,11 @@ extern char *version;
 
 /* Canonical host name as a string. */
 
-extern char *host_canonical;
+extern char *host_name;
 
 /* Canonical target name as a string. */
 
-extern char *target_canonical;
+extern char *target_name;
 
 extern char lang_frame_mismatch_warn[];                /* language.c */
 
@@ -306,6 +310,8 @@ int linesize = 100;
 
 /* Baud rate specified for talking to serial target systems.  Default
    is left as -1, so targets can choose their own defaults.  */
+/* FIXME: This means that "show remotebaud" and gr_files_info can print -1
+   or (unsigned int)-1.  This is a Bad User Interface.  */
 
 int baud_rate = -1;
 
@@ -324,7 +330,11 @@ static void stop_sig PARAMS ((int));
 
 /* Some System V have job control but not sigsetmask(). */
 #if !defined (HAVE_SIGSETMASK)
-#define HAVE_SIGSETMASK !defined (USG)
+#if !defined (USG)
+#define HAVE_SIGSETMASK 1
+#else
+#define HAVE_SIGSETMASK 0
+#endif
 #endif
 
 #if 0 == (HAVE_SIGSETMASK)
@@ -684,7 +694,13 @@ main (argc, argv)
 
              i = strtol (optarg, &p, 0);
              if (i == 0 && p == optarg)
-               warning ("Could not set baud rate to `%s'.\n", optarg);
+
+               /* Don't use *_filtered or warning() (which relies on
+                   current_target) until after initialize_all_files(). */
+
+               fprintf_unfiltered
+                 (gdb_stderr,
+                  "warning: could not set baud rate to `%s'.\n", optarg);
              else
                baud_rate = i;
            }
@@ -844,7 +860,6 @@ GDB manual (available as on-line info or a printed manual).\n", gdb_stdout);
       if (!SET_TOP_LEVEL ())
        {
          cd_command (cdarg, 0);
-         init_source_path ();
        }
     }
   do_cleanups (ALL_CLEANUPS);
@@ -1311,7 +1326,7 @@ filename_completer (text, word)
    "p b-a" ambiguous (all symbols starting with a)
    "p b-" ambiguous (all symbols)
    "file Make" "file" (word break hard to screw up here)
-   "file ../gdb.stabs/wi" "erd" (needs to not break word at slash)
+   "file ../gdb.stabs/we" "ird" (needs to not break word at slash)
    */
 
 /* Generate completions one by one for the completer.  Each time we are
@@ -1347,8 +1362,6 @@ symbol_completion_function (text, matches)
   /* Pointer within tmp_command which corresponds to text.  */
   char *word;
   struct cmd_list_element *c, *result_list;
-  extern char *rl_line_buffer;
-  extern int rl_point;
 
   if (matches == 0)
     {
@@ -1961,6 +1974,36 @@ info_command (arg, from_tty)
   help_list (infolist, "info ", -1, gdb_stdout);
 }
 
+/* The "complete" command is used by Emacs to implement completion.  */
+
+/* ARGSUSED */
+static void
+complete_command (arg, from_tty)
+     char *arg;
+     int from_tty;
+{
+  int i;
+  char *completion;
+
+  dont_repeat ();
+
+  if (arg == NULL)
+    {
+      rl_line_buffer[0] = '\0';
+      rl_point = 0;
+    }
+  else
+    {
+      strcpy (rl_line_buffer, arg);
+      rl_point = strlen (arg);
+    }
+
+  for (completion = symbol_completion_function (rl_line_buffer, i = 0);
+       completion;
+       completion = symbol_completion_function (rl_line_buffer, ++i))
+    printf_unfiltered ("%s\n", completion);
+}
+
 /* The "show" command with no arguments shows all the settings.  */
 
 /* ARGSUSED */
@@ -2179,10 +2222,10 @@ print_gdb_version (stream)
   GDB_FILE *stream;
 {
   fprintf_filtered (stream, "\
-GDB %s (%s", version, host_canonical);
+GDB %s (%s", version, host_name);
 
-  if (strcmp(host_canonical, target_canonical))
-    fprintf_filtered (stream, " --target %s", target_canonical);
+  if (!STREQ (host_name, target_name))
+    fprintf_filtered (stream, " --target %s", target_name);
 
   fprintf_filtered (stream, "), ");
   wrap_here("");
@@ -2233,9 +2276,13 @@ quit_command (args, from_tty)
            error ("Not confirmed.");
        }
     }
+  /* UDI wants this, to kill the TIP.  */
+  target_close (1);
+
   /* Save the history information if it is appropriate to do so.  */
   if (write_history_p && history_filename)
     write_history (history_filename);
+
   exit (0);
 }
 
@@ -2476,7 +2523,6 @@ show_commands (args, from_tty)
   int hist_len;
 
   extern HIST_ENTRY *history_get PARAMS ((int));
-  extern int history_base;
 
   /* Print out some of the commands from the command history.  */
   /* First determine the length of the history list.  */
@@ -2840,6 +2886,9 @@ ie. the number of previous commands to keep a record of.", &sethistlist);
                  &infolist, "info ", 0, &cmdlist);
   add_com_alias ("i", "info", class_info, 1);
 
+  add_com ("complete", class_obscure, complete_command,
+          "List the completions for the rest of the line as a command.");
+
   add_prefix_cmd ("show", class_info, show_command,
                  "Generic command for showing things about the debugger.",
                  &showlist, "show ", 0, &cmdlist);