This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC 1/2] link gdbserver against libiberty


Pedro> Well, looking at gdb's own Makefile, we see that install-only there
Pedro> already punts on "-only" when recursing, therefore never escaping
Pedro> that gdb-specific target elsewhere:

Pedro> gdb's Makefile:

Pedro> install-only: $(CONFIG_INSTALL)
Pedro> ...
Pedro>         @$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do

Pedro> It's just that gdbserver's currently doesn't.  Seems quite easy to
Pedro> do and just less magic.

Here's a revised patch.

Tom

2014-02-12  Tom Tromey  <tromey@redhat.com>

	* debug.c (debug_printf): Remove HAVE_GETTIMEOFDAY checks.
	* server.c (monitor_show_help): Remove HAVE_GETTIMEOFDAY check.
	(parse_debug_format_options): Likewise.
	(gdbserver_usage): Likewise.
	* Makefile.in (LIBIBERTY_BUILDDIR, LIBIBERTY): New variables.
	(SUBDIRS, REQUIRED_SUBDIRS): Add libiberty.
	(gdbserver$(EXEEXT), gdbreplay$(EXEEXT)): Depend on and link
	against libiberty.
	($(LIBGNU)): Depend on libiberty.
	(all-lib): Recurse into all subdirs.
	(install-only): Invoke "install" target in subdirs.
	(vasprintf.o, vsnprintf.o, safe-ctype.o, lbasename.o): Remove
	targets.
	* configure: Rebuild.
	* configure.ac: Add ACX_CONFIGURE_DIR for libiberty.  Don't check
	for vasprintf, vsnprintf, or gettimeofday.
	* configure.srv: Don't add safe-ctype.o or lbasename.o to
	srv_tgtobj.

commit 111ff97a644a43c4f84fea5b3a089d652676e668
Author: Tom Tromey <tromey@redhat.com>
Date:   Sun Jan 19 14:33:37 2014 -0700

    link gdbserver against libiberty
    
    This builds a libiberty just for gdbserver and arranges for gdbserver
    to use it.  I've tripped across the lack of libiberty in gdbserver at
    least once, and I have seen other threads where it would have been
    useful.
    
    2014-02-12  Tom Tromey  <tromey@redhat.com>
    
    	* debug.c (debug_printf): Remove HAVE_GETTIMEOFDAY checks.
    	* server.c (monitor_show_help): Remove HAVE_GETTIMEOFDAY check.
    	(parse_debug_format_options): Likewise.
    	(gdbserver_usage): Likewise.
    	* Makefile.in (LIBIBERTY_BUILDDIR, LIBIBERTY): New variables.
    	(SUBDIRS, REQUIRED_SUBDIRS): Add libiberty.
    	(gdbserver$(EXEEXT), gdbreplay$(EXEEXT)): Depend on and link
    	against libiberty.
    	($(LIBGNU)): Depend on libiberty.
    	(all-lib): Recurse into all subdirs.
    	(install-only): Invoke "install" target in subdirs.
    	(vasprintf.o, vsnprintf.o, safe-ctype.o, lbasename.o): Remove
    	targets.
    	* configure: Rebuild.
    	* configure.ac: Add ACX_CONFIGURE_DIR for libiberty.  Don't check
    	for vasprintf, vsnprintf, or gettimeofday.
    	* configure.srv: Don't add safe-ctype.o or lbasename.o to
    	srv_tgtobj.

diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index c172995..8305492 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -83,6 +83,9 @@ CC-LD=${CC}
 INCLUDE_DIR =  ${srcdir}/../../include
 INCLUDE_DEP = $$(INCLUDE_DIR)
 
+LIBIBERTY_BUILDDIR = build-libiberty-gdbserver
+LIBIBERTY = $(LIBIBERTY_BUILDDIR)/libiberty.a
+
 # Where is ust?  These will be empty if ust was not available.
 ustlibs = @ustlibs@
 ustinc = @ustinc@
@@ -190,14 +193,14 @@ XML_BUILTIN = @srv_xmlbuiltin@
 IPA_DEPFILES = @IPA_DEPFILES@
 extra_libraries = @extra_libraries@
 
-SUBDIRS = $(GNULIB_BUILDDIR)
+SUBDIRS = $(GNULIB_BUILDDIR) $(LIBIBERTY_BUILDDIR)
 CLEANDIRS = $(SUBDIRS)
 
 # List of subdirectories in the build tree that must exist.
 # This is used to force build failures in existing trees when
 # a new directory is added.
 # The format here is for the `case' shell command.
