From: Doug Evans <dje@google.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/6] gdbserver: Delimit debugging output for readability
Date: Tue, 17 Dec 2013 21:47:00 -0000 [thread overview]
Message-ID: <yjt2zjnztait.fsf@ruffy.mtv.corp.google.com> (raw)
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
next reply other threads:[~2013-12-17 21:47 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-17 21:47 Doug Evans [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yjt2zjnztait.fsf@ruffy.mtv.corp.google.com \
--to=dje@google.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox