From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27576 invoked by alias); 17 Dec 2013 21:47:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 27566 invoked by uid 89); 17 Dec 2013 21:47:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yh0-f73.google.com Received: from mail-yh0-f73.google.com (HELO mail-yh0-f73.google.com) (209.85.213.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 17 Dec 2013 21:47:41 +0000 Received: by mail-yh0-f73.google.com with SMTP id f64so663763yha.2 for ; Tue, 17 Dec 2013 13:47:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-type; bh=QmeJUxeNFrHHTnL590PJZGCF0mjP5y4L7d1zZ2N+jX0=; b=NkWmI03QvRZfwodDK5hGm9qL+hV6QhTSrpITBCkkaQXB6ezkQeXs5VVsO9UlZow+YU OkSoK+MI71SZQR5cH+JKQMRE8P/BbPFr5BlJkAUUJ/15L68RJ5DTLBEycStjNchuXiDc wRu9F1PuRFa3/Br/xLwkEqDni2tbuZ22X87wk+H+kBpJc/OQwxNR7G3hkBmj6BqhpmDX KSujtkG8Jl2L0BdQuER9GI8Tvc4mxThcKpewzjtFAZAqtFp7i/5xm2rVowqPaT3dMdhB G++sIkFW1dQNfNZvo5sf20e0MaErAUeAz5dVmLLu58RA5QQG3SAb7u+NYNotJnzZXCUC t0PQ== X-Gm-Message-State: ALoCoQmzFr1272KNpN24TOEO2N98RWYrc+LRcB/UPtWpmWlUPbORjx3OGBd2tB80o2VyrOb1aAFAoym0BBLKgVAlAfPvbOjB+jhIN5d6VGb/z54sqyk/Eio9cDv2FwFcaAlyv9dYaxP5KkJPp19ZeJ7d2Q0/V+2WzIoPvBrTJSQBS+taayez2a2ix+njMeK0r+GB5oqhb42HZmGll7U9k+jt09I3OmV/yGjKcy5EHEt0gpj/kDUr/2c= X-Received: by 10.58.128.33 with SMTP id nl1mr9799598veb.28.1387316859613; Tue, 17 Dec 2013 13:47:39 -0800 (PST) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id k45si4835724yhn.4.2013.12.17.13.47.39 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Dec 2013 13:47:39 -0800 (PST) Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.17.128.44]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 0F91531C204 for ; Tue, 17 Dec 2013 13:47:38 -0800 (PST) From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH 4/6] gdbserver: Delimit debugging output for readability Date: Tue, 17 Dec 2013 21:47:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00671.txt.bz2 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 * 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 . */ +/* 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