/* Select target systems and architectures at runtime for GDB.
- Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
Free Software Foundation, Inc.
Contributed by Cygnus Support.
#include "gdb_assert.h"
#include "gdbcore.h"
#include "exceptions.h"
+#include "target-descriptions.h"
static void target_info (char *, int);
{
struct target_ops *t;
- /* First, reset curren'ts contents. */
+ /* First, reset current's contents. */
memset (¤t_target, 0, sizeof (current_target));
#define INHERIT(FIELD, TARGET) \
INHERIT (to_find_memory_regions, t);
INHERIT (to_make_corefile_notes, t);
INHERIT (to_get_thread_local_address, t);
+ /* Do not inherit to_read_description. */
INHERIT (to_magic, t);
/* Do not inherit to_memory_map. */
/* Do not inherit to_flash_erase. */
de_fault (to_async,
(void (*) (void (*) (enum inferior_event_type, void*), void*))
tcomplain);
+ current_target.to_read_description = NULL;
#undef de_fault
/* Finally, position the target-stack beneath the squashed
/* Try GDB's internal data cache. */
region = lookup_mem_region (memaddr);
- if (memaddr + len < region->hi)
+ /* region->hi == 0 means there's no upper bound. */
+ if (memaddr + len < region->hi || region->hi == 0)
reg_len = len;
else
reg_len = region->hi - memaddr;
if (writebuf != NULL)
error (_("Writing to flash memory forbidden in this context"));
break;
+
+ case MEM_NONE:
+ return -1;
}
if (region->attrib.cache)
do
{
res = ops->to_xfer_partial (ops, TARGET_OBJECT_MEMORY, NULL,
- readbuf, writebuf, memaddr, len);
+ readbuf, writebuf, memaddr, reg_len);
if (res > 0)
return res;
if (targetdebug)
fprintf_unfiltered (gdb_stdlog, "target_flash_erase (%s, %s)\n",
paddr (address), phex (length, 0));
- return t->to_flash_erase (t, address, length);
+ t->to_flash_erase (t, address, length);
+ return;
}
tcomplain ();
{
if (targetdebug)
fprintf_unfiltered (gdb_stdlog, "target_flash_done\n");
- return t->to_flash_done (t);
+ t->to_flash_done (t);
+ return;
}
tcomplain ();
target_pre_inferior (int from_tty)
{
invalidate_target_mem_regions ();
+
+ target_clear_description ();
}
/* This is to be called by the open routine before it does
"could not find a target to follow fork");
}
+/* Look for a target which can describe architectural features, starting
+ from TARGET. If we find one, return its description. */
+
+const struct target_desc *
+target_read_description (struct target_ops *target)
+{
+ struct target_ops *t;
+
+ for (t = target; t != NULL; t = t->beneath)
+ if (t->to_read_description != NULL)
+ {
+ const struct target_desc *tdesc;
+
+ tdesc = t->to_read_description (t);
+ if (tdesc)
+ return tdesc;
+ }
+
+ return NULL;
+}
+
/* Look through the list of possible targets for a target that can
execute a run or attach command without any other data. This is
used to locate the default process stratum.
{
int retval;
- retval = debug_target.to_insert_watchpoint (addr, len, type);
+ retval = debug_target.to_remove_watchpoint (addr, len, type);
fprintf_unfiltered (gdb_stdlog,
- "target_insert_watchpoint (0x%lx, %d, %d) = %ld\n",
+ "target_remove_watchpoint (0x%lx, %d, %d) = %ld\n",
(unsigned long) addr, len, type, (unsigned long) retval);
return retval;
}
target_rcmd (cmd, gdb_stdtarg);
}
+/* Print the name of each layers of our target stack. */
+
+static void
+maintenance_print_target_stack (char *cmd, int from_tty)
+{
+ struct target_ops *t;
+
+ printf_filtered (_("The current target stack is:\n"));
+
+ for (t = target_stack; t != NULL; t = t->beneath)
+ {
+ printf_filtered (" - %s (%s)\n", t->to_shortname, t->to_longname);
+ }
+}
+
void
initialize_targets (void)
{
add_com ("monitor", class_obscure, do_monitor_command,
_("Send a command to the remote monitor (remote targets only)."));
+ add_cmd ("target-stack", class_maintenance, maintenance_print_target_stack,
+ _("Print the name of each layer of the internal target stack."),
+ &maintenanceprintlist);
+
target_dcache = dcache_init ();
}