This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC v2 02/38] introduce and use find_target_at
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tromey at redhat dot com>
- Date: Thu, 6 Feb 2014 13:55:00 -0700
- Subject: [RFC v2 02/38] introduce and use find_target_at
- Authentication-results: sourceware.org; auth=none
- References: <1391720136-2121-1-git-send-email-tromey at redhat dot com>
RECORD_IS_USED looks at current_target.to_stratum to determine whether
a record target is in use. This is bad because arch_stratum is
greater than record_stratum.
To fix this, this patch adds find_target_at to determine whether a
target appears at a given stratum. This may seem like overkill
somehow, but I have a subsequent patch series that uses it more
heavily.
This new function lets us clean up find_record_target a bit as well.
2014-02-06 Tom Tromey <tromey@redhat.com>
* record.c (find_record_target): Use find_target_at.
* record.h (RECORD_IS_REPLAY): Use find_target_at.
* target.c (find_target_at): New function.
* target.h (find_target_at): Declare.
---
gdb/ChangeLog | 7 +++++++
gdb/record.c | 8 +-------
gdb/target.c | 14 ++++++++++++++
gdb/target.h | 5 +++++
4 files changed, 27 insertions(+), 7 deletions(-)
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 6723562..c9f004a 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3685,6 +3685,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 e3479e2..07d0afd 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1955,6 +1955,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
--
1.8.1.4