-REQUIRED_SUBDIRS = $(GNULIB_BUILDDIR)
+REQUIRED_SUBDIRS = $(GNULIB_BUILDDIR) | $(LIBIBERTY_BUILDDIR)
 
 FLAGS_TO_PASS = \
 	"prefix=$(prefix)" \
@@ -258,7 +261,10 @@ install-only:
 	fi; \
 	$(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(bindir); \
 	$(INSTALL_PROGRAM) gdbserver$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT)
-	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
+	# Note that we run install and not install-only, as the latter
+	# is not part of GNU standards and in particular not provided
+	# in libiberty.
+	@$(MAKE) $(FLAGS_TO_PASS) DO=install "DODIRS=$(SUBDIRS)" subdir_do
 
 uninstall: force
 	n=`echo gdbserver | sed '$(program_transform_name)'`; \
@@ -276,20 +282,20 @@ install-html:
 clean-info: force
 	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
 
-gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} ${CDEPS} $(LIBGNU)
+gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} ${CDEPS} $(LIBGNU) $(LIBIBERTY)
 	rm -f gdbserver$(EXEEXT)
 	${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbserver$(EXEEXT) $(OBS) \
-	$(LIBGNU) $(GDBSERVER_LIBS) $(XM_CLIBS)
+	$(LIBGNU) $(LIBIBERTY) $(GDBSERVER_LIBS) $(XM_CLIBS)
 
-$(LIBGNU) $(GNULIB_H): all-lib
-all-lib: $(GNULIB_BUILDDIR)/Makefile
-	@$(MAKE) $(FLAGS_TO_PASS) DO=all DODIRS=$(GNULIB_BUILDDIR) subdir_do
+$(LIBGNU) $(LIBIBERTY) $(GNULIB_H): all-lib
+all-lib: $(GNULIB_BUILDDIR)/Makefile $(LIBIBERTY_BUILDDIR)/Makefile
+	@$(MAKE) $(FLAGS_TO_PASS) DO=all DODIRS="$(SUBDIRS)" subdir_do
 .PHONY: all-lib
 
-gdbreplay$(EXEEXT): $(GDBREPLAY_OBS) $(LIBGNU)
+gdbreplay$(EXEEXT): $(GDBREPLAY_OBS) $(LIBGNU) $(LIBIBERTY)
 	rm -f gdbreplay$(EXEEXT)
 	${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbreplay$(EXEEXT) $(GDBREPLAY_OBS) \
-	  $(XM_CLIBS) $(LIBGNU)
+	  $(XM_CLIBS) $(LIBGNU) $(LIBIBERTY)
 
 IPA_OBJS=ax-ipa.o tracepoint-ipa.o format-ipa.o utils-ipa.o regcache-ipa.o remote-utils-ipa.o common-utils-ipa.o tdesc-ipa.o ${IPA_DEPFILES}
 
@@ -533,23 +539,6 @@ linux-waitpid.o: ../nat/linux-waitpid.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
-# We build vasprintf with -DHAVE_CONFIG_H because we want that unit to
-# include our config.h file.  Otherwise, some system headers do not get
-# included, and the compiler emits a warning about implicitly defined
-# functions (missing declaration).
-vasprintf.o: $(srcdir)/../../libiberty/vasprintf.c
-	$(COMPILE) $< -DHAVE_CONFIG_H
-	$(POSTCOMPILE)
-vsnprintf.o: $(srcdir)/../../libiberty/vsnprintf.c
-	$(COMPILE) $<
-	$(POSTCOMPILE)
-safe-ctype.o: $(srcdir)/../../libiberty/safe-ctype.c
-	$(COMPILE) $<
-	$(POSTCOMPILE)
-lbasename.o: $(srcdir)/../../libiberty/lbasename.c
-	$(COMPILE) $<
-	$(POSTCOMPILE)
-
 aarch64.c : $(srcdir)/../regformats/aarch64.dat $(regdat_sh)
 	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/aarch64.dat aarch64.c
 reg-arm.c : $(srcdir)/../regformats/reg-arm.dat $(regdat_sh)
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 0dfa4a9..16360c0 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -77,12 +77,14 @@ AC_PROG_MAKE_SET
 # build it in the same directory, when building in the source dir.
 ACX_CONFIGURE_DIR(["../gnulib"], ["build-gnulib-gdbserver"])
 
+ACX_CONFIGURE_DIR(["../../libiberty"], ["build-libiberty-gdbserver"])
+
 AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
 		 proc_service.h sys/procfs.h linux/elf.h dnl
 		 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
 		 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
 		 netinet/tcp.h arpa/inet.h)
-AC_CHECK_FUNCS(gettimeofday pread pwrite pread64 readlink)
+AC_CHECK_FUNCS(pread pwrite pread64 readlink)
 AC_REPLACE_FUNCS(vasprintf vsnprintf)
 
 GDB_AC_COMMON
diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index f4e6154..32d935a 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -77,7 +77,6 @@ case "${target}" in
 			;;
   arm*-*-mingw32ce*)	srv_regobj=reg-arm.o
 			srv_tgtobj="win32-low.o win32-arm-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_tgtobj="${srv_tgtobj} wincecompat.o"
 			# hostio_last_error implementation is in win32-low.c
 			srv_hostio_err_objs=""
