fix repeated ext_format_i960 local decls so sun4 cc accepts it
[deliverable/binutils-gdb.git] / gdb / target.c
index eefdbea26491eada005a8c3f7a2d6000436a103f..667ee65311535913565d99e81170123de09e84ac 100644 (file)
@@ -18,23 +18,50 @@ 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.  */
 
-#include <stdio.h>
+#include "defs.h"
 #include <errno.h>
 #include <ctype.h>
-#include "defs.h"
 #include "target.h"
 #include "gdbcmd.h"
 #include "symtab.h"
 #include "inferior.h"
 #include "bfd.h"
 #include "symfile.h"
+#include "objfiles.h"
 
 extern int errno;
 
-extern int memory_insert_breakpoint(), memory_remove_breakpoint();
-extern void host_convert_to_virtual(), host_convert_from_virtual();
+static void
+target_info PARAMS ((char *, int));
+
+static void
+cleanup_target PARAMS ((struct target_ops *));
+
+static void
+maybe_kill_then_create_inferior PARAMS ((char *, char *, char **));
+
+static void
+maybe_kill_then_attach PARAMS ((char *, int));
 
-static void cleanup_target ();
+static void
+kill_or_be_killed PARAMS ((int));
+
+static void
+default_terminal_info PARAMS ((char *, int));
+
+static int
+nosymbol PARAMS ((char *, CORE_ADDR *));
+
+static void
+tcomplain PARAMS ((void));
+
+static int
+nomemory PARAMS ((CORE_ADDR, char *, int, int));
+
+static void
+ignore PARAMS ((void));
+static void
+target_command PARAMS ((char *, int));
 
 /* Pointer to array of target architecture structures; the size of the
    array; the current index into the array; the allocated size of the 
@@ -51,7 +78,7 @@ unsigned target_struct_allocsize;
 struct target_ops dummy_target = {"None", "None", "",
     0, 0, 0, 0,                /* open, close, attach, detach */
     0, 0,              /* resume, wait */
-    0, 0, 0, 0, 0,     /* registers */
+    0, 0, 0,           /* registers */
     0, 0,              /* memory */
     0, 0,              /* bkpts */
     0, 0, 0, 0, 0,     /* terminal */
@@ -96,7 +123,7 @@ add_target (t)
 {
   if (t->to_magic != OPS_MAGIC)
     {
-      fprintf(stderr, "Magic number of %s target struct wrong\n", 
+      fprintf_filtered(stderr, "Magic number of %s target struct wrong\n", 
        t->to_shortname);
       abort();
     }
@@ -110,8 +137,9 @@ add_target (t)
   if (target_struct_size >= target_struct_allocsize)
     {
       target_struct_allocsize *= 2;
-      target_structs = (struct target_ops **) xrealloc (target_structs, 
-       target_struct_allocsize * sizeof (*target_structs));
+      target_structs = (struct target_ops **)
+         xrealloc ((char *) target_structs, 
+                   target_struct_allocsize * sizeof (*target_structs));
     }
   target_structs[target_struct_size++] = t;
   cleanup_target (t);
@@ -142,6 +170,7 @@ nomemory (memaddr, myaddr, len, write)
      int len;
      int write;
 {
+  errno = EIO;         /* Can't read/write this location */
   return 0;            /* No bytes handled */
 }
 
@@ -152,7 +181,7 @@ tcomplain ()
         current_target->to_shortname);
 }
 
