introduce and use find_target_at
authorTom Tromey <tromey@redhat.com>
Mon, 28 Oct 2013 18:16:24 +0000 (12:16 -0600)
committerTom Tromey <tromey@redhat.com>
Wed, 19 Feb 2014 14:45:22 +0000 (07:45 -0700)
This patch adds find_target_at to determine whether a target appears
at a given stratum.  This new function lets us clean up
find_record_target a bit, and is generally useful.

2014-02-19  Tom Tromey  <tromey@redhat.com>

* record.c (find_record_target): Use find_target_at.
* target.c (find_target_at): New function.
* target.h (find_target_at): Declare.

gdb/ChangeLog
gdb/record.c
gdb/target.c
gdb/target.h

index 770a534cfda822c164bb7762abdc9120ada8e2da..bb6ce24a99a2170193a4a63a55dde2bc194480d8 100644 (file)
@@ -1,3 +1,9 @@
+2014-02-19  Tom Tromey  <tromey@redhat.com>
+
+       * record.c (find_record_target): Use find_target_at.
+       * target.c (find_target_at): New function.
+       * target.h (find_target_at): Declare.
+
 2014-02-19  Tom Tromey  <tromey@redhat.com>
 
        * aarch64-linux-nat.c (aarch64_linux_stopped_by_watchpoint):
index 4c671927c25a0e0c14189a4d29aa08c1ca0a2e48..41e167fc2ae16bc64efa156de22a4a2fce467441 100644 (file)
@@ -62,13 +62,7 @@ struct cmd_list_element *info_record_cmdlist = NULL;
 struct target_ops *
 find_record_target (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_stratum == record_stratum)
-      return t;
-
-  return NULL;
+  return find_target_at (record_stratum);
 }
 
 /* Check that recording is active.  Throw an error, if it isn't.  */
index 990dc5e36107c322805433a03fb24dd11457a967..75f7506a22eefddce99c9e8ba96db6c5ea8dbda8 100644 (file)
@@ -3748,6 +3748,20 @@ find_target_beneath (struct target_ops *t)
   return t->beneath;
 }
 
+/* See target.h.  */
+
+struct target_ops *
+find_target_at (enum strata stratum)
+{
+  struct target_ops *t;
+
+  for (t = current_target.beneath; t != NULL; t = t->beneath)
+    if (t->to_stratum == stratum)
+      return t;
+
+  return NULL;
+}
+
 \f
 /* The inferior process has died.  Long live the inferior!  */
 
index 83e3b590e16d134b92aeb960f7a06b9e2d7d5d67..1248734ed5e9620a891e0746c6e81a00c8160dab 100644 (file)
@@ -1968,6 +1968,11 @@ extern void find_default_create_inferior (struct target_ops *,
 
 extern struct target_ops *find_target_beneath (struct target_ops *);
 
+/* Find the target at STRATUM.  If no target is at that stratum,
+   return NULL.  */
+
+struct target_ops *find_target_at (enum strata stratum);
+
 /* Read OS data object of type TYPE from the target, and return it in
    XML format.  The result is NUL-terminated and returned as a string,
    allocated using xmalloc.  If an error occurs or the transfer is
This page took 0.030431 seconds and 4 git commands to generate.