aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAlan Hayward <alan.hayward@arm.com>2019-04-16 10:37:47 +0100
committerAlan Hayward <alan.hayward@arm.com>2019-04-17 10:42:46 +0100
commita7e559cc087b10b9ea337b58e52cc13964aae3fb (patch)
tree9d37b96a5ec1c3c53df5d92c2f2d86fcad65523c /gdb
parentaeb2e706e1b9c491d20c88c8ead1ae9df9cee04a (diff)
downloadgdb-a7e559cc087b10b9ea337b58e52cc13964aae3fb.zip
gdb-a7e559cc087b10b9ea337b58e52cc13964aae3fb.tar.gz
gdb-a7e559cc087b10b9ea337b58e52cc13964aae3fb.tar.bz2
gdbserver: Ensure all debug output uses debug functions
All debug output needs to go via debug functions to ensure it writes to the correct output stream. gdb/ChangeLog: * nat/linux-waitpid.c (linux_debug): Call debug_vprintf. gdb/gdbserver/ChangeLog: * ax.c (ax_vdebug): Call debug_printf. * debug.c (debug_write): New function. * debug.h (debug_write): New declaration. * linux-low.c (sigchld_handler): Call debug_write.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/gdbserver/ChangeLog7
-rw-r--r--gdb/gdbserver/ax.c4
-rw-r--r--gdb/gdbserver/debug.c9
-rw-r--r--gdb/gdbserver/debug.h3
-rw-r--r--gdb/gdbserver/linux-low.c7
-rw-r--r--gdb/nat/linux-waitpid.c2
7 files changed, 31 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f8120db..2fb4b87 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2019-04-17 Alan Hayward <alan.hayward@arm.com>
+
+ * nat/linux-waitpid.c (linux_debug): Call debug_vprintf.
+
2019-04-17 Jim Wilson <jimw@sifive.com>
Andrew Burgess <andrew.burgess@embecosm.com>
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index d3380d6..f8f600e 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,12 @@
2019-04-17 Alan Hayward <alan.hayward@arm.com>
+ * ax.c (ax_vdebug): Call debug_printf.
+ * debug.c (debug_write): New function.
+ * debug.h (debug_write): New declaration.
+ * linux-low.c (sigchld_handler): Call debug_write.
+
+2019-04-17 Alan Hayward <alan.hayward@arm.com>
+
* debug.c (debug_set_output): New function.
(debug_vprintf): Send output to debug_file.
(debug_flush): Likewise.
diff --git a/gdb/gdbserver/ax.c b/gdb/gdbserver/ax.c
index a16fba1..7b8df91 100644
--- a/gdb/gdbserver/ax.c
+++ b/gdb/gdbserver/ax.c
@@ -36,7 +36,11 @@ ax_vdebug (const char *fmt, ...)
va_start (ap, fmt);
vsprintf (buf, fmt, ap);
+#ifdef IN_PROCESS_AGENT
fprintf (stderr, PROG "/ax: %s\n", buf);
+#else
+ debug_printf (PROG "/ax: %s\n", buf);
+#endif
va_end (ap);
}
diff --git a/gdb/gdbserver/debug.c b/gdb/gdbserver/debug.c
index d80cd52..a1cf5db 100644
--- a/gdb/gdbserver/debug.c
+++ b/gdb/gdbserver/debug.c
@@ -130,3 +130,12 @@ do_debug_exit (const char *function_name)
if (function_name != NULL)
debug_printf ("<<<< exiting %s\n", function_name);
}
+
+/* See debug.h. */
+
+size_t
+debug_write (const void *buf, size_t nbyte)
+{
+ int fd = fileno (debug_file);
+ return write (fd, buf, nbyte);
+}
diff --git a/gdb/gdbserver/debug.h b/gdb/gdbserver/debug.h
index f65c91c..29e58ad 100644
--- a/gdb/gdbserver/debug.h
+++ b/gdb/gdbserver/debug.h
@@ -35,6 +35,9 @@ void debug_flush (void);
void do_debug_enter (const char *function_name);
void do_debug_exit (const char *function_name);
+/* Async signal safe debug output function that calls write directly. */
+size_t debug_write (const void *buf, size_t nbyte);
+
/* These macros are for use in major functions that produce a lot of
debugging output. They help identify in the mass of debugging output
when these functions enter and exit. debug_enter is intended to be
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 168f4b2..917b1c2 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -6185,10 +6185,9 @@ sigchld_handler (int signo)
{
do
{
- /* fprintf is not async-signal-safe, so call write
- directly. */
- if (write (2, "sigchld_handler\n",
- sizeof ("sigchld_handler\n") - 1) < 0)
+ /* Use the async signal safe debug function. */
+ if (debug_write ("sigchld_handler\n",
+ sizeof ("sigchld_handler\n") - 1) < 0)
break; /* just ignore */
} while (0);
}
diff --git a/gdb/nat/linux-waitpid.c b/gdb/nat/linux-waitpid.c
index e31c088..a7d11ab 100644
--- a/gdb/nat/linux-waitpid.c
+++ b/gdb/nat/linux-waitpid.c
@@ -42,7 +42,7 @@ linux_debug (const char *format, ...)
{
va_list args;
va_start (args, format);
- vfprintf (stderr, format, args);
+ debug_vprintf (format, args);
va_end (args);
}
#endif