diff mbox

[09/15] Mostly remove GDBSERVER from linux-waitpid.c

Message ID 1404902255-11101-10-git-send-email-gbenson@redhat.com
State Changes Requested, archived
Headers show

Commit Message

Gary Benson July 9, 2014, 10:37 a.m. UTC
This commit mostly removes the use of GDBSERVER from
nat/linux-waitpid.c.  A use remains for some debugging
code that I will remove when the Linux thread_db code
is refactored.

gdb/
2014-07-09  Gary Benson  <gbenson@redhat.com>

	* configure.ac [AC_CHECK_HEADERS] <errno.h>: New check.
	* configure: Regenerate.
	* config.in: Likewise.
	* nat/linux-waitpid.c: Don't include server.h or defs.h.
	(linux_debug) [debug_threads]: New declaration.
---
 gdb/ChangeLog           |    8 ++++++++
 gdb/config.in           |    3 +++
 gdb/configure           |    2 +-
 gdb/configure.ac        |    2 +-
 gdb/nat/linux-waitpid.c |   13 ++++++++-----
 5 files changed, 21 insertions(+), 7 deletions(-)

Comments

Doug Evans July 14, 2014, 6:59 p.m. UTC | #1
Gary Benson writes:
 > This commit mostly removes the use of GDBSERVER from
 > nat/linux-waitpid.c.  A use remains for some debugging
 > code that I will remove when the Linux thread_db code
 > is refactored.
 > 
 > gdb/
 > 2014-07-09  Gary Benson  <gbenson@redhat.com>
 > 
 > 	* configure.ac [AC_CHECK_HEADERS] <errno.h>: New check.
 > 	* configure: Regenerate.
 > 	* config.in: Likewise.
 > 	* nat/linux-waitpid.c: Don't include server.h or defs.h.
 > 	(linux_debug) [debug_threads]: New declaration.

gdb includes errno.h unconditionally,
so the test is for some gdbserver configs (right?).

It's going to be confusing to keep all the unconditional
inclusions of errno.h and yet seeing it tested for in configure.ac.
It would be good to document why things are the way they are.
E.g., add a comment to configure.ac or some such saying the test
is needed by common code used by gdb and gdbserver.

OTOH, I see there is gnulib/import/errno.in.h.
Can we solve this with gnulib and thus make errno.h
unconditionally includable everywhere?
Gary Benson July 15, 2014, 4:11 p.m. UTC | #2
Doug Evans wrote:
> Gary Benson writes:
> > This commit mostly removes the use of GDBSERVER from
> > nat/linux-waitpid.c.  A use remains for some debugging
> > code that I will remove when the Linux thread_db code
> > is refactored.
> > 
> > gdb/
> > 2014-07-09  Gary Benson  <gbenson@redhat.com>
> > 
> > 	* configure.ac [AC_CHECK_HEADERS] <errno.h>: New check.
> > 	* configure: Regenerate.
> > 	* config.in: Likewise.
> > 	* nat/linux-waitpid.c: Don't include server.h or defs.h.
> > 	(linux_debug) [debug_threads]: New declaration.
> 
> gdb includes errno.h unconditionally, so the test is for some
> gdbserver configs (right?).

I think so.

> It's going to be confusing to keep all the unconditional inclusions
> of errno.h and yet seeing it tested for in configure.ac.  It would
> be good to document why things are the way they are.  E.g., add a
> comment to configure.ac or some such saying the test is needed by
> common code used by gdb and gdbserver.
> 
> OTOH, I see there is gnulib/import/errno.in.h.
> Can we solve this with gnulib and thus make errno.h
> unconditionally includable everywhere?

I see gdb/gdbserver/linux-low.c includes errno.h unconditionally.
I'm going to assume from that that linux-waitpid.c can do the same.
I'll remove the conditionals from there and revert the configury
changes.

Thanks,
Gary

--
http://gbenson.net/
diff mbox

Patch

diff --git a/gdb/config.in b/gdb/config.in
index 8585b49..10b9887 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -129,6 +129,9 @@ 
 /* Define to 1 if you have the <elf_hp.h> header file. */
 #undef HAVE_ELF_HP_H
 
+/* Define to 1 if you have the <errno.h> header file. */
+#undef HAVE_ERRNO_H
+
 /* Define to 1 if your system has the etext variable. */
 #undef HAVE_ETEXT
 
diff --git a/gdb/configure b/gdb/configure
index a4c0a8c..45f3f5f 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -9307,7 +9307,7 @@  for ac_header in nlist.h machine/reg.h poll.h sys/poll.h proc_service.h \
 		  sys/reg.h sys/debugreg.h sys/select.h sys/syscall.h \
 		  termios.h termio.h \
 		  sgtty.h elf_hp.h \
-		  dlfcn.h
+		  dlfcn.h errno.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
diff --git a/gdb/configure.ac b/gdb/configure.ac
index a2ac15f..5f2ace4 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1254,7 +1254,7 @@  AC_CHECK_HEADERS([nlist.h machine/reg.h poll.h sys/poll.h proc_service.h \
 		  sys/reg.h sys/debugreg.h sys/select.h sys/syscall.h \
 		  termios.h termio.h \
 		  sgtty.h elf_hp.h \
-		  dlfcn.h])
+		  dlfcn.h errno.h])
 AC_CHECK_HEADERS(sys/proc.h, [], [],
 [#if HAVE_SYS_PARAM_H
 # include <sys/param.h>
diff --git a/gdb/nat/linux-waitpid.c b/gdb/nat/linux-waitpid.c
index 5159f03..b97ae58 100644
--- a/gdb/nat/linux-waitpid.c
+++ b/gdb/nat/linux-waitpid.c
@@ -17,11 +17,12 @@ 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifdef GDBSERVER
-#include "server.h"
-#else
-#include "defs.h"
-#include "signal.h"
+#include "config.h"
+
+#include <stdio.h>
+#include <stdarg.h>
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
 #endif
 
 #include "linux-nat.h"
@@ -37,6 +38,8 @@  static inline void
 linux_debug (const char *format, ...)
 {
 #ifdef GDBSERVER
+  extern int debug_threads;
+
   if (debug_threads)
     {
       va_list args;