* elf.c (prep_headers): Use new EM_SPARCV9 symbol.
[deliverable/binutils-gdb.git] / gdb / top.c
index 80a2293c0226f4c4dbd7ec3ca1a5e9b307869573..248a44df63500b5b2c1a3f332b5eb8e812ee302f 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1,5 +1,5 @@
 /* Top level stuff for GDB, the GNU debugger.
-   Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 1997
+   Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 1998
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -118,7 +118,7 @@ static void set_endian_auto PARAMS ((char *, int));
 
 static void show_endian PARAMS ((char *, int));
 
-extern void set_architecture PARAMS ((char *, int));
+static void set_architecture PARAMS ((char *, int));
 
 static void show_architecture PARAMS ((char *, int));
 
@@ -403,6 +403,10 @@ void (*print_frame_info_listing_hook) PARAMS ((struct symtab *s, int line,
 
 int (*query_hook) PARAMS ((const char *, va_list));
 
+/* Replaces most of warning.  */
+
+void (*warning_hook) PARAMS ((const char *, va_list));
+
 /* Called from gdb_flush to flush output.  */
 
 void (*flush_hook) PARAMS ((FILE *stream));
@@ -439,6 +443,9 @@ void (*interactive_hook) PARAMS ((void));
 
 void (*registers_changed_hook) PARAMS ((void));
 
+/* tell the GUI someone changed the PC */
+void (*pc_changed_hook) PARAMS ((void));
+
 /* Called when going to wait for the target.  Usually allows the GUI to run
    while waiting for target events.  */
 
@@ -458,9 +465,9 @@ NORETURN void (*error_hook) PARAMS ((void)) ATTR_NORETURN;
 
 \f
 /* Where to go for return_to_top_level (RETURN_ERROR).  */
-jmp_buf error_return;
+SIGJMP_BUF error_return;
 /* Where to go for return_to_top_level (RETURN_QUIT).  */
-jmp_buf quit_return;
+SIGJMP_BUF quit_return;
 
 /* Return for reason REASON.  This generally gets back to the command
    loop, but can be caught via catch_errors.  */
@@ -490,7 +497,7 @@ return_to_top_level (reason)
        break;
       }
 
-  (NORETURN void) longjmp
+  (NORETURN void) SIGLONGJMP
     (reason == RETURN_ERROR ? error_return : quit_return, 1);
 }
 
