Use target_continue{,_no_signal} instead of target_resume
authorSergio Durigan Junior <sergiodj@redhat.com>
Thu, 25 Aug 2016 20:26:24 +0000 (16:26 -0400)
committerSergio Durigan Junior <sergiodj@redhat.com>
Thu, 1 Sep 2016 18:53:51 +0000 (14:53 -0400)
This commit implements a new function, target_continue, on top of the
target_resume function.  Then, it replaces all calls to target_resume
by calls to target_continue or to the already existing
target_continue_no_signal.

This is one of the (many) necessary steps needed to consolidate the
target interface between GDB and gdbserver.  In particular, I am
interested in the impact this change will have on the unification of
the fork_inferior function (which I have been working on).

Tested on the BuildBot, no regressions introduced.

gdb/gdbserver/ChangeLog:
2016-09-31  Sergio Durigan Junior  <sergiodj@redhat.com>

* server.c (start_inferior): New variable 'ptid'.  Replace calls
to the_target->resume by target_continue{,_no_signal}, depending
on the case.
* target.c (target_stop_and_wait): Call target_continue_no_signal
instead of the_target->resume.
(target_continue): New function.

gdb/ChangeLog:
2016-09-31  Sergio Durigan Junior  <sergiodj@redhat.com>

* fork-child.c (startup_inferior): Replace calls to target_resume
by target_continue{,_no_signal}, depending on the case.
* linux-nat.c (cleanup_target_stop): Call
target_continue_no_signal instead of target_resume.
* procfs.c (procfs_wait): Likewise.
* target.c (target_continue): New function.
* target/target.h (target_continue): New prototype.

gdb/ChangeLog
gdb/fork-child.c
gdb/gdbserver/ChangeLog
gdb/gdbserver/server.c
gdb/gdbserver/target.c
gdb/linux-nat.c
gdb/procfs.c
gdb/target.c
gdb/target/target.h

index 602a05a8534ea8a6ea9299079787be574dd097dc..60b595079a3a776775cc66c3a972641c42e3fd95 100644 (file)
@@ -1,3 +1,13 @@
+2016-09-01  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+       * fork-child.c (startup_inferior): Replace calls to target_resume
+       by target_continue{,_no_signal}, depending on the case.
+       * linux-nat.c (cleanup_target_stop): Call
+       target_continue_no_signal instead of target_resume.
+       * procfs.c (procfs_wait): Likewise.
+       * target.c (target_continue): New function.
+       * target/target.h (target_continue): New prototype.
+
 2016-08-31  Yao Qi  <yao.qi@linaro.org>
 
        * record-full.c (record_full_insert_breakpoint): Fix typo.
index 6856cf630f58215dc7aee14d6696c4f8e44cf68c..3e29a1f7a5a3b707c24683d0af23d2a2f71080fb 100644 (file)
@@ -514,7 +514,7 @@ startup_inferior (int ntraps)
       if (resume_signal != GDB_SIGNAL_TRAP)
        {
          /* Let shell child handle its own signals in its own way.  */
-         target_resume (resume_ptid, 0, resume_signal);
+         target_continue (resume_ptid, resume_signal);
        }
       else
        {
@@ -540,7 +540,7 @@ startup_inferior (int ntraps)
            break;
 
          /* Just make it go on.  */
-         target_resume (resume_ptid, 0, GDB_SIGNAL_0);
+         target_continue_no_signal (resume_ptid);
        }
     }
 
index 4dc2e451ea6dd93495b3b160d33636a75033ff53..921a5d4536c6193b18f80e3a3e2830993f365832 100644 (file)
@@ -1,3 +1,12 @@
+2016-09-01  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+       * server.c (start_inferior): New variable 'ptid'.  Replace calls
+       to the_target->resume by target_continue{,_no_signal}, depending
+       on the case.
+       * target.c (target_stop_and_wait): Call target_continue_no_signal
+       instead of the_target->resume.
+       (target_continue): New function.
+
 2016-08-31  Antoine Tremblay  <antoine.tremblay@ericsson.com>
 
        * linux-low.c (linux_wait_1): Move event switch after unsuspend_lwps.
