Fix gcc -Wall warnings. See ChangeLog for details.
[deliverable/binutils-gdb.git] / gdb / infcmd.c
index 0ca4d5668e192090dad665070e03d3161ade1319..eddd89a228c8bf2d6227cfe9c5093c12838a8cf3 100644 (file)
@@ -1,5 +1,5 @@
 /* Memory-access and commands for "inferior" process, for GDB.
-   Copyright 1986, 1987, 1988, 1989, 1991, 1992 Free Software Foundation, Inc.
+   Copyright 1986, 1987, 1988, 1989, 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -15,12 +15,12 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
 #include <signal.h>
 #include <sys/param.h>
-#include <string.h>
+#include "gdb_string.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "frame.h"
@@ -54,7 +54,9 @@ static void all_registers_info PARAMS ((char *, int));
 
 static void registers_info PARAMS ((char *, int));
 
+#if !defined (DO_REGISTERS_INFO)
 static void do_registers_info PARAMS ((int, int));
+#endif
 
 static void unset_environment_command PARAMS ((char *, int));
 
@@ -82,6 +84,10 @@ static void step_command PARAMS ((char *, int));
 
 static void run_command PARAMS ((char *, int));
 
+#ifdef CALL_DUMMY_BREAKPOINT_OFFSET
+static void breakpoint_auto_delete_contents PARAMS ((PTR));
+#endif
+
 #define ERROR_NO_INFERIOR \
    if (!target_has_execution) error ("The program is not being run.");
 
@@ -187,7 +193,7 @@ run_command (args, from_tty)
 
   dont_repeat ();
 
-  if (inferior_pid)
+  if (inferior_pid != 0 && target_has_execution)
     {
       if (
          !query ("The program being debugged has been started already.\n\
@@ -359,7 +365,6 @@ step_1 (skip_subroutines, single_inst, count_string)
              printf_filtered ("\
 Single stepping until exit from function %s, \n\
 which has no line number information.\n", name);
-             gdb_flush (gdb_stdout);
            }
        }
       else
@@ -501,13 +506,18 @@ signal_command (signum_exp, from_tty)
 
 /* Call breakpoint_auto_delete on the current contents of the bpstat
    pointed to by arg (which is really a bpstat *).  */
-void
+
+#ifdef CALL_DUMMY_BREAKPOINT_OFFSET
+
+static void
 breakpoint_auto_delete_contents (arg)
      PTR arg;
 {
   breakpoint_auto_delete (*(bpstat *)arg);
 }
 
+#endif /* CALL_DUMMY_BREAKPOINT_OFFSET */
+
 /* Execute a "stack dummy", a piece of code stored in the stack
    by the debugger to be executed in the inferior.
 
@@ -571,7 +581,7 @@ run_stack_dummy (addr, buffer)
     bpt = set_momentary_breakpoint (sal,
                                    get_current_frame (),
                                    bp_call_dummy);
-    bpt->disposition = delete;
+    bpt->disposition = del;
 
     /* If all error()s out of proceed ended up calling normal_stop (and
        perhaps they should; it already does in the special case of error
@@ -732,7 +742,7 @@ finish_command (arg, from_tty)
       val = value_being_returned (value_type, stop_registers,
              using_struct_return (value_of_variable (function, NULL),
                                   funcaddr,
-                                  value_type,
+                                  check_typedef (value_type),
                BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function))));
 
       printf_filtered ("Value returned is $%d = ", record_latest_value (val));
@@ -923,9 +933,13 @@ path_command (dirname, from_tty)
      int from_tty;
 {
   char *exec_path;
-
+  char *env;
   dont_repeat ();
-  exec_path = strsave (get_in_environ (inferior_environ, path_var_name));
+  env = get_in_environ (inferior_environ, path_var_name);
+  /* Can be null if path is not set */
+  if (!env)
+    env = "";
+  exec_path = strsave (env);
   mod_path (dirname, &exec_path);
   set_in_environ (inferior_environ, path_var_name, exec_path);
   free (exec_path);
@@ -974,6 +988,11 @@ do_registers_info (regnum, fpregs)
          continue;
       }
 
+      /* If the register name is empty, it is undefined for this
+        processor, so don't display anything.  */
+      if (reg_names[i] == NULL || *(reg_names[i]) == '\0')
+       continue;
+
       fputs_filtered (reg_names[i], gdb_stdout);
       print_spaces_filtered (15 - strlen (reg_names[i]), gdb_stdout);
 
@@ -1011,7 +1030,11 @@ do_registers_info (regnum, fpregs)
 
          printf_filtered ("\t(raw 0x");
          for (j = 0; j < REGISTER_RAW_SIZE (i); j++)
-           printf_filtered ("%02x", (unsigned char)raw_buffer[j]);
+           {
+             register int idx = TARGET_BYTE_ORDER == BIG_ENDIAN ? j
+               : REGISTER_RAW_SIZE (i) - 1 - j;
+             printf_filtered ("%02x", (unsigned char)raw_buffer[idx]);
+           }
          printf_filtered (")");
        }
 
@@ -1019,7 +1042,7 @@ do_registers_info (regnum, fpregs)
 
       /* Else if virtual format is too long for printf,
         print in hex a byte at a time.  */
-      else if (REGISTER_VIRTUAL_SIZE (i) > sizeof (long))
+      else if (REGISTER_VIRTUAL_SIZE (i) > (int) sizeof (long))
        {
          register int j;
          printf_filtered ("0x");
@@ -1057,6 +1080,8 @@ registers_info (addr_exp, fpregs)
 
   if (!target_has_registers)
     error ("The program has no registers now.");
+  if (selected_frame == NULL)
+    error ("No selected frame.");
 
   if (!addr_exp)
     {
@@ -1127,6 +1152,10 @@ attach_command (args, from_tty)
      char *args;
      int from_tty;
 {
+#ifdef SOLIB_ADD
+  extern int auto_solib_add;
+#endif
+
   dont_repeat ();                      /* Not for the faint of heart */
 
   if (target_has_execution)
@@ -1152,16 +1181,19 @@ attach_command (args, from_tty)
   clear_proceed_status ();
   stop_soon_quietly = 1;
 
-#ifndef MACH
-  /* Mach 3 does not generate any traps when attaching to inferior,
-     and to set up frames we can do this.  */
-
+  /* No traps are generated when attaching to inferior under Mach 3
+     or GNU hurd.  */
+#ifndef ATTACH_NO_WAIT
   wait_for_inferior ();
 #endif
 
 #ifdef SOLIB_ADD
-  /* Add shared library symbols from the newly attached process, if any.  */
-  SOLIB_ADD ((char *)0, from_tty, (struct target_ops *)0);
+  if (auto_solib_add)
+    {
+      /* Add shared library symbols from the newly attached process, if any.  */
+      SOLIB_ADD ((char *)0, from_tty, (struct target_ops *)0);
+      re_enable_breakpoints_in_shlibs ();
+    }
 #endif
 
   normal_stop ();
This page took 0.026552 seconds and 4 git commands to generate.