aboutsummaryrefslogtreecommitdiff
path: root/gdb/target.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2012-07-20 16:57:32 +0000
committerPedro Alves <palves@redhat.com>2012-07-20 16:57:32 +0000
commit09826ec59df0c34fb49e483b88436b0ea0a7bb30 (patch)
tree2977e95bb21d81ba0042e2cd4b7ad528d09dbe2f /gdb/target.c
parentf7a35f025bd80233c01edb9321aad6f7b523c756 (diff)
downloadgdb-09826ec59df0c34fb49e483b88436b0ea0a7bb30.zip
gdb-09826ec59df0c34fb49e483b88436b0ea0a7bb30.tar.gz
gdb-09826ec59df0c34fb49e483b88436b0ea0a7bb30.tar.bz2
2012-07-20 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_nat_wait): Dump the passed in target options. * target.c (target_wait): Likewise. (str_comma_list_concat_elem, do_option, target_options_to_string): New functions. * target.h (target_options_to_string): Declare.
Diffstat (limited to 'gdb/target.c')
-rw-r--r--gdb/target.c58
1 files changed, 55 insertions, 3 deletions
diff --git a/gdb/target.c b/gdb/target.c
index bb8eae8..ae31415 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2629,13 +2629,17 @@ target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
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;
@@ -3885,6 +3889,54 @@ target_waitstatus_to_string (const struct target_waitstatus *ws)
}
}
+/* 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)