public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 4/6] gdbserver: Delimit debugging output for readability
@ 2013-12-17 21:47 Doug Evans
  2013-12-18 11:17 ` Pedro Alves
  0 siblings, 1 reply; 26+ messages in thread
From: Doug Evans @ 2013-12-17 21:47 UTC (permalink / raw)
  To: gdb-patches

Hi.

This patch adds some delimiters to the output of the major pieces
I found use for, namely linux_resume/wait, and stop/unstop_all_lwps.
These are important steps in the control of the inferior, and can
produce a lot of output: It's helpful to be able to identify
when these steps begin and when they end.

2013-12-17  Doug Evans  <dje@google.com>

	* linux-low.c (linux_wait_1): Surround debugging printf output with
	"====".  Ensure all exit paths have debugging printfs for result.
	(linux_wait): Delete debugging printf, duplicates one in linux_wait_1.
	(linux_resume): Surround debugging printf output with "====".
	(stop_all_lwps): Surround debugging printf output with "----".
	(unstop_all_lwps): Ditto.

---
 gdb/gdbserver/linux-low.c | 66 +++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 58 insertions(+), 8 deletions(-)

diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 3883e50..61744a3 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -16,6 +16,18 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* Notes:
+   Debugging printf output is delimited to make it easier to read.
+   There's a lot of it (which is good), but without the delimiters it's
+   hard to see where the entry and exit points are.  High level routines
+   that are useful enough to mark this way are delimited with "====".
+   Lower level routines that are useful enough to mark this way are
+   delimited with "----".
+   We could also use indentation, but that's adds more complexity.
+   Using ==== vs ---- vs nothing works well in practice.
+   Functions are free to use indentation internally, but there is no
+   convention yet for this.  */
+
 #include "server.h"
 #include "linux-low.h"
 #include "linux-osdata.h"
@@ -2268,6 +2278,10 @@ linux_wait_1 (ptid_t ptid,
   int trace_event;
   int in_step_range;
 
+  /* Debugging output is delimited with ==== to make it easier to read.  */
+  if (debug_threads)
+    fprintf (stderr, "====\nlinux_wait_1: [%s]\n", target_pid_to_str (ptid));
+
   /* Translate generic target options into linux options.  */
   options = __WALL;
   if (target_options & TARGET_WNOHANG)
@@ -2318,7 +2332,11 @@ retry:
     }
 
   if (pid == 0) /* only if TARGET_WNOHANG */
-    return null_ptid;
+    {
+      if (debug_threads)
+	fprintf (stderr, "linux_wait_1 ret = null_ptid\n====\n");
+      return null_ptid;
+    }
 
   event_child = get_thread_lwp (current_inferior);
 
@@ -2345,7 +2363,9 @@ retry:
 
 	      if (debug_threads)
 		fprintf (stderr,
-			 "\nChild exited with retcode = %x \n",
+			 "linux_wait_1 ret = %s, exited with retcode %d\n"
+			 "====\n",
+			 target_pid_to_str (ptid_of (event_child)),
 			 WEXITSTATUS (w));
 	    }
 	  else
@@ -2355,9 +2375,10 @@ retry:
 
 	      if (debug_threads)
 		fprintf (stderr,
-			 "\nChild terminated with signal = %x \n",
+			 "linux_wait_1 ret = %s, terminated with signal %d\n"
+			 "====\n",
+			 target_pid_to_str (ptid_of (event_child)),
 			 WTERMSIG (w));
-
 	    }
 
 	  return ptid_of (event_child);
@@ -2524,6 +2545,13 @@ Check if we're already there.\n",
 		{
 		  ourstatus->kind = TARGET_WAITKIND_STOPPED;
 		  ourstatus->value.sig = GDB_SIGNAL_0;
+
+		  if (debug_threads)
+		    fprintf (stderr,
+			     "linux_wait_1 ret = %s, stopped "
+			     "while stabilizing threads\n====\n",
+			     target_pid_to_str (ptid_of (event_child)));
+
 		  return ptid_of (event_child);
 		}
 	    }
@@ -2733,7 +2761,7 @@ Check if we're already there.\n",
   gdb_assert (ptid_equal (step_over_bkpt, null_ptid));
 
   if (debug_threads)
-    fprintf (stderr, "linux_wait ret = %s, %d, %d\n",
+    fprintf (stderr, "linux_wait_1 ret = %s, %d, %d\n====\n",
 	     target_pid_to_str (ptid_of (event_child)),
 	     ourstatus->kind,
 	     ourstatus->value.sig);
@@ -2775,9 +2803,6 @@ linux_wait (ptid_t ptid,
 {
   ptid_t event_ptid;
 
-  if (debug_threads)
-    fprintf (stderr, "linux_wait: [%s]\n", target_pid_to_str (ptid));
-
   /* Flush the async file first.  */
   if (target_is_async_p ())
     async_file_flush ();
@@ -3079,6 +3104,13 @@ stop_all_lwps (int suspend, struct lwp_info *except)
   /* Should not be called recursively.  */
   gdb_assert (stopping_threads == NOT_STOPPING_THREADS);
 
+  if (debug_threads)
+    {
+      fprintf (stderr, "----\nstop_all_lwps (%s, except=%s)\n",
+	       suspend ? "stop-and-suspend" : "stop",
+	       except != NULL ? target_pid_to_str (ptid_of (except)) : "none");
+    }
+
   stopping_threads = (suspend
 		      ? STOPPING_AND_SUSPENDING_THREADS
 		      : STOPPING_THREADS);
@@ -3089,6 +3121,13 @@ stop_all_lwps (int suspend, struct lwp_info *except)
     find_inferior (&all_lwps, send_sigstop_callback, except);
   for_each_inferior (&all_lwps, wait_for_sigstop);
   stopping_threads = NOT_STOPPING_THREADS;
+
+  if (debug_threads)
+    {
+      fprintf (stderr,
+	       "stop_all_lwps done, setting stopping_threads "
+	       "back to !stopping\n----\n");
+    }
 }
 
 /* Resume execution of the inferior process.
@@ -3792,6 +3831,10 @@ linux_resume (struct thread_resume *resume_info, size_t n)
   int any_pending;
   int leave_all_stopped;
 
+  /* Debugging output is delimited with ==== to make it easier to read.  */
+  if (debug_threads)
+    fprintf (stderr, "====\nlinux_resume:\n");
+
   find_inferior (&all_threads, linux_set_resume_request, &array);
 
   /* If there is a thread which would otherwise be resumed, which has
@@ -3835,6 +3878,9 @@ linux_resume (struct thread_resume *resume_info, size_t n)
 
   if (need_step_over)
     start_step_over (need_step_over);
+
+  if (debug_threads)
+    fprintf (stderr, "linux_resume done\n====\n");
 }
 
 /* This function is called once per thread.  We check the thread's
@@ -3984,6 +4030,7 @@ unstop_all_lwps (int unsuspend, struct lwp_info *except)
 {
   if (debug_threads)
     {
+      fprintf (stderr, "----\n");
       if (except)
 	fprintf (stderr,
 		 "unstopping all lwps, except=(LWP %ld)\n", lwpid_of (except));
@@ -3996,6 +4043,9 @@ unstop_all_lwps (int unsuspend, struct lwp_info *except)
     find_inferior (&all_lwps, unsuspend_and_proceed_one_lwp, except);
   else
     find_inferior (&all_lwps, proceed_one_lwp, except);
+
+  if (debug_threads)
+    fprintf (stderr, "unstop_all_lwps done\n----\n");
 }
 
 
-- 
1.8.5.1

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2014-01-22 23:06 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-17 21:47 [PATCH 4/6] gdbserver: Delimit debugging output for readability Doug Evans
2013-12-18 11:17 ` Pedro Alves
2014-01-15  0:47   ` Doug Evans
2014-01-16 17:22     ` Pedro Alves
2014-01-16 18:43       ` Doug Evans
2014-01-16 18:54         ` Pedro Alves
2014-01-16 23:28           ` [PATCH 0/3] Add debug_printf and timestamps to gdbserver Doug Evans
2014-01-16 23:31             ` [PATCH 1/3] gdbserver debug_printf+timestamps: FUNCTION_NAME Doug Evans
2014-01-17 12:46               ` Pedro Alves
2014-01-16 23:33             ` [PATCH 2/3] gdbserver debug_printf+timestamps: delim_string_to_char_ptr_vec_append Doug Evans
2014-01-16 23:37             ` [PATCH 3/3, doc RFA] gdbserver debug_printf+timestamps: main patch Doug Evans
2014-01-17  2:58               ` Doug Evans
2014-01-17  7:04               ` Eli Zaretskii
2014-01-17 12:46               ` Pedro Alves
2014-01-17 22:45                 ` Doug Evans
2014-01-18  8:25                   ` Eli Zaretskii
2014-01-20 16:14                   ` Pedro Alves
2014-01-22 23:06                     ` Doug Evans
2014-01-16 18:39     ` [PATCH 4/6] gdbserver: Delimit debugging output for readability Yao Qi
2014-01-16 19:01       ` Doug Evans
2014-01-17  2:32         ` Joel Brobecker
2014-01-17  2:40         ` Joel Brobecker
2014-01-17 12:46         ` Pedro Alves
2014-01-17 12:59         ` Yao Qi
2014-01-20  5:42         ` Tom Tromey
2014-01-20 19:51           ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).