/* 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.
de_fault (to_stop,
(void (*) (void))
target_ignore);
- de_fault (to_query,
- (int (*) (int, char *, char *, int *))
- return_zero);
de_fault (to_rcmd,
(void (*) (char *, struct ui_file *))
tcomplain);
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
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.
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, ¤t_target);
+ }
+ }
+
/* The quick case is that the top target can handle the transfer. */
res = current_target.to_xfer_memory
(memaddr, myaddr, len, write, attrib, ¤t_target);
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,
®ion->attrib);
if (res <= 0)
/* 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. */
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
PIDGET (ptid), status);
}
+static void
+debug_print_register (const char * func, int regno)
+{
+ fprintf_unfiltered (gdb_stdlog, "%s ", func);
+ if (regno >= 0 && regno < NUM_REGS + NUM_PSEUDO_REGS
+ && REGISTER_NAME (regno) != NULL && REGISTER_NAME (regno)[0] != '\0')
+ fprintf_unfiltered (gdb_stdlog, "(%s)", REGISTER_NAME (regno));
+ else
+ fprintf_unfiltered (gdb_stdlog, "(%d)", regno);
+ if (regno >= 0)
+ {
+ int i;
+ unsigned char *buf = alloca (MAX_REGISTER_RAW_SIZE);
+ read_register_gen (regno, buf);
+ fprintf_unfiltered (gdb_stdlog, " = ");
+ for (i = 0; i < REGISTER_RAW_SIZE (regno); i++)
+ {
+ fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
+ }
+ if (REGISTER_RAW_SIZE (regno) <= sizeof (LONGEST))
+ {
+ fprintf_unfiltered (gdb_stdlog, " 0x%s %s",
+ paddr_nz (read_register (regno)),
+ paddr_d (read_register (regno)));
+ }
+ }
+ fprintf_unfiltered (gdb_stdlog, "\n");
+}
+
static void
debug_to_fetch_registers (int regno)
{
debug_target.to_fetch_registers (regno);
-
- fprintf_unfiltered (gdb_stdlog, "target_fetch_registers (%s)",
- regno != -1 ? REGISTER_NAME (regno) : "-1");
- if (regno != -1)
- fprintf_unfiltered (gdb_stdlog, " = 0x%lx %ld",
- (unsigned long) read_register (regno),
- (unsigned long) read_register (regno));
- fprintf_unfiltered (gdb_stdlog, "\n");
+ debug_print_register ("target_fetch_registers", regno);
}
static void
debug_to_store_registers (int regno)
{
debug_target.to_store_registers (regno);
-
- if (regno >= 0 && regno < NUM_REGS)
- fprintf_unfiltered (gdb_stdlog, "target_store_registers (%s) = 0x%lx %ld\n",
- REGISTER_NAME (regno),
- (unsigned long) read_register (regno),
- (unsigned long) read_register (regno));
- else
- fprintf_unfiltered (gdb_stdlog, "target_store_registers (%d)\n", regno);
+ debug_print_register ("target_store_registers", regno);
+ fprintf_unfiltered (gdb_stdlog, "\n");
}
static 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 ();
}