Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Doug Evans <dje@google.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] lmemmem.patch
Date: Sun, 30 Mar 2008 21:37:00 -0000	[thread overview]
Message-ID: <20080330213540.GA2856@caradoc.them.org> (raw)
In-Reply-To: <e394668d0803241436w5160a2dfodd33d44b174cb9bf@mail.gmail.com>

On Mon, Mar 24, 2008 at 02:36:13PM -0700, Doug Evans wrote:
> On Mon, Mar 24, 2008 at 2:23 PM, Daniel Jacobowitz <drow@false.org> wrote:
> >  I have been thinking of adding support in the GDB build process to use
> >  gnulib directly.  I even have a patch.  I put it under the GDB
> >  subdirectory precisely to minimize integration and keeping-in-sync
> >  issues with libiberty; gnulib-tool makes it easy to update.
> 
> [for completeness' sake]
> 
> If/when you do this, make sure gdbserver can use the code too.

Here you go.  How does this look?  It frees us to rely on gnulib's
stdint.h, string.h, and other useful modules should we want them.  I
didn't make gdbserver completely use gnulib, only build memmem; I
tested this on Linux (memmem present) and Windows (memmem missing).
GDB will use the included memmem even on Linux, since glibc's is known
to be slower.

-- 
Daniel Jacobowitz
CodeSourcery

In the gdb directory, run:

  gnulib-tool --import --lib=libgnu --source-base=gnulib --m4-base=gnulib/m4 \
    --aux-dir=gnulib/aux memmem

Then apply this patch and run autoconf, aclocal, and automake (yes, automake)
in the gdb subdirectory.  Also run autoconf in the gdbserver directory.

2008-03-30  Daniel Jacobowitz  <dan@codesourcery.com>

	* Makefile.in (LIBGNU, INCGNU): Define.
	(INTERNAL_CFLAGS_BASE): Add INCGNU.
	(INTERNAL_LIBS, CLIBS, CDEPS): Add LIBGNU.
	(CLEANDIRS): New.
	($(LIBGNU), all-lib): New rules.
	(clean, distclean, do-maintainer-clean): Use CLEANDIRS.
	* configure.ac: Use gl_EARLY, gl_INIT, and AM_INIT_AUTOMAKE.
	Simplify AC_CONFIG_AUX_DIR.  Generate gnulib/Makefile.
	* gnulib: New directory, from gnulib-tool.
	* configure, aclocal.m4: Regenerated.

2008-03-30  Daniel Jacobowitz  <dan@codesourcery.com>

	* Makefile.in (LIBOBJS): New.
	(OBS): Use LIBOBJS.
	(memmem.o): New rule.
	* configure.ac: Use AC_CONFIG_LIBOBJ_DIR and check for memmem.
	* configure: Regenerated.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.996
diff -u -p -r1.996 Makefile.in
--- Makefile.in	26 Mar 2008 14:53:28 -0000	1.996
+++ Makefile.in	30 Mar 2008 21:28:20 -0000
@@ -160,6 +160,10 @@ LIBICONV = @LIBICONV@
 TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
 TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@
 
+# Helper code from gnulib.
+LIBGNU = gnulib/libgnu.a
+INCGNU = -I$(srcdir)/gnulib -Ignulib
+
 #
 # CLI sub directory definitons
 #
@@ -364,7 +368,7 @@ INTERNAL_CFLAGS_BASE = \
 	$(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \
 	$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) \
 	$(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \
-	$(INTL_CFLAGS) $(ENABLE_CFLAGS) $(INTERNAL_CPPFLAGS)
+	$(INTL_CFLAGS) $(INCGNU) $(ENABLE_CFLAGS) $(INTERNAL_CPPFLAGS)
 INTERNAL_WARN_CFLAGS = $(INTERNAL_CFLAGS_BASE) $(GDB_WARN_CFLAGS)
 INTERNAL_CFLAGS = $(INTERNAL_WARN_CFLAGS) $(GDB_WERROR_CFLAGS)
 
@@ -388,13 +392,13 @@ INTERNAL_LDFLAGS = $(CFLAGS) $(GLOBAL_CF
 # you can use 'CLIBS=$(INSTALLED_LIBS)' 'CDEPS='
 INSTALLED_LIBS=-lbfd -lreadline -lopcodes -liberty -ldecnumber \
 	$(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) @LIBS@ \
-	-lintl -liberty
+	-lintl -liberty $(LIBGNU)
 CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
 	$(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) @LIBS@ \
 	$(LIBICONV) $(LIBEXPAT) \
-	$(LIBIBERTY) $(WIN32LIBS)
+	$(LIBIBERTY) $(WIN32LIBS) $(LIBGNU)
 CDEPS = $(XM_CDEPS) $(TM_CDEPS) $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) \
-	$(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS)
+	$(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU)
 
 ADD_FILES = $(XM_ADD_FILES) $(TM_ADD_FILES) $(NAT_ADD_FILES)
 ADD_DEPS = $(XM_ADD_FILES) $(TM_ADD_FILES) $(NAT_ADD_FILES)
@@ -1077,6 +1081,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $
 TSOBS = inflow.o
 
 SUBDIRS = @subdirs@
+CLEANDIRS = $(SUBDIRS) gnulib
 
 # For now, shortcut the "configure GDB for fewer languages" stuff.
 YYFILES = c-exp.c \
@@ -1329,6 +1334,12 @@ $(TUI)$(EXEEXT): tui-main.o libgdb.a $(A
 		-o $(TUI)$(EXEEXT) tui-main.o libgdb.a \
 		$(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES)
 
+# Convenience rule to handle recursion.
+$(LIBGNU): all-lib
+all-lib:
+	@$(MAKE) $(FLAGS_TO_PASS) DO=all DODIRS=gnulib subdir_do
+.PHONY: all-lib
+
 # Create a library of the gdb object files and build GDB by linking
 # against that.
 #
@@ -1368,7 +1379,7 @@ TAGS: $(DEPFILES) $(TAGFILES_NO_SRCDIR) 
 tags: TAGS
 
 clean mostlyclean: $(CONFIG_CLEAN)
-	@$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(SUBDIRS)" subdir_do
+	@$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(CLEANDIRS)" subdir_do
 	rm -f *.o *.a $(ADD_FILES) *~ init.c-tmp init.l-tmp version.c-tmp
 	rm -f init.c version.c
 	rm -f gdb$(EXEEXT) core make.log
@@ -1387,7 +1398,7 @@ clean-tui:
 # NB: While GDBSERVER might be configured on native systems, it isn't
 # always included in SUBDIRS.  Remove the gdbserver files explicitly.
 distclean: clean
-	@$(MAKE) $(FLAGS_TO_PASS) DO=distclean "DODIRS=$(SUBDIRS)" subdir_do
+	@$(MAKE) $(FLAGS_TO_PASS) DO=distclean "DODIRS=$(CLEANDIRS)" subdir_do
 	rm -f gdbserver/config.status gdbserver/config.log
 	rm -f gdbserver/tm.h gdbserver/xm.h gdbserver/nm.h
 	rm -f gdbserver/Makefile gdbserver/config.cache
@@ -1414,7 +1425,7 @@ local-maintainer-clean:
 	rm -f nm.h config.status
 
 do-maintainer-clean:
-	@$(MAKE) $(FLAGS_TO_PASS) DO=maintainer-clean "DODIRS=$(SUBDIRS)" \
+	@$(MAKE) $(FLAGS_TO_PASS) DO=maintainer-clean "DODIRS=$(CLEANDIRS)" \
 		subdir_do
 
 diststuff: $(DISTSTUFF) $(PACKAGE).pot $(CATALOGS)
Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/configure.ac,v
retrieving revision 1.66
diff -u -p -r1.66 configure.ac
--- configure.ac	12 Mar 2008 14:10:53 -0000	1.66
+++ configure.ac	30 Mar 2008 21:28:20 -0000
@@ -1,6 +1,6 @@
 dnl Autoconf configure script for GDB, the GNU debugger.
 dnl Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-dnl 2005, 2006
+dnl 2005, 2006, 2007, 2008
 dnl Free Software Foundation, Inc.
 dnl
 dnl This file is part of GDB.
@@ -29,9 +29,10 @@ AC_PROG_CC
 AC_GNU_SOURCE
 AC_AIX
 AC_ISC_POSIX
+gl_EARLY
 AM_PROG_CC_STDC
 
-AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..)
+AC_CONFIG_AUX_DIR(..)
 AC_CANONICAL_SYSTEM
 
 dnl List of object files and targets accumulated by configure.
@@ -59,10 +60,16 @@ if test x"$USE_NLS" = xyes; then
    CONFIG_UNINSTALL="$CONFIG_UNINSTALL uninstall-po"
 fi
 
+gl_INIT
+
 PACKAGE=gdb
 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package. ])
 AC_SUBST(PACKAGE)
 
