aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-10-28 12:16:24 -0600
committerTom Tromey <tromey@redhat.com>2014-02-19 07:45:22 -0700
commit8b06beed0f0eb221067a1013add2efd159a36ade (patch)
treef9db016ba84b5f8a4d5f9b42fe77e6e8dc919e58 /gdb
parent6a109b6b2c98b949e490791ae57c100bb53be57e (diff)
downloadgdb-8b06beed0f0eb221067a1013add2efd159a36ade.zip
gdb-8b06beed0f0eb221067a1013add2efd159a36ade.tar.gz
gdb-8b06beed0f0eb221067a1013add2efd159a36ade.tar.bz2
introduce and use find_target_at
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/record.c8
-rw-r--r--gdb/target.c14
-rw-r--r--gdb/target.h5
4 files changed, 26 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 770a534..bb6ce24 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
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):
Add 'ops' argument.
* arm-linux-nat.c (arm_linux_stopped_by_watchpoint): Add
diff --git a/gdb/record.c b/gdb/record.c
index 4c67192..41e167f 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -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. */
diff --git a/gdb/target.c b/gdb/target.c
index 990dc5e..75f7506 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -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;
+}
+
/* The inferior process has died. Long live the inferior! */
diff --git a/gdb/target.h b/gdb/target.h
index 83e3b59..1248734 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -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