From patchwork Tue Dec 16 16:53:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 4276 Received: (qmail 21357 invoked by alias); 16 Dec 2014 16:54:01 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 21340 invoked by uid 89); 16 Dec 2014 16:54:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 16 Dec 2014 16:53:59 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBGGrvrs002275 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 16 Dec 2014 11:53:57 -0500 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sBGGrt52018425 for ; Tue, 16 Dec 2014 11:53:57 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 1/5] libthread_db: debug output should go to gdb_stdlog Date: Tue, 16 Dec 2014 16:53:50 +0000 Message-Id: <1418748834-27545-2-git-send-email-palves@redhat.com> In-Reply-To: <1418748834-27545-1-git-send-email-palves@redhat.com> References: <1418748834-27545-1-git-send-email-palves@redhat.com> Some debug output in linux-thread-db.c was being sent to gdb_stdout, and some to gdb_stderr, while the right place to send debug output to is gdb_stdlog. gdb/ 2014-12-16 Pedro Alves * linux-thread-db.c (thread_db_find_new_threads_silently) (try_thread_db_load_1, try_thread_db_load, thread_db_load_search) (find_new_threads_once): Print debug output on gdb_stdlog. --- gdb/linux-thread-db.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index c49b567..a405603 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -671,7 +671,7 @@ thread_db_find_new_threads_silently (ptid_t ptid) if (except.reason < 0) { if (libthread_db_debug) - exception_fprintf (gdb_stderr, except, + exception_fprintf (gdb_stdlog, except, "Warning: thread_db_find_new_threads_silently: "); /* There is a bug fixed between nptl 2.6.1 and 2.7 by @@ -753,8 +753,8 @@ try_thread_db_load_1 (struct thread_db_info *info) if (err != TD_OK) { if (libthread_db_debug) - printf_unfiltered (_("td_ta_new failed: %s\n"), - thread_db_err_str (err)); + fprintf_unfiltered (gdb_stdlog, _("td_ta_new failed: %s\n"), + thread_db_err_str (err)); else switch (err) { @@ -814,14 +814,16 @@ try_thread_db_load_1 (struct thread_db_info *info) if (libthread_db_debug || *libthread_db_search_path) { + struct ui_file *file; const char *library; library = dladdr_to_soname (*info->td_ta_new_p); if (library == NULL) library = LIBTHREAD_DB_SO; - printf_unfiltered (_("Using host libthread_db library \"%s\".\n"), - library); + file = *libthread_db_search_path != '\0' ? gdb_stdout : gdb_stdlog; + fprintf_unfiltered (file, _("Using host libthread_db library \"%s\".\n"), + library); } /* The thread library was detected. Activate the thread_db target @@ -846,8 +848,9 @@ try_thread_db_load (const char *library, int check_auto_load_safe) struct thread_db_info *info; if (libthread_db_debug) - printf_unfiltered (_("Trying host libthread_db library: %s.\n"), - library); + fprintf_unfiltered (gdb_stdlog, + _("Trying host libthread_db library: %s.\n"), + library); if (check_auto_load_safe) { @@ -856,7 +859,8 @@ try_thread_db_load (const char *library, int check_auto_load_safe) /* Do not print warnings by file_is_auto_load_safe if the library does not exist at this place. */ if (libthread_db_debug) - printf_unfiltered (_("open failed: %s.\n"), safe_strerror (errno)); + fprintf_unfiltered (gdb_stdlog, _("open failed: %s.\n"), + safe_strerror (errno)); return 0; } @@ -871,7 +875,7 @@ try_thread_db_load (const char *library, int check_auto_load_safe) if (handle == NULL) { if (libthread_db_debug) - printf_unfiltered (_("dlopen failed: %s.\n"), dlerror ()); + fprintf_unfiltered (gdb_stdlog, _("dlopen failed: %s.\n"), dlerror ()); return 0; } @@ -885,7 +889,7 @@ try_thread_db_load (const char *library, int check_auto_load_safe) const char *const libpath = dladdr_to_soname (td_init); if (libpath != NULL) - printf_unfiltered (_("Host %s resolved to: %s.\n"), + fprintf_unfiltered (gdb_stdlog, _("Host %s resolved to: %s.\n"), library, libpath); } } @@ -1076,7 +1080,8 @@ thread_db_load_search (void) do_cleanups (cleanups); if (libthread_db_debug) - printf_unfiltered (_("thread_db_load_search returning %d\n"), rc); + fprintf_unfiltered (gdb_stdlog, + _("thread_db_load_search returning %d\n"), rc); return rc; } @@ -1683,11 +1688,12 @@ find_new_threads_once (struct thread_db_info *info, int iteration, if (libthread_db_debug) { if (except.reason < 0) - exception_fprintf (gdb_stderr, except, + exception_fprintf (gdb_stdlog, except, "Warning: find_new_threads_once: "); - printf_filtered (_("Found %d new threads in iteration %d.\n"), - data.new_threads, iteration); + fprintf_unfiltered (gdb_stdlog, + _("Found %d new threads in iteration %d.\n"), + data.new_threads, iteration); } if (errp != NULL)