+# GDB does not use automake, but gnulib does.  This line lets us
+# generate its Makefile.in.
+AM_INIT_AUTOMAKE(gdb, UNUSED-VERSION, [no-define])
+
 debugdir=${libdir}/debug
 	 
 AC_ARG_WITH(separate-debug-dir,
@@ -207,8 +214,6 @@ if test "x$targ_defvec" != x; then
     [Define to BFD's default target vector. ])
 fi
 
-AC_ARG_PROGRAM
-
 # The CLI cannot be disabled yet, but may be in the future.
 
 # Enable CLI.
@@ -1721,7 +1726,7 @@ AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "ISO
 
 AM_ICONV
 
-AC_OUTPUT(Makefile .gdbinit:gdbinit.in,
+AC_OUTPUT(Makefile .gdbinit:gdbinit.in gnulib/Makefile,
 [
 dnl Autoconf doesn't provide a mechanism for modifying definitions 
 dnl provided by makefile fragments.
Index: gdbserver/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/Makefile.in,v
retrieving revision 1.56
diff -u -p -r1.56 Makefile.in
--- gdbserver/Makefile.in	28 Feb 2008 05:55:55 -0000	1.56
+++ gdbserver/Makefile.in	30 Mar 2008 21:28:20 -0000
@@ -136,6 +136,8 @@ SFILES=	$(srcdir)/gdbreplay.c $(srcdir)/
 
 DEPFILES = @GDBSERVER_DEPFILES@
 
+LIBOBJS = @LIBOBJS@
+
 SOURCES = $(SFILES)
 TAGFILES = $(SOURCES) ${HFILES} ${ALLPARAM} ${POSSLIBS} 
 
@@ -143,7 +145,7 @@ OBS = inferiors.o regcache.o remote-util
 	utils.o version.o \
 	mem-break.o hostio.o \
 	$(XML_BUILTIN) \
-	$(DEPFILES)
+	$(DEPFILES) $(LIBOBJS)
 GDBSERVER_LIBS = @GDBSERVER_LIBS@
 XM_CLIBS = @LIBS@
 
@@ -289,6 +291,9 @@ utils.o: utils.c $(server_h)
 signals.o: ../signals/signals.c $(server_h)
 	$(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< -DGDBSERVER
 
+memmem.o: ../gnulib/memmem.c
+	$(CC) -o memmem.o -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $<
+
 i387-fp.o: i387-fp.c $(server_h)
 
 linux_low_h = $(srcdir)/linux-low.h
Index: gdbserver/configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/configure.ac,v
retrieving revision 1.21
diff -u -p -r1.21 configure.ac
--- gdbserver/configure.ac	28 Feb 2008 05:54:09 -0000	1.21
+++ gdbserver/configure.ac	30 Mar 2008 21:28:20 -0000
@@ -23,6 +23,7 @@ AC_PREREQ(2.59)dnl
 
 AC_INIT(server.c)
 AC_CONFIG_HEADER(config.h:config.in)
+AC_CONFIG_LIBOBJ_DIR(../gnulib)
 
 AC_PROG_CC
 AC_GNU_SOURCE
@@ -42,6 +43,7 @@ AC_CHECK_HEADERS(sgtty.h termio.h termio
 		 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
 		 netinet/tcp.h arpa/inet.h sys/wait.h)
 AC_CHECK_FUNCS(pread pwrite pread64)
+AC_REPLACE_FUNCS(memmem)
 
 have_errno=no
 AC_MSG_CHECKING(for errno)


       reply	other threads:[~2008-03-30 21:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200803241737.m2OHbgC8016762@greed.delorie.com>
     [not found] ` <e394668d0803241050w6a1f341u585fb4906135a44b@mail.gmail.com>
     [not found]   ` <200803241758.m2OHwDid017265@greed.delorie.com>
     [not found]     ` <e394668d0803241333nedb753j9b7b1593c6d3989f@mail.gmail.com>
     [not found]       ` <20080324203738.GC29991@ins.uni-bonn.de>
     [not found]         ` <e394668d0803241346h5006b63du8997cf9e081dc907@mail.gmail.com>
     [not found]           ` <20080324205119.GE29991@ins.uni-bonn.de>
     [not found]             ` <e394668d0803241420w3db1813bj4aa7803b74f3d40b@mail.gmail.com>
     [not found]               ` <20080324212354.GA16323@caradoc.them.org>
     [not found]                 ` <e394668d0803241436w5160a2dfodd33d44b174cb9bf@mail.gmail.com>
2008-03-30 21:37                   ` Daniel Jacobowitz [this message]
2008-03-31 16:10                     ` [RFC] gnulib (was: Re: [RFA] lmemmem.patch) Daniel Jacobowitz
2008-03-31 18:35                     ` [RFA] lmemmem.patch Doug Evans
2008-04-14 18:27                       ` Daniel Jacobowitz
2008-04-15 11:55                         ` Pierre Muller
2008-04-15 11:59                           ` Corinna Vinschen
2008-04-15 13:08                           ` 'Daniel Jacobowitz'
2008-04-15 13:15                             ` Pierre Muller
2008-04-15 13:37                               ` Corinna Vinschen
2008-04-15 14:12                                 ` Pierre Muller
2008-04-15 14:44                                   ` Corinna Vinschen
2008-04-15 14:57                                   ` Daniel Jacobowitz
2008-04-15 15:40                                     ` Pierre Muller
2008-04-15 17:14                                       ` 'Daniel Jacobowitz'
2008-04-15 18:07                                         ` Pierre Muller
2008-04-09 23:04                     ` Doug Evans
2008-04-10  5:31                       ` Daniel Jacobowitz
2008-04-14 18:59 Aleksandar Ristovski
2008-04-14 19:13 ` Daniel Jacobowitz
2008-04-14 19:14 Aleksandar Ristovski
2008-04-14 20:00 ` Daniel Jacobowitz
2008-04-14 23:46 Aleksandar Ristovski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080330213540.GA2856@caradoc.them.org \
    --to=drow@false.org \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox