[1/4] gdbserver: Move remote_debug to a single place

Message ID 20190416101729.16176-2-alan.hayward@arm.com
State New
Headers show
Series
  • gdbserver/testsuite : Capture gdbserver debug output during testing
Related show

Commit Message

Alan Hayward April 16, 2019, 10:17 a.m.
A comment in debug.h (written in 2014) states: "We declare debug format
variables here, and debug_threads but no other debug content variables
(e.g., not remote_debug) because while this file is not currently used by
IPA it may be some day, and IPA may have its own set of debug content
variables".

This has resulted in remote_debug being declared in many .c/.h files
throughout gdbserver.

It would be much simplier to define it one place.  The most logical place to
define it is in debug.h, surrounded by #define guards.  If IPA is changed,
then at that point the variable can be moved elsewhere.

Also removes the unused gdb_stdlog variable.

gdb/gdbserver/ChangeLog:

2019-04-16  Alan Hayward  <alan.hayward@arm.com>

	* debug.c (remote_debug): Add definition.
	* debug.h (remote_debug): Add declaration.
	* hostio.c (remote_debug): Remove declaration.
	* remote-utils.c (struct ui_file): Likewise.
	(remote_debug): Likewise.
	* remote-utils.h (remote_debug): Likewise,
	* server.c (remote_debug): Remove definition.
---
 gdb/gdbserver/debug.c        |  4 ++++
 gdb/gdbserver/debug.h        | 11 ++++-------
 gdb/gdbserver/hostio.c       |  2 --
 gdb/gdbserver/remote-utils.c |  3 ---
 gdb/gdbserver/remote-utils.h |  2 --
 gdb/gdbserver/server.c       |  2 --
 6 files changed, 8 insertions(+), 16 deletions(-)

-- 
2.20.1 (Apple Git-117)

Comments

Tom Tromey April 16, 2019, 7:31 p.m. | #1
>>>>> "Alan" == Alan Hayward <Alan.Hayward@arm.com> writes:


Alan> Also removes the unused gdb_stdlog variable.

I looked and this is referenced from common/observable.h; but I suppose
that could be converted to use debug_vprintf or similar if it's ever
used in gdbserver.

Alan> 2019-04-16  Alan Hayward  <alan.hayward@arm.com>
Alan> 	* debug.c (remote_debug): Add definition.
Alan> 	* debug.h (remote_debug): Add declaration.
Alan> 	* hostio.c (remote_debug): Remove declaration.
Alan> 	* remote-utils.c (struct ui_file): Likewise.
Alan> 	(remote_debug): Likewise.
Alan> 	* remote-utils.h (remote_debug): Likewise,
Alan> 	* server.c (remote_debug): Remove definition.

Thanks, this is ok.

Tom

Patch

diff --git a/gdb/gdbserver/debug.c b/gdb/gdbserver/debug.c
index a5b791b6df..7c4c77afe2 100644
--- a/gdb/gdbserver/debug.c
+++ b/gdb/gdbserver/debug.c
@@ -19,6 +19,10 @@ 
 #include "server.h"
 #include <chrono>
 
+#if !defined (IN_PROCESS_AGENT)
+int remote_debug = 0;
+#endif
+
 /* Enable miscellaneous debugging output.  The name is historical - it
    was originally used to debug LinuxThreads support.  */
 int debug_threads;
diff --git a/gdb/gdbserver/debug.h b/gdb/gdbserver/debug.h
index e40f28c771..c8d5e3365e 100644
--- a/gdb/gdbserver/debug.h
+++ b/gdb/gdbserver/debug.h
@@ -19,13 +19,10 @@ 
 #ifndef GDBSERVER_DEBUG_H
 #define GDBSERVER_DEBUG_H
 
-/* We declare debug format variables here, and debug_threads but no other
-   debug content variables (e.g., not remote_debug) because while this file
-   is not currently used by IPA it may be some day, and IPA may have its own
-   set of debug content variables.  It's ok to declare debug_threads here
-   because it is misnamed - a better name is debug_basic or some such,
-   which can work for any program, gdbserver or IPA.  If/when this file is
-   used with IPA it is recommended to fix debug_thread's name.  */
+#if !defined (IN_PROCESS_AGENT)
+extern int remote_debug;
+#endif
+
 extern int debug_threads;
 extern int debug_timestamp;
 
diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c
index cf75de0c00..eedf6d9fe7 100644
--- a/gdb/gdbserver/hostio.c
+++ b/gdb/gdbserver/hostio.c
@@ -29,8 +29,6 @@ 
 #include <sys/stat.h>
 #include "common/fileio.h"
 
-extern int remote_debug;
-
 struct fd_list
 {
   int fd;
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 4e6f9c62de..903d77349d 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -108,9 +108,6 @@  struct sym_cache
   struct sym_cache *next;
 };
 
-int remote_debug = 0;
-struct ui_file *gdb_stdlog;
-
 static int remote_is_stdio = 0;
 
 static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR;
diff --git a/gdb/gdbserver/remote-utils.h b/gdb/gdbserver/remote-utils.h
index 587afdb028..4ca5d9435e 100644
--- a/gdb/gdbserver/remote-utils.h
+++ b/gdb/gdbserver/remote-utils.h
@@ -19,8 +19,6 @@ 
 #ifndef GDBSERVER_REMOTE_UTILS_H
 #define GDBSERVER_REMOTE_UTILS_H
 
-extern int remote_debug;
-
 int gdb_connected (void);
 
 #define STDIO_CONNECTION_NAME "stdio"
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index f2c8f15169..3f6c849dbc 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -328,8 +328,6 @@  attach_inferior (int pid)
   return 0;
 }
 
-extern int remote_debug;
-
 /* Decode a qXfer read request.  Return 0 if everything looks OK,
    or -1 otherwise.  */