index 6fbd61db5b51b7ff9c4d83c26c13688093faa55f..9c06443e25c387351e4e08fccf8ad6d3ceac662d 100644 (file)
@@ -258,12 +258,7 @@ start_inferior (char **argv)
 
   if (wrapper_argv != NULL)
     {
-      struct thread_resume resume_info;
-
-      memset (&resume_info, 0, sizeof (resume_info));
-      resume_info.thread = pid_to_ptid (signal_pid);
-      resume_info.kind = resume_continue;
-      resume_info.sig = 0;
+      ptid_t ptid = pid_to_ptid (signal_pid);
 
       last_ptid = mywait (pid_to_ptid (signal_pid), &last_status, 0, 0);
 
@@ -271,7 +266,7 @@ start_inferior (char **argv)
        {
          do
            {
-             (*the_target->resume) (&resume_info, 1);
+             target_continue_no_signal (ptid);
 
              last_ptid = mywait (pid_to_ptid (signal_pid), &last_status, 0, 0);
              if (last_status.kind != TARGET_WAITKIND_STOPPED)
@@ -3929,7 +3924,6 @@ process_serial_event (void)
 
       if ((tracing && disconnected_tracing) || any_persistent_commands ())
        {
-         struct thread_resume resume_info;
          struct process_info *process = find_process_pid (pid);
 
          if (process == NULL)
@@ -3965,10 +3959,7 @@ process_serial_event (void)
          process->gdb_detached = 1;
 
          /* Detaching implicitly resumes all threads.  */
-         resume_info.thread = minus_one_ptid;
-         resume_info.kind = resume_continue;
-         resume_info.sig = 0;
-         (*the_target->resume) (&resume_info, 1);
+         target_continue_no_signal (minus_one_ptid);
 
          write_ok (own_buf);
          break; /* from switch/case */
@@ -4428,7 +4419,7 @@ handle_target_event (int err, gdb_client_data client_data)
              /* A thread stopped with a signal, but gdb isn't
                 connected to handle it.  Pass it down to the
                 inferior, as if it wasn't being traced.  */
-             struct thread_resume resume_info;
+             enum gdb_signal signal;
 
              if (debug_threads)
                debug_printf ("GDB not connected; forwarding event %d for"
@@ -4436,13 +4427,11 @@ handle_target_event (int err, gdb_client_data client_data)
                              (int) last_status.kind,
                              target_pid_to_str (last_ptid));
 
-             resume_info.thread = last_ptid;
-             resume_info.kind = resume_continue;
              if (last_status.kind == TARGET_WAITKIND_STOPPED)
-               resume_info.sig = gdb_signal_to_host (last_status.value.sig);
+               signal = last_status.value.sig;
              else
-               resume_info.sig = 0;
-             (*the_target->resume) (&resume_info, 1);
+               signal = GDB_SIGNAL_0;
+             target_continue (last_ptid, signal);
            }
        }
       else
index 42d22b42c4f1a865a65686ff43b357ee01532bf1..8435dc2b260fc9648c64ac16debba09af0c71224 100644 (file)
@@ -248,12 +248,8 @@ target_stop_and_wait (ptid_t ptid)
 {
   struct target_waitstatus status;
   int was_non_stop = non_stop;
-  struct thread_resume resume_info;
 
-  resume_info.thread = ptid;
-  resume_info.kind = resume_stop;
-  resume_info.sig = GDB_SIGNAL_0;
-  (*the_target->resume) (&resume_info, 1);
+  target_continue_no_signal (ptid);
 
   non_stop = 1;
   mywait (ptid, &status, 0, 0);
@@ -273,6 +269,19 @@ target_continue_no_signal (ptid_t ptid)
   (*the_target->resume) (&resume_info, 1);
 }
 
+/* See target/target.h.  */
+
+void
+target_continue (ptid_t ptid, enum gdb_signal signal)
+{
+  struct thread_resume resume_info;
+
+  resume_info.thread = ptid;
+  resume_info.kind = resume_continue;
+  resume_info.sig = gdb_signal_to_host (signal);
+  (*the_target->resume) (&resume_info, 1);
+}
+
 int
 start_non_stop (int nonstop)
 {
index 5d5efa0af45fa8c36b143d6cc8b812f06c64e568..7410f8ec148115e3ca95b2e3ce0032396b53ac22 100644 (file)
@@ -4289,7 +4289,7 @@ cleanup_target_stop (void *arg)
   gdb_assert (arg != NULL);
 
   /* Unpause all */
-  target_resume (*ptid, 0, GDB_SIGNAL_0);
+  target_continue_no_signal (*ptid);
 }
 
 static VEC(static_tracepoint_marker_p) *
index 67b424f5e565587c80f0ce725f6170af0a3055d4..0e0641eb0ac574410ba4963ecdc9b436c5b16b32 100644 (file)
@@ -3716,7 +3716,7 @@ wait_again:
                    else
                      {
                        /* How to keep going without returning to wfi: */
-                       target_resume (ptid, 0, GDB_SIGNAL_0);
+                       target_continue_no_signal (ptid);
                        goto wait_again;
                      }
                  }
@@ -3742,7 +3742,7 @@ wait_again:
                    /* This is an internal event and should be transparent
                       to wfi, so resume the execution and wait again.  See
                       comment in procfs_init_inferior() for more details.  */
-                   target_resume (ptid, 0, GDB_SIGNAL_0);
+                   target_continue_no_signal (ptid);
                    goto wait_again;
                  }
 #endif
index 13e3cdb50d31c80f7fae495e56142bc59ca278d1..87c968146817833091201816c3fe121f0f50421f 100644 (file)
@@ -3449,6 +3449,14 @@ target_continue_no_signal (ptid_t ptid)
   target_resume (ptid, 0, GDB_SIGNAL_0);
 }
 
+/* See target/target.h.  */
+
+void
+target_continue (ptid_t ptid, enum gdb_signal signal)
+{
+  target_resume (ptid, 0, signal);
+}
+
 /* Concatenate ELEM to LIST, a comma separate list, and return the
    result.  The LIST incoming argument is released.  */
 
index 76af732f53660a6386c320e2ba76d50004cafc9d..64ef782d354acb4b5b82430a678b12b378461457 100644 (file)
@@ -64,10 +64,14 @@ extern int target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
 
 extern void target_stop_and_wait (ptid_t ptid);
 
-/* Restart a target previously stopped by target_stop_and_wait.
-   No signal is delivered to the target.  This function must be
-   provided by the client.  */
+/* Restart a target previously stopped.  No signal is delivered to the
+   target.  This function must be provided by the client.  */
 
 extern void target_continue_no_signal (ptid_t ptid);
 
+/* Restart a target previously stopped.  SIGNAL is delivered to the
+   target.  This function must be provided by the client.  */
+
+extern void target_continue (ptid_t ptid, enum gdb_signal signal);
+
 #endif /* TARGET_COMMON_H */
This page took 0.048275 seconds and 4 git commands to generate.