Rewrite xcoff*_ppc_relocate_section.
[deliverable/binutils-gdb.git] / gdb / target.c
index 1a8723c37e569cd2b1a3918329a0805631e88038..ddc012c4f831c6059206882f50c0661e853dcf0e 100644 (file)
@@ -1,6 +1,7 @@
 /* Select target systems and architectures at runtime for GDB.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001 Free Software Foundation, Inc.
+   2000, 2001, 2002
+   Free Software Foundation, Inc.
    Contributed by Cygnus Support.
 
    This file is part of GDB.
@@ -607,6 +608,8 @@ update_current_target (void)
       INHERIT (to_is_async_p, t);
       INHERIT (to_async, t);
       INHERIT (to_async_mask_value, t);
+      INHERIT (to_find_memory_regions, t);
+      INHERIT (to_make_corefile_notes, t);
       INHERIT (to_magic, t);
 
 #undef INHERIT
@@ -832,6 +835,8 @@ target_write_memory (CORE_ADDR memaddr, char *myaddr, int len)
   return target_xfer_memory (memaddr, myaddr, len, 1);
 }
 
+static int trust_readonly = 0;
+
 /* Move memory to or from the targets.  The top target gets priority;
    if it cannot handle it, it is offered to the next one down, etc.
 
@@ -854,6 +859,26 @@ do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
      0.  */
   errno = 0;
 
+  if (!write && trust_readonly)
+    {
+      /* User-settable option, "trust-readonly-sections".  If true,
+         then memory from any SEC_READONLY bfd section may be read
+         directly from the bfd file. */
+
+      struct section_table *secp;
+
+      for (secp = current_target.to_sections;
+          secp < current_target.to_sections_end;
+          secp++)
+       {
+         if (bfd_get_section_flags (secp->bfd, secp->the_bfd_section) 
+             & SEC_READONLY)
+           if (memaddr >= secp->addr && memaddr < secp->endaddr)
+             return xfer_memory (memaddr, myaddr, len, 0, 
+                                 attrib, &current_target);
+       }
+    }
+
   /* The quick case is that the top target can handle the transfer.  */
   res = current_target.to_xfer_memory
     (memaddr, myaddr, len, write, attrib, &current_target);
@@ -924,10 +949,10 @@ target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
       while (reg_len > 0)
        {
          if (region->attrib.cache)
-           res = dcache_xfer_memory(target_dcache, memaddr, myaddr,
+           res = dcache_xfer_memory (target_dcache, memaddr, myaddr,
                                     reg_len, write);
          else
-           res = do_xfer_memory(memaddr, myaddr, reg_len, write,
+           res = do_xfer_memory (memaddr, myaddr, reg_len, write,
                                 &region->attrib);
              
          if (res <= 0)
@@ -1461,6 +1486,22 @@ normal_target_post_startup_inferior (ptid_t ptid)
   /* This space intentionally left blank. */
 }
 
+/* Error-catcher for target_find_memory_regions */
+/* ARGSUSED */
+static int dummy_find_memory_regions (int (*ignore1) (), void *ignore2)
+{
+  error ("No target.");
+  return 0;
+}
+
+/* Error-catcher for target_make_corefile_notes */
+/* ARGSUSED */
+static char * dummy_make_corefile_notes (bfd *ignore1, int *ignore2)
+{
+  error ("No target.");
+  return NULL;
+}
+
 /* Set up the handful of non-empty slots needed by the dummy target
    vector.  */
 
@@ -1477,6 +1518,8 @@ init_dummy_target (void)
   dummy_target.to_clone_and_follow_inferior = find_default_clone_and_follow_inferior;
   dummy_target.to_pid_to_str = normal_pid_to_str;
   dummy_target.to_stratum = dummy_stratum;
+  dummy_target.to_find_memory_regions = dummy_find_memory_regions;
+  dummy_target.to_make_corefile_notes = dummy_make_corefile_notes;
   dummy_target.to_magic = OPS_MAGIC;
 }
 \f
@@ -2233,16 +2276,26 @@ initialize_targets (void)
   add_info ("target", target_info, targ_desc);
   add_info ("files", target_info, targ_desc);
 
-  add_show_from_set (
-               add_set_cmd ("target", class_maintenance, var_zinteger,
-                            (char *) &targetdebug,
-                            "Set target debugging.\n\
+  add_show_from_set 
+    (add_set_cmd ("target", class_maintenance, var_zinteger,
+                 (char *) &targetdebug,
+                 "Set target debugging.\n\
 When non-zero, target debugging is enabled.", &setdebuglist),
-                     &showdebuglist);
-
+     &showdebuglist);
+
+  add_show_from_set 
+    (add_set_boolean_cmd 
+     ("trust-readonly-sections", class_support, 
+      &trust_readonly, 
+      "Set mode for reading from readonly sections.\n\
+When this mode is on, memory reads from readonly sections (such as .text)\n\
+will be read from the object file instead of from the target.  This will\n\
+result in significant performance improvement for remote targets.",
+      &setlist),
+     &showlist);
 
   add_com ("monitor", class_obscure, do_monitor_command,
           "Send a command to the remote monitor (remote targets only).");
 
-  target_dcache = dcache_init();
+  target_dcache = dcache_init ();
 }
This page took 0.026697 seconds and 4 git commands to generate.