[PATCH 4/6] gdb/infrun: in condition evaluation wait only for current inferor.

Natalia Saiapova natalia.saiapova@intel.com
Mon Aug 31 12:35:17 GMT 2020


In the middle of a condition evaluation, to successfully finish the
inferior call we need to wait for events from the current thread.
Otherwise, a pending event from another thread might be taken and
the inferior call is abandoned.

gdb/ChangeLog:
2020-08-26  Natalia Saiapova  <natalia.saiapova@intel.com>
	    Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>

	* infrun.c (do_target_wait): Match an inferior PID with the
        expected PID.
	(fetch_inferior_event): In condition evaluation, wait for the
        event from the current inferior.

Co-authored-by: Natalia Saiapova <natalia.saiapova@intel.com>
Co-authored-by: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>

Signed-off-by: Natalia Saiapova <natalia.saiapova@intel.com>
---
 gdb/ChangeLog |  8 ++++++++
 gdb/infrun.c  | 17 +++++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 792903ea251..d526c9fe46f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2020-08-26  Natalia Saiapova  <natalia.saiapova@intel.com>
+	    Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
+
+	* infrun.c (do_target_wait): Match an inferior PID with the
+	expected PID.
+	(fetch_inferior_event): In condition evaluation, wait for the
+	event from the current inferior.
+
 2020-08-26  Natalia Saiapova  <natalia.saiapova@intel.com>
 	    Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
 
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 40c0d425c29..19703c64c4e 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3564,10 +3564,11 @@ do_target_wait (ptid_t wait_ptid, execution_control_state *ecs, int options)
      polling the rest of the inferior list starting from that one in a
      circular fashion until the whole list is polled once.  */
 
-  auto inferior_matches = [&wait_ptid] (inferior *inf)
+  ptid_t wait_pid_ptid {wait_ptid.pid ()};
+  auto inferior_matches = [&wait_pid_ptid] (inferior *inf)
     {
-      return (inf->process_target () != NULL
-	      && ptid_t (inf->pid).matches (wait_ptid));
+      return (inf->process_target () != nullptr
+	      && ptid_t (inf->pid).matches (wait_pid_ptid));
     };
 
   /* First see how many matching inferiors we have.  */
@@ -3905,7 +3906,15 @@ fetch_inferior_event ()
       = make_scoped_restore (&execution_direction,
 			     target_execution_direction ());
 
-    if (!do_target_wait (minus_one_ptid, ecs, TARGET_WNOHANG))
+    ptid_t waiton_ptid = minus_one_ptid;
+
+    /* If the thread is in the middle of the condition evaluation,
+       wait for the event from the current inferior.  */
+    if (inferior_ptid != null_ptid
+	&& inferior_thread ()->control.in_cond_eval)
+      waiton_ptid = inferior_ptid;
+
+    if (!do_target_wait (waiton_ptid, ecs, TARGET_WNOHANG))
       return;
 
     gdb_assert (ecs->ws.kind != TARGET_WAITKIND_IGNORE);
-- 
2.17.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928



More information about the Gdb-patches mailing list