[09/15] Mostly remove GDBSERVER from linux-waitpid.c
Commit Message
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
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?
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/
@@ -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
@@ -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"
@@ -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>
@@ -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;