Add support for FreeBSD/i386 ELF.
[deliverable/binutils-gdb.git] / gdb / target.c
index fa9cf88a1083a8c73d92ae0141a19f45df0ed778..606be318d547c8301613db27189c65cba6ab4a36 100644 (file)
@@ -95,7 +95,7 @@ static void normal_target_post_startup_inferior PARAMS ((int pid));
 
 static int
 target_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len,
-                           int write, asection * bfd_section));
+                           int write));
 
 static void init_dummy_target PARAMS ((void));
 
@@ -836,7 +836,7 @@ target_read_string (memaddr, string, len, errnop)
       tlen = MIN (len, 4 - (memaddr & 3));
       offset = memaddr & 3;
 
-      errcode = target_xfer_memory (memaddr & ~3, buf, 4, 0, NULL);
+      errcode = target_xfer_memory (memaddr & ~3, buf, 4, 0);
       if (errcode != 0)
        {
          /* The transfer request might have crossed the boundary to an
@@ -844,7 +844,7 @@ target_read_string (memaddr, string, len, errnop)
             a single byte.  */
          tlen = 1;
          offset = 0;
-         errcode = target_xfer_memory (memaddr, buf, 1, 0, NULL);
+         errcode = target_xfer_memory (memaddr, buf, 1, 0);
          if (errcode != 0)
            goto done;
        }
@@ -896,17 +896,7 @@ target_read_memory (memaddr, myaddr, len)
      char *myaddr;
      int len;
 {
-  return target_xfer_memory (memaddr, myaddr, len, 0, NULL);
-}
-
-int
-target_read_memory_section (memaddr, myaddr, len, bfd_section)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
-     asection *bfd_section;
-{
-  return target_xfer_memory (memaddr, myaddr, len, 0, bfd_section);
+  return target_xfer_memory (memaddr, myaddr, len, 0);
 }
 
 int
@@ -915,15 +905,9 @@ target_write_memory (memaddr, myaddr, len)
      char *myaddr;
      int len;
 {
-  return target_xfer_memory (memaddr, myaddr, len, 1, NULL);
+  return target_xfer_memory (memaddr, myaddr, len, 1);
 }
 
-/* This variable is used to pass section information down to targets.  This
-   *should* be done by adding an argument to the target_xfer_memory function
-   of all the targets, but I didn't feel like changing 50+ files.  */
-
-asection *target_memory_bfd_section = NULL;
-
 /* Move memory to or from the targets.  Iterate until all of it has
    been moved, if necessary.  The top target gets priority; anything
    it doesn't want, is offered to the next one down, etc.  Note the
@@ -935,12 +919,11 @@ asection *target_memory_bfd_section = NULL;
    Result is 0 or errno value.  */
 
 static int
-target_xfer_memory (memaddr, myaddr, len, write, bfd_section)
+target_xfer_memory (memaddr, myaddr, len, write)
      CORE_ADDR memaddr;
      char *myaddr;
      int len;
      int write;
-     asection *bfd_section;
 {
   int curlen;
   int res;
@@ -951,8 +934,6 @@ target_xfer_memory (memaddr, myaddr, len, write, bfd_section)
   if (len == 0)
     return 0;
 
-  target_memory_bfd_section = bfd_section;
-
   /* to_xfer_memory is not guaranteed to set errno, even when it returns
      0.  */
   errno = 0;
@@ -1325,6 +1306,39 @@ target_resize_to_sections (struct target_ops *target, int num_added)
 
 }
 
+/* Remove all target sections taken from ABFD.
+
+   Scan the current target stack for targets whose section tables
+   refer to sections from BFD, and remove those sections.  We use this
+   when we notice that the inferior has unloaded a shared object, for
+   example.  */
+void
+remove_target_sections (bfd *abfd)
+{
+  struct target_ops **t;
+
+  for (t = target_structs; t < target_structs + target_struct_size; t++)
+    {
+      struct section_table *src, *dest;
+
+      dest = (*t)->to_sections;
+      for (src = (*t)->to_sections; src < (*t)->to_sections_end; src++)
+       if (src->bfd != abfd)
+         {
+           /* Keep this section.  */
+           if (dest < src) *dest = *src;
+           dest++;
+         }
+
+      /* If we've dropped any sections, resize the section table.  */
+      if (dest < src)
+       target_resize_to_sections (*t, dest - src);
+    }
+}
+
+
+
+
 /* Find a single runnable target in the stack and return it.  If for
    some reason there is more than one, return NULL.  */
 
@@ -3030,9 +3044,11 @@ static void
 do_monitor_command (char *cmd,
                 int from_tty)
 {
-  if ((current_target.to_rcmd == (void*) tcomplain)
+  if ((current_target.to_rcmd
+       == (void (*) (char *, struct ui_file *)) tcomplain)
       || (current_target.to_rcmd == debug_to_rcmd
-         && (debug_target.to_rcmd == (void*) tcomplain)))
+         && (debug_target.to_rcmd
+             == (void (*) (char *, struct ui_file *)) tcomplain)))
     {
       error ("\"monitor\" command not supported by this target.\n");
     }
@@ -3049,11 +3065,11 @@ initialize_targets ()
   add_info ("files", target_info, targ_desc);
 
   add_show_from_set (
-               add_set_cmd ("targetdebug", class_maintenance, var_zinteger,
+               add_set_cmd ("target", class_maintenance, var_zinteger,
                             (char *) &targetdebug,
                             "Set target debugging.\n\
-When non-zero, target debugging is enabled.", &setlist),
-                     &showlist);
+When non-zero, target debugging is enabled.", &setdebuglist),
+                     &showdebuglist);
 
 
   add_com ("monitor", class_obscure, do_monitor_command,
This page took 0.026536 seconds and 4 git commands to generate.