-static int
+void
 noprocess ()
 {
   error ("You can't do that without a process to debug");
@@ -173,7 +202,7 @@ default_terminal_info (args, from_tty)
      char *args;
      int from_tty;
 {
-  printf("No saved terminal information.\n");
+  printf_filtered("No saved terminal information.\n");
 }
 
 #if 0
@@ -216,7 +245,7 @@ kill_or_be_killed (from_tty)
 {
   if (target_has_execution)
     {
-      printf ("You are already running a program:\n");
+      printf_filtered ("You are already running a program:\n");
       target_files_info ();
       if (query ("Kill it? ")) {
        target_kill ();
@@ -261,7 +290,7 @@ cleanup_target (t)
      the struct definition, but not all the places that initialize one.  */
   if (t->to_magic != OPS_MAGIC)
     {
-      fprintf(stderr, "Magic number of %s target struct wrong\n", 
+      fprintf_filtered(stderr, "Magic number of %s target struct wrong\n", 
        t->to_shortname);
       abort();
     }
@@ -271,19 +300,17 @@ cleanup_target (t)
 
   /*        FIELD                      DEFAULT VALUE        */
 
-  de_fault (to_open,                   tcomplain);
+  de_fault (to_open,                   (void (*)())tcomplain);
   de_fault (to_close,                  (void (*)())ignore);
   de_fault (to_attach,                         maybe_kill_then_attach);
   de_fault (to_detach,                         (void (*)())ignore);
   de_fault (to_resume,                         (void (*)())noprocess);
-  de_fault (to_wait,                   noprocess);
-  de_fault (to_fetch_registers,        ignore);
+  de_fault (to_wait,                   (int (*)())noprocess);
+  de_fault (to_fetch_registers,        (void (*)())ignore);
   de_fault (to_store_registers,                (void (*)())noprocess);
   de_fault (to_prepare_to_store,       (void (*)())noprocess);
-  de_fault (to_convert_to_virtual,     host_convert_to_virtual);
-  de_fault (to_convert_from_virtual,   host_convert_from_virtual);
-  de_fault (to_xfer_memory,            nomemory);
-  de_fault (to_files_info,             ignore);
+  de_fault (to_xfer_memory,            (int (*)())nomemory);
+  de_fault (to_files_info,             (void (*)())ignore);
   de_fault (to_insert_breakpoint,      memory_insert_breakpoint);
   de_fault (to_remove_breakpoint,      memory_remove_breakpoint);
   de_fault (to_terminal_init,          ignore);
@@ -292,7 +319,7 @@ cleanup_target (t)
   de_fault (to_terminal_ours,          ignore);
   de_fault (to_terminal_info,          default_terminal_info);
   de_fault (to_kill,                   (void (*)())noprocess);
-  de_fault (to_load,                   tcomplain);
+  de_fault (to_load,                   (void (*)())tcomplain);
   de_fault (to_lookup_symbol,          nosymbol);
   de_fault (to_create_inferior,                maybe_kill_then_create_inferior);
   de_fault (to_mourn_inferior,         (void (*)())noprocess);
@@ -493,7 +520,7 @@ target_xfer_memory (memaddr, myaddr, len, write)
          /* If this address is for nonexistent memory,
             read zeros if reading, or do nothing if writing.  Return error. */
          if (!write)
-           bzero (myaddr, len);
+           memset (myaddr, 0, len);
          if (errno == 0)
            return EIO;
          else
@@ -517,8 +544,8 @@ target_info (args, from_tty)
   struct target_ops *t;
   int has_all_mem = 0;
   
-  if (symfile_objfile != 0)
-    printf ("Symbols from \"%s\".\n", symfile_objfile->name);
+  if (symfile_objfile != NULL)
+    printf_filtered ("Symbols from \"%s\".\n", symfile_objfile->name);
 
 #ifdef FILES_INFO_HOOK
   if (FILES_INFO_HOOK ())
@@ -532,8 +559,8 @@ target_info (args, from_tty)
       if ((int)(t->to_stratum) <= (int)dummy_stratum)
        continue;
       if (has_all_mem)
-       printf("\tWhile running this, gdb does not access memory from...\n");
-      printf("%s:\n", t->to_longname);
+       printf_filtered("\tWhile running this, gdb does not access memory from...\n");
+      printf_filtered("%s:\n", t->to_longname);
       (t->to_files_info)(t);
       has_all_mem = t->to_has_all_memory;
     }
This page took 0.026473 seconds and 4 git commands to generate.