aboutsummaryrefslogtreecommitdiff
path: root/gdb/target.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2020-01-10 20:05:44 +0000
committerPedro Alves <palves@redhat.com>2020-01-10 20:05:44 +0000
commit5018ce90c1205d79f29adf954b0fd5e613d08430 (patch)
treedb2d71399b20052fd76eb3a4ca9bba47485d3eae /gdb/target.c
parent74375d182e992778ef8701278c02a742db6be77e (diff)
downloadgdb-5018ce90c1205d79f29adf954b0fd5e613d08430.zip
gdb-5018ce90c1205d79f29adf954b0fd5e613d08430.tar.gz
gdb-5018ce90c1205d79f29adf954b0fd5e613d08430.tar.bz2
Make target_ops::has_execution take an 'inferior *' instead of a ptid_t
With the multi-target work, each inferior will have its own target stack, so to call a target method, we'll need to make sure that the inferior in question is the current one, otherwise target->beneath() calls will find the target beneath in the wrong inferior. In some places, it's much more convenient to be able to check whether an inferior has execution without having to switch to it in order to call target_has_execution on the right inferior/target stack, to avoid side effects with switching inferior/thread/program space. The current target_ops::has_execution method takes a ptid_t as parameter, which, in a multi-target world, isn't sufficient to identify the target. This patch prepares to address that, by changing the parameter to an inferior pointer instead. From the inferior, we'll be able to query its target stack to tell which target is beneath. Also adds a new inferior::has_execution() method to make callers a bit more natural to read. gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * corelow.c (core_target::has_execution): Change parameter type to inferior pointer. * inferior.c (number_of_live_inferiors): Use inferior::has_execution instead of target_has_execution_1. * inferior.h (inferior::has_execution): New. * linux-thread-db.c (thread_db_target::update_thread_list): Use inferior::has_execution instead of target_has_execution_1. * process-stratum-target.c (process_stratum_target::has_execution): Change parameter type to inferior pointer. Check the inferior's PID instead of inferior_ptid. * process-stratum-target.h (process_stratum_target::has_execution): Change parameter type to inferior pointer. * record-full.c (record_full_core_target::has_execution): Change parameter type to inferior pointer. * target.c (target_has_execution_1): Change parameter type to inferior pointer. (target_has_execution_current): Adjust. * target.h (target_ops::has_execution): Change parameter type to inferior pointer. (target_has_execution_1): Change parameter type to inferior pointer. Change return type to bool. * tracefile.h (tracefile_target::has_execution): Change parameter type to inferior pointer.
Diffstat (limited to 'gdb/target.c')
-rw-r--r--gdb/target.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/gdb/target.c b/gdb/target.c
index e3e30af..7e7e875 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -223,20 +223,20 @@ target_has_registers_1 (void)
return 0;
}
-int
-target_has_execution_1 (ptid_t the_ptid)
+bool
+target_has_execution_1 (inferior *inf)
{
for (target_ops *t = current_top_target (); t != NULL; t = t->beneath ())
- if (t->has_execution (the_ptid))
- return 1;
+ if (t->has_execution (inf))
+ return true;
- return 0;
+ return false;
}
int
target_has_execution_current (void)
{
- return target_has_execution_1 (inferior_ptid);
+ return target_has_execution_1 (current_inferior ());
}
/* This is used to implement the various target commands. */