/* Select target systems and architectures at runtime for GDB.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by Cygnus Support.
static LONGEST default_xfer_partial (struct target_ops *ops,
enum target_object object,
- const char *annex, void *readbuf,
- const void *writebuf,
+ const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf,
ULONGEST offset, LONGEST len);
/* Transfer LEN bytes between target address MEMADDR and GDB address
partial transfers, try either target_read_memory_partial or
target_write_memory_partial). */
-static int target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len,
+static int target_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
int write);
static void init_dummy_target (void);
static void debug_to_prepare_to_store (void);
-static int deprecated_debug_xfer_memory (CORE_ADDR, char *, int, int,
- struct mem_attrib *,
- struct target_ops *);
-
static void debug_to_files_info (struct target_ops *);
-static int debug_to_insert_breakpoint (CORE_ADDR, char *);
+static int debug_to_insert_breakpoint (CORE_ADDR, gdb_byte *);
-static int debug_to_remove_breakpoint (CORE_ADDR, char *);
+static int debug_to_remove_breakpoint (CORE_ADDR, gdb_byte *);
static int debug_to_can_use_hw_breakpoint (int, int, int);
-static int debug_to_insert_hw_breakpoint (CORE_ADDR, char *);
+static int debug_to_insert_hw_breakpoint (CORE_ADDR, gdb_byte *);
-static int debug_to_remove_hw_breakpoint (CORE_ADDR, char *);
+static int debug_to_remove_hw_breakpoint (CORE_ADDR, gdb_byte *);
static int debug_to_insert_watchpoint (CORE_ADDR, int, int);
/* Non-zero if we want to see trace of target level stuff. */
static int targetdebug = 0;
+static void
+show_targetdebug (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("Target debugging is %s.\n"), value);
+}
static void setup_target_debug (void);
(void (*) (void))
noprocess);
de_fault (deprecated_xfer_memory,
- (int (*) (CORE_ADDR, char *, int, int, struct mem_attrib *, struct target_ops *))
+ (int (*) (CORE_ADDR, gdb_byte *, int, int, struct mem_attrib *, struct target_ops *))
nomemory);
de_fault (to_files_info,
(void (*) (struct target_ops *))
(int (*) (int, int, int))
return_zero);
de_fault (to_insert_hw_breakpoint,
- (int (*) (CORE_ADDR, char *))
+ (int (*) (CORE_ADDR, gdb_byte *))
return_minus_one);
de_fault (to_remove_hw_breakpoint,
- (int (*) (CORE_ADDR, char *))
+ (int (*) (CORE_ADDR, gdb_byte *))
return_minus_one);
de_fault (to_insert_watchpoint,
(int (*) (CORE_ADDR, int, int))
target_read_string (CORE_ADDR memaddr, char **string, int len, int *errnop)
{
int tlen, origlen, offset, i;
- char buf[4];
+ gdb_byte buf[4];
int errcode = 0;
char *buffer;
int buffer_allocated;
tlen = MIN (len, 4 - (memaddr & 3));
offset = memaddr & 3;
- errcode = target_read_memory (memaddr & ~3, buf, 4);
+ errcode = target_read_memory (memaddr & ~3, buf, sizeof buf);
if (errcode != 0)
{
/* The transfer request might have crossed the boundary to an
return 0;
offset += xfered;
if (readbuf != NULL)
- readbuf = (bfd_byte *) readbuf + xfered;
+ readbuf = (gdb_byte *) readbuf + xfered;
if (writebuf != NULL)
- writebuf = (bfd_byte *) writebuf + xfered;
+ writebuf = (gdb_byte *) writebuf + xfered;
target = target_stack;
}
else if (xfered < 0)
deal with partial reads should call target_read_memory_partial. */
int
-target_read_memory (CORE_ADDR memaddr, bfd_byte *myaddr, int len)
+target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
{
if (target_xfer_partial_p ())
return xfer_using_stratum (TARGET_OBJECT_MEMORY, NULL,
}
int
-target_write_memory (CORE_ADDR memaddr, const bfd_byte *myaddr, int len)
+target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
{
- bfd_byte *bytes = alloca (len);
+ gdb_byte *bytes = alloca (len);
memcpy (bytes, myaddr, len);
if (target_xfer_partial_p ())
return xfer_using_stratum (TARGET_OBJECT_MEMORY, NULL,
#endif
static int trust_readonly = 0;
+static void
+show_trust_readonly (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("\
+Mode for reading from readonly sections is %s.\n"),
+ value);
+}
/* 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.
Result is -1 on error, or the number of bytes transfered. */
int
-do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+do_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
struct mem_attrib *attrib)
{
int res;
Result is 0 or errno value. */
static int
-target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
+target_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write)
{
int res;
int reg_len;
{
if (region->attrib.cache)
res = dcache_xfer_memory (target_dcache, memaddr, myaddr,
- reg_len, write);
+ reg_len, write);
else
res = do_xfer_memory (memaddr, myaddr, reg_len, write,
®ion->attrib);
target_read_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err)
{
if (target_xfer_partial_p ())
- return target_xfer_partial (target_stack, TARGET_OBJECT_MEMORY, NULL,
- buf, NULL, memaddr, len);
+ {
+ int retval;
+
+ retval = target_xfer_partial (target_stack, TARGET_OBJECT_MEMORY,
+ NULL, buf, NULL, memaddr, len);
+
+ if (retval <= 0)
+ {
+ if (errno)
+ *err = errno;
+ else
+ *err = EIO;
+ return -1;
+ }
+ else
+ {
+ *err = 0;
+ return retval;
+ }
+ }
else
return target_xfer_memory_partial (memaddr, buf, len, 0, err);
}
target_write_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err)
{
if (target_xfer_partial_p ())
- return target_xfer_partial (target_stack, TARGET_OBJECT_MEMORY, NULL,
- NULL, buf, memaddr, len);
+ {
+ int retval;
+
+ retval = target_xfer_partial (target_stack, TARGET_OBJECT_MEMORY,
+ NULL, NULL, buf, memaddr, len);
+
+ if (retval <= 0)
+ {
+ if (errno)
+ *err = errno;
+ else
+ *err = EIO;
+ return -1;
+ }
+ else
+ {
+ *err = 0;
+ return retval;
+ }
+ }
else
return target_xfer_memory_partial (memaddr, buf, len, 1, err);
}
static LONGEST
default_xfer_partial (struct target_ops *ops, enum target_object object,
- const char *annex, void *readbuf,
- const void *writebuf, ULONGEST offset, LONGEST len)
+ const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
if (object == TARGET_OBJECT_MEMORY
&& ops->deprecated_xfer_memory != NULL)
LONGEST
target_read_partial (struct target_ops *ops,
enum target_object object,
- const char *annex, void *buf,
+ const char *annex, gdb_byte *buf,
ULONGEST offset, LONGEST len)
{
return target_xfer_partial (ops, object, annex, buf, NULL, offset, len);
LONGEST
target_write_partial (struct target_ops *ops,
enum target_object object,
- const char *annex, const void *buf,
+ const char *annex, const gdb_byte *buf,
ULONGEST offset, LONGEST len)
{
return target_xfer_partial (ops, object, annex, NULL, buf, offset, len);
LONGEST
target_read (struct target_ops *ops,
enum target_object object,
- const char *annex, void *buf,
+ const char *annex, gdb_byte *buf,
ULONGEST offset, LONGEST len)
{
LONGEST xfered = 0;
while (xfered < len)
{
LONGEST xfer = target_read_partial (ops, object, annex,
- (bfd_byte *) buf + xfered,
+ (gdb_byte *) buf + xfered,
offset + xfered, len - xfered);
/* Call an observer, notifying them of the xfer progress? */
if (xfer <= 0)
LONGEST
target_write (struct target_ops *ops,
enum target_object object,
- const char *annex, const void *buf,
+ const char *annex, const gdb_byte *buf,
ULONGEST offset, LONGEST len)
{
LONGEST xfered = 0;
while (xfered < len)
{
LONGEST xfer = target_write_partial (ops, object, annex,
- (bfd_byte *) buf + xfered,
+ (gdb_byte *) buf + xfered,
offset + xfered, len - xfered);
/* Call an observer, notifying them of the xfer progress? */
if (xfer <= 0)
/* Memory transfer methods. */
void
-get_target_memory (struct target_ops *ops, CORE_ADDR addr, void *buf,
+get_target_memory (struct target_ops *ops, CORE_ADDR addr, gdb_byte *buf,
LONGEST len)
{
if (target_read (ops, TARGET_OBJECT_MEMORY, NULL, buf, addr, len)
(current_target.to_disconnect) (args, from_tty);
}
-void
-target_link (char *modname, CORE_ADDR *t_reloc)
-{
- if (DEPRECATED_STREQ (current_target.to_shortname, "rombug"))
- {
- (current_target.to_lookup_symbol) (modname, t_reloc);
- if (*t_reloc == 0)
- error (_("Unable to link to %s and get relocation in rombug"), modname);
- }
- else
- *t_reloc = (CORE_ADDR) -1;
-}
-
int
target_async_mask (int mask)
{
int (*target_activity_function) (void);
int target_activity_fd;
\f
-/* Convert a normal process ID to a string. Returns the string in a static
- buffer. */
+/* Convert a normal process ID to a string. Returns the string in a
+ static buffer. */
char *
normal_pid_to_str (ptid_t ptid)
{
- static char buf[30];
+ static char buf[32];
- sprintf (buf, "process %d", PIDGET (ptid));
+ xsnprintf (buf, sizeof buf, "process %d", ptid_get_pid (ptid));
return buf;
}
}
static int
-deprecated_debug_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len,
+deprecated_debug_xfer_memory (CORE_ADDR memaddr, bfd_byte *myaddr, int len,
int write, struct mem_attrib *attrib,
struct target_ops *target)
{
}
static int
-debug_to_insert_breakpoint (CORE_ADDR addr, char *save)
+debug_to_insert_breakpoint (CORE_ADDR addr, gdb_byte *save)
{
int retval;
}
static int
-debug_to_remove_breakpoint (CORE_ADDR addr, char *save)
+debug_to_remove_breakpoint (CORE_ADDR addr, gdb_byte *save)
{
int retval;
}
static int
-debug_to_insert_hw_breakpoint (CORE_ADDR addr, char *save)
+debug_to_insert_hw_breakpoint (CORE_ADDR addr, gdb_byte *save)
{
int retval;
}
static int
-debug_to_remove_hw_breakpoint (CORE_ADDR addr, char *save)
+debug_to_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *save)
{
int retval;
add_info ("target", target_info, targ_desc);
add_info ("files", target_info, targ_desc);
- deprecated_add_show_from_set
- (add_set_cmd ("target", class_maintenance, var_zinteger,
- (char *) &targetdebug,
- "Set target debugging.\n\
+ add_setshow_zinteger_cmd ("target", class_maintenance, &targetdebug, _("\
+Set target debugging."), _("\
+Show target debugging."), _("\
When non-zero, target debugging is enabled. Higher numbers are more\n\
verbose. Changes do not take effect until the next \"run\" or \"target\"\n\
-command.", &setdebuglist),
- &showdebuglist);
+command."),
+ NULL,
+ show_targetdebug,
+ &setdebuglist, &showdebuglist);
add_setshow_boolean_cmd ("trust-readonly-sections", class_support,
&trust_readonly, _("\
will be read from the object file instead of from the target. This will\n\
result in significant performance improvement for remote targets."),
NULL,
- NULL, /* FIXME: i18n: Mode for reading from readonly sections is %s. */
+ show_trust_readonly,
&setlist, &showlist);
add_com ("monitor", class_obscure, do_monitor_command,