]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix Ravenscar "process" resume
authorTom Tromey <tromey@adacore.com>
Fri, 7 Aug 2020 16:26:45 +0000 (10:26 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 7 Aug 2020 16:26:47 +0000 (10:26 -0600)
A coworker noticed that gdb would send the wrong vCont packet to qemu
when debugging a Ravenscar program:

    > (gdb) thread 2
    > [Switching to thread 2 (Thread 1.2)]
    > #0  0x0000000000001000 in ?? ()

    > (gdb) c
    [...]
    > Sending packet: $vCont;c:p1.1#e2...Ack

Here, we've switched to thread 2, but the packet says to resume thread
1.

This turned out to be a bug in ravenscar_thread_target::resume, which
did not properly handle the case of a "process" resume.  In
particular, the resume method would be passed a ptid of (1, 0, 0) --
but then rewrite this to its saved ptid.

This patch fixes the problem by recognizing this case in the resume
method.

gdb/ChangeLog
2020-08-07  Tom Tromey  <tromey@adacore.com>

* ravenscar-thread.c (ravenscar_thread_target::resume): Handle
"is_pid" case.

gdb/ChangeLog
gdb/ravenscar-thread.c

index e67b386b418881afa9afb8b27e36491b73f06571..0d443a8f72dacefb1ad2b9d9876503b27acd844c 100644 (file)
@@ -1,3 +1,8 @@
+2020-08-07  Tom Tromey  <tromey@adacore.com>
+
+       * ravenscar-thread.c (ravenscar_thread_target::resume): Handle
+       "is_pid" case.
+
 2020-08-07  Tom Tromey  <tromey@adacore.com>
 
        * ravenscar-thread.c (xfer_partial, enable_btrace, add_thread):
index a67a5e9a368d1e6effbf9efd5b4d072392e65335..91f09209bbce36e9405b9230f1741647c60994d4 100644 (file)
@@ -363,7 +363,12 @@ ravenscar_thread_target::resume (ptid_t ptid, int step,
   /* If we see a wildcard resume, we simply pass that on.  Otherwise,
      arrange to resume the base ptid.  */
   inferior_ptid = m_base_ptid;
-  if (ptid != minus_one_ptid)
+  if (ptid.is_pid ())
+    {
+      /* We only have one process, so resume all threads of it.  */
+      ptid = minus_one_ptid;
+    }
+  else if (ptid != minus_one_ptid)
     ptid = m_base_ptid;
   beneath ()->resume (ptid, step, siggnal);
 }