@@ -520,9 +527,9 @@ catch_errors (func, args, errstring, mask)
      char *errstring;
      return_mask mask;
 {
-  jmp_buf saved_error;
-  jmp_buf saved_quit;
-  jmp_buf tmp_jmp;
+  SIGJMP_BUF saved_error;
+  SIGJMP_BUF saved_quit;
+  SIGJMP_BUF tmp_jmp;
   int val;
   struct cleanup *saved_cleanup_chain;
   char *saved_error_pre_print;
@@ -534,21 +541,21 @@ catch_errors (func, args, errstring, mask)
 
   if (mask & RETURN_MASK_ERROR)
     {
-      memcpy ((char *)saved_error, (char *)error_return, sizeof (jmp_buf));
+      memcpy ((char *)saved_error, (char *)error_return, sizeof (SIGJMP_BUF));
       error_pre_print = errstring;
     }
   if (mask & RETURN_MASK_QUIT)
     {
-      memcpy (saved_quit, quit_return, sizeof (jmp_buf));
+      memcpy (saved_quit, quit_return, sizeof (SIGJMP_BUF));
       quit_pre_print = errstring;
     }
 
-  if (setjmp (tmp_jmp) == 0)
+  if (SIGSETJMP (tmp_jmp) == 0)
     {
       if (mask & RETURN_MASK_ERROR)
-       memcpy (error_return, tmp_jmp, sizeof (jmp_buf));
+       memcpy (error_return, tmp_jmp, sizeof (SIGJMP_BUF));
       if (mask & RETURN_MASK_QUIT)
-       memcpy (quit_return, tmp_jmp, sizeof (jmp_buf));
+       memcpy (quit_return, tmp_jmp, sizeof (SIGJMP_BUF));
       val = (*func) (args);
     }
   else
@@ -558,12 +565,12 @@ catch_errors (func, args, errstring, mask)
 
   if (mask & RETURN_MASK_ERROR)
     {
-      memcpy (error_return, saved_error, sizeof (jmp_buf));
+      memcpy (error_return, saved_error, sizeof (SIGJMP_BUF));
       error_pre_print = saved_error_pre_print;
     }
   if (mask & RETURN_MASK_QUIT)
     {
-      memcpy (quit_return, saved_quit, sizeof (jmp_buf));
+      memcpy (quit_return, saved_quit, sizeof (SIGJMP_BUF));
       quit_pre_print = saved_quit_pre_print;
     }
   return val;
@@ -1914,6 +1921,13 @@ static void
 do_nothing (signo)
 int signo;
 {
+  /* Under System V the default disposition of a signal is reinstated after
+     the signal is caught and delivered to an application process.  On such
+     systems one must restore the replacement signal handler if one wishes
+     to continue handling the signal in one's program.  On BSD systems this
+     is not needed but it is harmless, and it simplifies the code to just do
+     it unconditionally. */
+  signal (signo, do_nothing);
 }
 
 static void
@@ -2803,7 +2817,7 @@ print_gdb_version (stream)
 
   /* Second line is a copyright notice. */
 
-  fprintf_filtered (stream, "Copyright 1997 Free Software Foundation, Inc.\n");
+  fprintf_filtered (stream, "Copyright 1998 Free Software Foundation, Inc.\n");
 
   /* Following the copyright is a brief statement that the program is
      free software, that users are free to copy and change it on
@@ -2851,9 +2865,46 @@ print_prompt ()
   printf_unfiltered ("%s", prompt);
   gdb_flush (gdb_stdout);
 }
+
+/* This replaces the above for the frontends: it returns a pointer
+   to the prompt. */
+char *
+get_prompt ()
+{
+  return prompt;
+}
 \f
+/* If necessary, make the user confirm that we should quit.  Return
+   non-zero if we should quit, zero if we shouldn't.  */
+
+int
+quit_confirm ()
+{
+  if (inferior_pid != 0 && target_has_execution)
+    {
+      char *s;
+
+      /* This is something of a hack.  But there's no reliable way to
+        see if a GUI is running.  The `use_windows' variable doesn't
+        cut it.  */
+      if (init_ui_hook)
+       s = "A debugging session is active.\nDo you still want to close the debugger?";
+      else if (attach_flag)
+       s = "The program is running.  Quit anyway (and detach it)? ";
+      else
+       s = "The program is running.  Exit anyway? ";
+
+      if (! query (s))
+       return 0;
+    }
+
+  return 1;
+}
+
+/* Quit without asking for confirmation.  */
+
 void
-quit_command (args, from_tty)
+quit_force (args, from_tty)
      char *args;
      int from_tty;
 {
@@ -2871,20 +2922,11 @@ quit_command (args, from_tty)
   if (inferior_pid != 0 && target_has_execution)
     {
       if (attach_flag)
-       {
-         if (query ("The program is running.  Quit anyway (and detach it)? "))
-           target_detach (args, from_tty);
-         else
-           error ("Not confirmed.");
-       }
+       target_detach (args, from_tty);
       else
-       {
-         if (query ("The program is running.  Quit anyway (and kill it)? "))
-           target_kill ();
-         else
-           error ("Not confirmed.");
-       }
+       target_kill ();
     }
+
   /* UDI wants this, to kill the TIP.  */
   target_close (1);
 
@@ -2897,6 +2939,18 @@ quit_command (args, from_tty)
   exit (exit_code);
 }
 
+/* Handle the quit command.  */
+
+void
+quit_command (args, from_tty)
+     char *args;
+     int from_tty;
+{
+  if (! quit_confirm ())
+    error ("Not confirmed.");
+  quit_force (args, from_tty);
+}
+
 /* Returns whether GDB is running on a terminal and whether the user
    desires that questions be asked of them on that terminal.  */
 
@@ -3242,8 +3296,27 @@ extern const bfd_arch_info_type bfd_default_arch_struct;
 const bfd_arch_info_type *target_architecture = &bfd_default_arch_struct;
 int (*target_architecture_hook) PARAMS ((const bfd_arch_info_type *ap));
 
-/* Called if the user enters ``set architecture'' with or without an argument. */
-void
+static void
+set_arch (arch)
+     const bfd_arch_info_type *arch;
+{
+  /* FIXME: Is it compatible with gdb? */
+  /* Check with the target on the setting */
+  if (target_architecture_hook != NULL
+      && !target_architecture_hook (arch))
+    printf_unfiltered ("Target does not support `%s' architecture.\n",
+                      arch->printable_name);
+  else
+    {
+      target_architecture_auto = 0;
+      target_architecture = arch;
+    }
+}
+
+
+/* Called if the user enters ``set architecture'' with or without an
+   argument. */
+static void
 set_architecture (args, from_tty)
      char *args;
      int from_tty;
@@ -3260,22 +3333,9 @@ set_architecture (args, from_tty)
     {
       const bfd_arch_info_type *arch = bfd_scan_arch (args);
       if (arch != NULL)
-       {
-         /* FIXME: Is it compatible with gdb? */
-         /* Check with the target on the setting */
-         if (target_architecture_hook != NULL
-             && !target_architecture_hook (arch))
-           printf_unfiltered ("Target does not support `%s' architecture.", args);
-         else
-           {
-             target_architecture_auto = 0;
-             target_architecture = arch;
-           }
-       }
+       set_arch (arch);
       else
-       {
-         printf_unfiltered ("Architecture `%s' not reconized.\n", args);
-       }
+       printf_unfiltered ("Architecture `%s' not reconized.\n", args);
     }
 }
 
@@ -3317,6 +3377,20 @@ info_architecture (args, from_tty)
     }
 }
 
+/* Set the architecture from arch/machine */
+void
+set_architecture_from_arch_mach (arch, mach)
+     enum bfd_architecture arch;
+     unsigned long mach;
+{
+  const bfd_arch_info_type *wanted = bfd_lookup_arch (arch, mach);
+  if (wanted != NULL)
+    set_arch (wanted);
+  else
+    fatal ("hardwired architecture/machine not reconized");
+}
+
+
 /* Set the architecture from a BFD */
 void
 set_architecture_from_file (abfd)
This page took 0.028048 seconds and 4 git commands to generate.