/* Select target systems and architectures at runtime for GDB.
- Copyright (C) 1990-2012 Free Software Foundation, Inc.
+ Copyright (C) 1990-2013 Free Software Foundation, Inc.
Contributed by Cygnus Support.
/* Non-zero if we want to see trace of target level stuff. */
-static int targetdebug = 0;
+static unsigned int targetdebug = 0;
static void
show_targetdebug (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
INHERIT (to_get_min_fast_tracepoint_insn_len, t);
INHERIT (to_set_disconnected_tracing, t);
INHERIT (to_set_circular_trace_buffer, t);
+ INHERIT (to_set_trace_buffer_size, t);
INHERIT (to_set_trace_notes, t);
INHERIT (to_get_tib_address, t);
INHERIT (to_set_permissions, t);
INHERIT (to_can_use_agent, t);
INHERIT (to_magic, t);
INHERIT (to_supports_evaluation_of_breakpoint_conditions, t);
+ INHERIT (to_can_run_breakpoint_commands, t);
/* Do not inherit to_memory_map. */
/* Do not inherit to_flash_erase. */
/* Do not inherit to_flash_done. */
de_fault (to_set_circular_trace_buffer,
(void (*) (int))
target_ignore);
+ de_fault (to_set_trace_buffer_size,
+ (void (*) (LONGEST))
+ target_ignore);
de_fault (to_set_trace_notes,
(int (*) (char *, char *, char *))
return_zero);
de_fault (to_supports_evaluation_of_breakpoint_conditions,
(int (*) (void))
return_zero);
+ de_fault (to_can_run_breakpoint_commands,
+ (int (*) (void))
+ return_zero);
de_fault (to_use_agent,
(int (*) (int))
tcomplain);
}
if (target != NULL
- && gdbarch_fetch_tls_load_module_address_p (target_gdbarch))
+ && gdbarch_fetch_tls_load_module_address_p (target_gdbarch ()))
{
ptid_t ptid = inferior_ptid;
volatile struct gdb_exception ex;
CORE_ADDR lm_addr;
/* Fetch the load module address for this objfile. */
- lm_addr = gdbarch_fetch_tls_load_module_address (target_gdbarch,
+ lm_addr = gdbarch_fetch_tls_load_module_address (target_gdbarch (),
objfile);
/* If it's 0, throw the appropriate exception. */
if (lm_addr == 0)
int
target_read_string (CORE_ADDR memaddr, char **string, int len, int *errnop)
{
- int tlen, origlen, offset, i;
+ int tlen, offset, i;
gdb_byte buf[4];
int errcode = 0;
char *buffer;
buffer = xmalloc (buffer_allocated);
bufptr = buffer;
- origlen = len;
-
while (len > 0)
{
tlen = MIN (len, 4 - (memaddr & 3));
it makes no progress, and then return how much was transferred). */
int
-target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
+target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
{
/* Dispatch to the topmost target, not the flattened current_target.
Memory accesses check target->to_has_(all_)memory, and the
the target's stack. This may trigger different cache behavior. */
int
-target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
+target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
{
/* Dispatch to the topmost target, not the flattened current_target.
Memory accesses check target->to_has_(all_)memory, and the
Callers that can deal with partial writes should call target_write. */
int
-target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
+target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
{
/* Dispatch to the topmost target, not the flattened current_target.
Memory accesses check target->to_has_(all_)memory, and the
should call target_write. */
int
-target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
+target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
{
/* Dispatch to the topmost target, not the flattened current_target.
Memory accesses check target->to_has_(all_)memory, and the
target_read_stralloc (struct target_ops *ops, enum target_object object,
const char *annex)
{
- gdb_byte *buffer;
+ char *buffer;
LONGEST i, transferred;
- transferred = target_read_alloc_1 (ops, object, annex, &buffer, 1);
+ transferred = target_read_alloc_1 (ops, object, annex,
+ (gdb_byte **) &buffer, 1);
if (transferred < 0)
return NULL;
break;
}
- return (char *) buffer;
+ return buffer;
}
/* Memory transfer methods. */
/* In some OSs, the shared library list is the same/global/shared
across inferiors. If code is shared between processes, so are
memory regions and features. */
- if (!gdbarch_has_global_solist (target_gdbarch))
+ if (!gdbarch_has_global_solist (target_gdbarch ()))
{
no_shared_libraries (NULL, from_tty);
{
struct target_ops* t;
- if (gdbarch_has_global_breakpoints (target_gdbarch))
+ if (gdbarch_has_global_breakpoints (target_gdbarch ()))
/* Don't remove global breakpoints here. They're removed on
disconnection from the target. */
;
if (targetdebug)
{
char *status_string;
+ char *options_string;
status_string = target_waitstatus_to_string (status);
+ options_string = target_options_to_string (options);
fprintf_unfiltered (gdb_stdlog,
- "target_wait (%d, status) = %d, %s\n",
- PIDGET (ptid), PIDGET (retval),
- status_string);
+ "target_wait (%d, status, options={%s})"
+ " = %d, %s\n",
+ PIDGET (ptid), options_string,
+ PIDGET (retval), status_string);
xfree (status_string);
+ xfree (options_string);
}
return retval;
if (target_read (ops, TARGET_OBJECT_MEMORY, NULL,
search_buf, start_addr, search_buf_size) != search_buf_size)
{
- warning (_("Unable to access target memory at %s, halting search."),
- hex_string (start_addr));
+ warning (_("Unable to access %s bytes of target "
+ "memory at %s, halting search."),
+ pulongest (search_buf_size), hex_string (start_addr));
do_cleanups (old_cleanups);
return -1;
}
search_buf + keep_len, read_addr,
nr_to_read) != nr_to_read)
{
- warning (_("Unable to access target "
+ warning (_("Unable to access %s bytes of target "
"memory at %s, halting search."),
+ plongest (nr_to_read),
hex_string (read_addr));
do_cleanups (old_cleanups);
return -1;
/* Implement the "info proc" command. */
-void
+int
target_info_proc (char *args, enum info_proc_what what)
{
struct target_ops *t;
fprintf_unfiltered (gdb_stdlog,
"target_info_proc (\"%s\", %d)\n", args, what);
- return;
+ return 1;
}
}
- error (_("Not supported on this target."));
+ return 0;
}
static int
char *
target_fileio_read_stralloc (const char *filename)
{
- gdb_byte *buffer;
+ char *buffer;
LONGEST i, transferred;
- transferred = target_fileio_read_alloc_1 (filename, &buffer, 1);
+ transferred = target_fileio_read_alloc_1 (filename,
+ (gdb_byte **) &buffer, 1);
if (transferred < 0)
return NULL;
break;
}
- return (char *) buffer;
+ return buffer;
}
static int
default_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
{
- return (len <= gdbarch_ptr_bit (target_gdbarch) / TARGET_CHAR_BIT);
+ return (len <= gdbarch_ptr_bit (target_gdbarch ()) / TARGET_CHAR_BIT);
}
static int
static struct gdbarch *
default_thread_architecture (struct target_ops *ops, ptid_t ptid)
{
- return target_gdbarch;
+ return target_gdbarch ();
}
static int
return xstrprintf ("%svforked", kind_str);
case TARGET_WAITKIND_EXECD:
return xstrprintf ("%sexecd", kind_str);
+ case TARGET_WAITKIND_VFORK_DONE:
+ return xstrprintf ("%svfork-done", kind_str);
case TARGET_WAITKIND_SYSCALL_ENTRY:
return xstrprintf ("%sentered syscall", kind_str);
case TARGET_WAITKIND_SYSCALL_RETURN:
}
}
+/* Concatenate ELEM to LIST, a comma separate list, and return the
+ result. The LIST incoming argument is released. */
+
+static char *
+str_comma_list_concat_elem (char *list, const char *elem)
+{
+ if (list == NULL)
+ return xstrdup (elem);
+ else
+ return reconcat (list, list, ", ", elem, (char *) NULL);
+}
+
+/* Helper for target_options_to_string. If OPT is present in
+ TARGET_OPTIONS, append the OPT_STR (string version of OPT) in RET.
+ Returns the new resulting string. OPT is removed from
+ TARGET_OPTIONS. */
+
+static char *
+do_option (int *target_options, char *ret,
+ int opt, char *opt_str)
+{
+ if ((*target_options & opt) != 0)
+ {
+ ret = str_comma_list_concat_elem (ret, opt_str);
+ *target_options &= ~opt;
+ }
+
+ return ret;
+}
+
+char *
+target_options_to_string (int target_options)
+{
+ char *ret = NULL;
+
+#define DO_TARG_OPTION(OPT) \
+ ret = do_option (&target_options, ret, OPT, #OPT)
+
+ DO_TARG_OPTION (TARGET_WNOHANG);
+
+ if (target_options != 0)
+ ret = str_comma_list_concat_elem (ret, "unknown???");
+
+ if (ret == NULL)
+ ret = xstrdup ("");
+ return ret;
+}
+
static void
debug_print_register (const char * func,
struct regcache *regcache, int regno)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int i, size = register_size (gdbarch, regno);
- unsigned char buf[MAX_REGISTER_SIZE];
+ gdb_byte buf[MAX_REGISTER_SIZE];
regcache_raw_collect (regcache, regno, buf);
fprintf_unfiltered (gdb_stdlog, " = ");
if (targetdebug)
fprintf_unfiltered (gdb_stdlog,
"target_verify_memory (%s, %s) = %d\n",
- paddress (target_gdbarch, memaddr),
+ paddress (target_gdbarch (), memaddr),
pulongest (size),
retval);
return retval;
return -1;
}
+/* See target.h. */
+
+int
+target_supports_btrace (void)
+{
+ struct target_ops *t;
+
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ if (t->to_supports_btrace != NULL)
+ return t->to_supports_btrace ();
+
+ return 0;
+}
+
+/* See target.h. */
+
+struct btrace_target_info *
+target_enable_btrace (ptid_t ptid)
+{
+ struct target_ops *t;
+
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ if (t->to_enable_btrace != NULL)
+ return t->to_enable_btrace (ptid);
+
+ tcomplain ();
+ return NULL;
+}
+
+/* See target.h. */
+
+void
+target_disable_btrace (struct btrace_target_info *btinfo)
+{
+ struct target_ops *t;
+
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ if (t->to_disable_btrace != NULL)
+ return t->to_disable_btrace (btinfo);
+
+ tcomplain ();
+}
+
+/* See target.h. */
+
+void
+target_teardown_btrace (struct btrace_target_info *btinfo)
+{
+ struct target_ops *t;
+
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ if (t->to_teardown_btrace != NULL)
+ return t->to_teardown_btrace (btinfo);
+
+ tcomplain ();
+}
+
+/* See target.h. */
+
+VEC (btrace_block_s) *
+target_read_btrace (struct btrace_target_info *btinfo,
+ enum btrace_read_type type)
+{
+ struct target_ops *t;
+
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ if (t->to_read_btrace != NULL)
+ return t->to_read_btrace (btinfo, type);
+
+ tcomplain ();
+ return NULL;
+}
+
static void
debug_to_prepare_to_store (struct regcache *regcache)
{
fprintf_unfiltered (gdb_stdlog,
"target_xfer_memory (%s, xxx, %d, %s, xxx) = %d",
- paddress (target_gdbarch, memaddr), len,
+ paddress (target_gdbarch (), memaddr), len,
write ? "write" : "read", retval);
if (retval > 0)
add_info ("target", target_info, targ_desc);
add_info ("files", target_info, targ_desc);
- add_setshow_zinteger_cmd ("target", class_maintenance, &targetdebug, _("\
+ add_setshow_zuinteger_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."),
- NULL,
- show_targetdebug,
- &setdebuglist, &showdebuglist);
+ NULL,
+ show_targetdebug,
+ &setdebuglist, &showdebuglist);
add_setshow_boolean_cmd ("trust-readonly-sections", class_support,
&trust_readonly, _("\