@@ -101,7 +100,6 @@ case "${target}" in
 			;;
   i[34567]86-*-cygwin*)	srv_regobj="$srv_i386_regobj"
 			srv_tgtobj="i386-low.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			;;
   i[34567]86-*-linux*)	srv_regobj="$srv_i386_linux_regobj"
@@ -128,7 +126,6 @@ case "${target}" in
   i[34567]86-*-mingw32ce*)
 			srv_regobj="$srv_i386_regobj"
 			srv_tgtobj="i386-low.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_tgtobj="${srv_tgtobj} wincecompat.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			# hostio_last_error implementation is in win32-low.c
@@ -138,7 +135,6 @@ case "${target}" in
 			;;
   i[34567]86-*-mingw*)	srv_regobj="$srv_i386_regobj"
 			srv_tgtobj="i386-low.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			srv_mingw=yes
 			;;
@@ -330,13 +326,11 @@ case "${target}" in
 			;;
   x86_64-*-mingw*)	srv_regobj="$srv_amd64_regobj"
 			srv_tgtobj="i386-low.o i387-fp.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles $srv_amd64_xmlfiles"
 			srv_mingw=yes
 			;;
   x86_64-*-cygwin*)	srv_regobj="$srv_amd64_regobj"
 			srv_tgtobj="i386-low.o i387-fp.o win32-low.o win32-i386-low.o"
-			srv_tgtobj="${srv_tgtobj} safe-ctype.o lbasename.o"
 			srv_xmlfiles="$srv_i386_xmlfiles"
 			;;
 
diff --git a/gdb/gdbserver/debug.c b/gdb/gdbserver/debug.c
index 6f4d531..c50af76 100644
--- a/gdb/gdbserver/debug.c
+++ b/gdb/gdbserver/debug.c
@@ -36,7 +36,7 @@ void
 debug_printf (const char *msg, ...)
 {
   va_list args;
-#if defined (HAVE_GETTIMEOFDAY) && !defined (IN_PROCESS_AGENT)
+#if !defined (IN_PROCESS_AGENT)
   /* N.B. Not thread safe, and can't be used, as is, with IPA.  */
   static int new_line = 1;
 
@@ -57,7 +57,7 @@ debug_printf (const char *msg, ...)
   vfprintf (stderr, msg, args);
   va_end (args);
 
-#if defined (HAVE_GETTIMEOFDAY) && !defined (IN_PROCESS_AGENT)
+#if !defined (IN_PROCESS_AGENT)
   if (*msg)
     new_line = msg[strlen (msg) - 1] == '\n';
 #endif
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 88354be..314cc92 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -695,9 +695,7 @@ monitor_show_help (void)
   monitor_output ("  set debug-format option1[,option2,...]\n");
   monitor_output ("    Add additional information to debugging messages\n");
   monitor_output ("    Options: all, none");
-#ifdef HAVE_GETTIMEOFDAY
   monitor_output (", timestamp");
-#endif
   monitor_output ("\n");
   monitor_output ("  exit\n");
   monitor_output ("    Quit GDBserver\n");
@@ -973,14 +971,12 @@ parse_debug_format_options (const char *arg, int is_monitor)
 	  if (is_monitor)
 	    monitor_output ("All extra debug format options disabled.\n");
 	}
-#ifdef HAVE_GETTIMEOFDAY
       else if (strcmp (option, "timestamp") == 0)
 	{
 	  debug_timestamp = 1;
 	  if (is_monitor)
 	    monitor_output ("Timestamps will be added to debug output.\n");
 	}
-#endif
       else if (*option == '\0')
 	{
 	  /* An empty option, e.g., "--debug-format=foo,,bar", is ignored.  */
@@ -2831,9 +2827,7 @@ gdbserver_usage (FILE *stream)
 	   "                          Options:\n"
 	   "                            all\n"
 	   "                            none\n"
-#ifdef HAVE_GETTIMEOFDAY
 	   "                            timestamp\n"
-#endif
 	   "  --remote-debug        Enable remote protocol debugging output.\n"
 	   "  --version             Display version information and exit.\n"
 	   "  --wrapper WRAPPER --  Run WRAPPER to start new programs.\n"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]