From 4eefa7bcf286b879f61b9e1ec1c97230f5345104 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 18 Nov 2016 00:07:10 +0000 Subject: [PATCH] gdbserver: Use debug_printf for debug output gdb/gdbserver/ChangeLog: 2016-11-23 Pedro Alves * linux-low.c (check_zombie_leaders): Use debug_printf for debug output. * notif.c (handle_notif_ack, notif_event_enque): Likewise. * remote-utils.c (putpkt_binary_1, readchar, getpkt): Use debug_printf and debug_flush for debug output. * server.c (handle_general_set): Likewise. * thread-db.c (try_thread_db_load): Use debug_printf for debug output. --- gdb/gdbserver/ChangeLog | 11 +++++++++++ gdb/gdbserver/linux-low.c | 7 +++---- gdb/gdbserver/notif.c | 8 ++++---- gdb/gdbserver/remote-utils.c | 32 ++++++++++++++++---------------- gdb/gdbserver/server.c | 17 ++++++++--------- gdb/gdbserver/thread-db.c | 3 +-- 6 files changed, 43 insertions(+), 35 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index b7a7e8f68a4..c023c8b6f8b 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,14 @@ +2016-11-23 Pedro Alves + + * linux-low.c (check_zombie_leaders): Use debug_printf for debug + output. + * notif.c (handle_notif_ack, notif_event_enque): Likewise. + * remote-utils.c (putpkt_binary_1, readchar, getpkt): Use + debug_printf and debug_flush for debug output. + * server.c (handle_general_set): Likewise. + * thread-db.c (try_thread_db_load): Use debug_printf for debug + output. + 2016-11-17 Simon Marchi * Makefile.in (.c.o): Replace rule with ... diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index b441ebccce5..4bf39556535 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -1981,10 +1981,9 @@ check_zombie_leaders (void) thread execs). */ if (debug_threads) - fprintf (stderr, - "CZL: Thread group leader %d zombie " - "(it exited, or another thread execd).\n", - leader_pid); + debug_printf ("CZL: Thread group leader %d zombie " + "(it exited, or another thread execd).\n", + leader_pid); delete_lwp (leader_lp); } diff --git a/gdb/gdbserver/notif.c b/gdb/gdbserver/notif.c index 945516798d5..342f07bce9b 100644 --- a/gdb/gdbserver/notif.c +++ b/gdb/gdbserver/notif.c @@ -104,8 +104,8 @@ handle_notif_ack (char *own_buf, int packet_len) = QUEUE_deque (notif_event_p, np->queue); if (remote_debug) - fprintf (stderr, "%s: acking %d\n", np->ack_name, - QUEUE_length (notif_event_p, np->queue)); + debug_printf ("%s: acking %d\n", np->ack_name, + QUEUE_length (notif_event_p, np->queue)); xfree (head); } @@ -124,8 +124,8 @@ notif_event_enque (struct notif_server *notif, QUEUE_enque (notif_event_p, notif->queue, event); if (remote_debug) - fprintf (stderr, "pending events: %s %d\n", notif->notif_name, - QUEUE_length (notif_event_p, notif->queue)); + debug_printf ("pending events: %s %d\n", notif->notif_name, + QUEUE_length (notif_event_p, notif->queue)); } diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c index 1d51010b27a..3212ec97150 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -664,18 +664,18 @@ putpkt_binary_1 (char *buf, int cnt, int is_notif) if (remote_debug) { if (is_notif) - fprintf (stderr, "putpkt (\"%s\"); [notif]\n", buf2); + debug_printf ("putpkt (\"%s\"); [notif]\n", buf2); else - fprintf (stderr, "putpkt (\"%s\"); [noack mode]\n", buf2); - fflush (stderr); + debug_printf ("putpkt (\"%s\"); [noack mode]\n", buf2); + debug_flush (); } break; } if (remote_debug) { - fprintf (stderr, "putpkt (\"%s\"); [looking for ack]\n", buf2); - fflush (stderr); + debug_printf ("putpkt (\"%s\"); [looking for ack]\n", buf2); + debug_flush (); } cc = readchar (); @@ -688,8 +688,8 @@ putpkt_binary_1 (char *buf, int cnt, int is_notif) if (remote_debug) { - fprintf (stderr, "[received '%c' (0x%x)]\n", cc, cc); - fflush (stderr); + debug_printf ("[received '%c' (0x%x)]\n", cc, cc); + debug_flush (); } /* Check for an input interrupt while we're here. */ @@ -889,7 +889,7 @@ readchar (void) if (readchar_bufcnt == 0) { if (remote_debug) - fprintf (stderr, "readchar: Got EOF\n"); + debug_printf ("readchar: Got EOF\n"); } else perror ("readchar"); @@ -977,8 +977,8 @@ getpkt (char *buf) break; if (remote_debug) { - fprintf (stderr, "[getpkt: discarding char '%c']\n", c); - fflush (stderr); + debug_printf ("[getpkt: discarding char '%c']\n", c); + debug_flush (); } if (c < 0) @@ -1024,8 +1024,8 @@ getpkt (char *buf) { if (remote_debug) { - fprintf (stderr, "getpkt (\"%s\"); [sending ack] \n", buf); - fflush (stderr); + debug_printf ("getpkt (\"%s\"); [sending ack] \n", buf); + debug_flush (); } if (write_prim ("+", 1) != 1) @@ -1033,16 +1033,16 @@ getpkt (char *buf) if (remote_debug) { - fprintf (stderr, "[sent ack]\n"); - fflush (stderr); + debug_printf ("[sent ack]\n"); + debug_flush (); } } else { if (remote_debug) { - fprintf (stderr, "getpkt (\"%s\"); [no ack sent] \n", buf); - fflush (stderr); + debug_printf ("getpkt (\"%s\"); [no ack sent] \n", buf); + debug_flush (); } } diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 3f9ff2bbf49..ef8dd032428 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -706,8 +706,8 @@ handle_general_set (char *own_buf) { if (remote_debug) { - fprintf (stderr, "[noack mode enabled]\n"); - fflush (stderr); + debug_printf ("[noack mode enabled]\n"); + debug_flush (); } noack_mode = 1; @@ -746,7 +746,7 @@ handle_general_set (char *own_buf) non_stop = req; if (remote_debug) - fprintf (stderr, "[%s mode enabled]\n", req_str); + debug_printf ("[%s mode enabled]\n", req_str); write_ok (own_buf); return; @@ -762,10 +762,9 @@ handle_general_set (char *own_buf) if (remote_debug) { - if (disable_randomization) - fprintf (stderr, "[address space randomization disabled]\n"); - else - fprintf (stderr, "[address space randomization enabled]\n"); + debug_printf (disable_randomization + ? "[address space randomization disabled]\n" + : "[address space randomization enabled]\n"); } write_ok (own_buf); @@ -795,7 +794,7 @@ handle_general_set (char *own_buf) /* Update the flag. */ use_agent = req; if (remote_debug) - fprintf (stderr, "[%s agent]\n", req ? "Enable" : "Disable"); + debug_printf ("[%s agent]\n", req ? "Enable" : "Disable"); write_ok (own_buf); return; } @@ -832,7 +831,7 @@ handle_general_set (char *own_buf) { const char *req_str = report_thread_events ? "enabled" : "disabled"; - fprintf (stderr, "[thread events are now %s]\n", req_str); + debug_printf ("[thread events are now %s]\n", req_str); } write_ok (own_buf); diff --git a/gdb/gdbserver/thread-db.c b/gdb/gdbserver/thread-db.c index 0222bfcd734..2776557d723 100644 --- a/gdb/gdbserver/thread-db.c +++ b/gdb/gdbserver/thread-db.c @@ -590,8 +590,7 @@ try_thread_db_load (const char *library) const char *const libpath = dladdr_to_soname (td_init); if (libpath != NULL) - fprintf (stderr, "Host %s resolved to: %s.\n", - library, libpath); + debug_printf ("Host %s resolved to: %s.\n", library, libpath); } } #endif -- 2.30.2