Skip to contentSkip to conversation

package: add the duma memory debugging library

PATCH New Baruch Siach 3 participants 4 messages Oct 5, 2011 – Oct 6, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package: add the duma memory debugging library

---
Hi Yann,

Might this collide somehow with the optional duma support of crosstool-ng?

baruch

 package/Config.in                            |    1 +
 package/duma/Config.in                       |   15 +++++++++++
 package/duma/duma-2_5_15-cross-compile.patch |   36 ++++++++++++++++++++++++++
 package/duma/duma-2_5_15-separate-cpp.patch  |   23 ++++++++++++++++
 package/duma/duma.mk                         |   36 ++++++++++++++++++++++++++
 5 files changed, 111 insertions(+), 0 deletions(-)
 create mode 100644 package/duma/Config.in
 create mode 100644 package/duma/duma-2_5_15-cross-compile.patch
 create mode 100644 package/duma/duma-2_5_15-separate-cpp.patch
 create mode 100644 package/duma/duma.mk
package/Config.in +1 -0
index fd920c3..d565216 100644
@@ -20,6 +20,7 @@ menu "Debugging, profiling and benchmark"
 source "package/bonnie/Config.in"
 source "package/dhrystone/Config.in"
 source "package/dmalloc/Config.in"
+source "package/duma/Config.in"
 source "package/kexec/Config.in"
 source "package/lmbench/Config.in"
 source "package/lsof/Config.in"
package/duma/Config.in new file +15 -0
new file mode 100644
index 0000000..7f7a765
@@ -0,0 +1,15 @@
+config BR2_PACKAGE_DUMA
+	bool "duma"
+	help
+	  D.U.M.A. - Detect Unintended Memory Access. A fork of the Electric
+	  Fence library. Detects buffer overflow and underflow, and also memory
+	  leaks.
+
+	  http://duma.sourceforge.net
+
+if BR2_PACKAGE_DUMA
+
+config BR2_PACKAGE_DUMA_NO_LEAKDETECTION
+	bool "disable memory leak detection"
+
+endif # BR2_PACKAGE_DUMA
package/duma/duma-2_5_15-cross-compile.patch new file +36 -0
new file mode 100644
index 0000000..d50ac20
@@ -0,0 +1,36 @@
+Allow cross compilation. Taken from crosstool-ng.
+
+Signed-off-by: Baruch Siach <[email protected]>
+---
+diff -durN duma_2_5_15.orig/GNUmakefile duma_2_5_15/GNUmakefile
+--- duma_2_5_15.orig/GNUmakefile	2008-08-03 21:22:38.000000000 +0200
++++ duma_2_5_15/GNUmakefile	2009-06-19 15:32:23.000000000 +0200
+@@ -93,10 +93,6 @@
+ # also define 'WIN32'
+ 
+ # some defaults:
+-CC=gcc
+-CXX=g++
+-AR=ar
+-RANLIB=ranlib
+ INSTALL=install
+ RM=rm
+ RMFORCE=rm -f
+@@ -471,7 +467,7 @@
+ 
+ createconf$(EXEPOSTFIX): createconf.o
+ 	- $(RMFORCE) createconf$(EXEPOSTFIX)
+-	$(CC) $(CFLAGS) $(DUMA_OPTIONS) createconf.o -o createconf$(EXEPOSTFIX)
++	$(HOSTCC) $(HOSTCFLAGS) $(DUMA_OPTIONS) createconf.o -o createconf$(EXEPOSTFIX)
+ 
+ tstheap$(EXEPOSTFIX): libduma.a tstheap.o
+ 	- $(RMFORCE) tstheap$(EXEPOSTFIX)
+@@ -532,7 +528,7 @@
+ # define rules how to build objects for createconf
+ #
+ createconf.o:
+-	$(CC) $(CFLAGS) $(DUMA_OPTIONS) -c createconf.c -o $@
++	$(HOSTCC) $(HOSTCFLAGS) $(DUMA_OPTIONS) -c createconf.c -o $@
+ 
+ 
+ #
package/duma/duma-2_5_15-separate-cpp.patch new file +23 -0
new file mode 100644
index 0000000..ad10882
@@ -0,0 +1,23 @@
+Allow build without C++ support. Taken from crosstool-ng.
+
+Signed-off-by: Baruch Siach <[email protected]>
+---
+diff -durN duma_2_5_15.orig/GNUmakefile duma_2_5_15/GNUmakefile
+--- duma_2_5_15.orig/GNUmakefile	2009-06-19 16:41:53.000000000 +0200
++++ duma_2_5_15/GNUmakefile	2009-06-19 16:43:53.000000000 +0200
+@@ -289,9 +289,13 @@
+ 	dumatest.c tstheap.c thread-test.c testmt.c dumatestpp.cpp testoperators.cpp \
+ 	createconf.c
+ 
+-OBJECTS=dumapp.o duma.o sem_inc.o print.o
++OBJECTS = duma.o sem_inc.o print.o
++SO_OBJECTS = duma_so.o sem_inc_so.o print_so.o
+ 
+-SO_OBJECTS=dumapp_so.o duma_so.o sem_inc_so.o print_so.o
++ifeq ($(DUMA_CPP),1)
++OBJECTS += dumapp.o
++SO_OBJECTS += dumapp_so.o
++endif
+ 
+ # Make all the top-level targets the makefile knows about.
+ all:	libduma.a tstheap$(EXEPOSTFIX) dumatest$(EXEPOSTFIX) thread-test$(EXEPOSTFIX) testmt$(EXEPOSTFIX) dumatestpp$(EXEPOSTFIX) testoperators$(EXEPOSTFIX) $(DUMA_DYN_DEPS)
package/duma/duma.mk new file +36 -0
new file mode 100644
index 0000000..3b8675b
@@ -0,0 +1,36 @@
+#############################################################
+#
+# duma
+#
+#############################################################
+DUMA_VERSION = 2_5_15
+DUMA_SOURCE = duma_$(DUMA_VERSION).tar.gz
+DUMA_SITE = http://$(BR2_SOURCEFORGE_MIRROR).dl.sourceforge.net/sourceforge/duma
+DUMA_INSTALL_STAGING = YES
+
+DUMA_OPTIONS = $(if $(BR2_PACKAGE_DUMA_NO_LEAKDETECTION), \
+			-DDUMA_LIB_NO_LEAKDETECTION)
+
+ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
+DUMA_CPP = DUMA_CPP=1
+else
+DUMA_CPP =
+endif
+
+# The dependency of some source files in duma_config.h, which is generated at 
+# build time, is not specified in the Makefile. Force non-parallel build.
+define DUMA_BUILD_CMDS
+	$(MAKE1) CC=$(TARGET_CC) CXX=$(TARGET_CXX) AR=$(TARGET_AR) \
+		RANLIB=$(TARGET_RANLIB) DUMA_OPTIONS=$(strip $(DUMA_OPTIONS)) \
+		$(DUMA_CPP) -C $(@D)
+endef
+
+define DUMA_INSTALL_STAGING_CMDS
+	$(MAKE) prefix=$(STAGING_DIR) install -C $(@D)
+endef
+
+define DUMA_INSTALL_TARGET_CMDS
+	$(MAKE) prefix=$(TARGET_DIR) install -C $(@D)
+endef
+
+$(eval $(call GENTARGETS))
Signature · 1 line
1.7.6.3
#1 lore raw

PATCH 1/1 package: add the duma memory debugging library

Baruch, All,

Quoted 2 lines · On Wednesday 05 October 2011 08:20:05 Baruch Siach wrote:

Comments in-lined below, in the patch...

Quoted 4 lines

---
Hi Yann,

Might this collide somehow with the optional duma support of crosstool-ng?

No, there will be no conflict, as the DUMA entry in crosstool-NG is not available when acting as the toolchain backend in buildroot.

But if crosstool-NG is used outside of buildroot to produce a toolchain, and that toolchain is used as an external toolchain, there will be a conflict.

But that case is probably a corner case; the user has to be somewhat responsible for his/her choices.

Quoted 138 lines

baruch

 package/Config.in                            |    1 +
 package/duma/Config.in                       |   15 +++++++++++
 package/duma/duma-2_5_15-cross-compile.patch |   36 ++++++++++++++++++++++++++
 package/duma/duma-2_5_15-separate-cpp.patch  |   23 ++++++++++++++++
 package/duma/duma.mk                         |   36 ++++++++++++++++++++++++++
 5 files changed, 111 insertions(+), 0 deletions(-)
 create mode 100644 package/duma/Config.in
 create mode 100644 package/duma/duma-2_5_15-cross-compile.patch
 create mode 100644 package/duma/duma-2_5_15-separate-cpp.patch
 create mode 100644 package/duma/duma.mk
package/Config.in +1 -0
index fd920c3..d565216 100644
@@ -20,6 +20,7 @@ menu "Debugging, profiling and benchmark"
 source "package/bonnie/Config.in"
 source "package/dhrystone/Config.in"
 source "package/dmalloc/Config.in"
+source "package/duma/Config.in"
 source "package/kexec/Config.in"
 source "package/lmbench/Config.in"
 source "package/lsof/Config.in"
package/duma/Config.in new file +15 -0
new file mode 100644
index 0000000..7f7a765
@@ -0,0 +1,15 @@
+config BR2_PACKAGE_DUMA
+	bool "duma"
+	help
+	  D.U.M.A. - Detect Unintended Memory Access. A fork of the Electric
+	  Fence library. Detects buffer overflow and underflow, and also memory
+	  leaks.
+
+	  http://duma.sourceforge.net
+
+if BR2_PACKAGE_DUMA
+
+config BR2_PACKAGE_DUMA_NO_LEAKDETECTION
+	bool "disable memory leak detection"
+
+endif # BR2_PACKAGE_DUMA
package/duma/duma-2_5_15-cross-compile.patch new file +36 -0
new file mode 100644
index 0000000..d50ac20
@@ -0,0 +1,36 @@
+Allow cross compilation. Taken from crosstool-ng.
+
+Signed-off-by: Baruch Siach <[email protected]>
+---
+diff -durN duma_2_5_15.orig/GNUmakefile duma_2_5_15/GNUmakefile
+--- duma_2_5_15.orig/GNUmakefile	2008-08-03 21:22:38.000000000 +0200
++++ duma_2_5_15/GNUmakefile	2009-06-19 15:32:23.000000000 +0200
+@@ -93,10 +93,6 @@
+ # also define 'WIN32'
+ 
+ # some defaults:
+-CC=gcc
+-CXX=g++
+-AR=ar
+-RANLIB=ranlib
+ INSTALL=install
+ RM=rm
+ RMFORCE=rm -f
+@@ -471,7 +467,7 @@
+ 
+ createconf$(EXEPOSTFIX): createconf.o
+ 	- $(RMFORCE) createconf$(EXEPOSTFIX)
+-	$(CC) $(CFLAGS) $(DUMA_OPTIONS) createconf.o -o createconf$(EXEPOSTFIX)
++	$(HOSTCC) $(HOSTCFLAGS) $(DUMA_OPTIONS) createconf.o -o createconf$(EXEPOSTFIX)
+ 
+ tstheap$(EXEPOSTFIX): libduma.a tstheap.o
+ 	- $(RMFORCE) tstheap$(EXEPOSTFIX)
+@@ -532,7 +528,7 @@
+ # define rules how to build objects for createconf
+ #
+ createconf.o:
+-	$(CC) $(CFLAGS) $(DUMA_OPTIONS) -c createconf.c -o $@
++	$(HOSTCC) $(HOSTCFLAGS) $(DUMA_OPTIONS) -c createconf.c -o $@
+ 
+ 
+ #
package/duma/duma-2_5_15-separate-cpp.patch new file +23 -0
new file mode 100644
index 0000000..ad10882
@@ -0,0 +1,23 @@
+Allow build without C++ support. Taken from crosstool-ng.
+
+Signed-off-by: Baruch Siach <[email protected]>
+---
+diff -durN duma_2_5_15.orig/GNUmakefile duma_2_5_15/GNUmakefile
+--- duma_2_5_15.orig/GNUmakefile	2009-06-19 16:41:53.000000000 +0200
++++ duma_2_5_15/GNUmakefile	2009-06-19 16:43:53.000000000 +0200
+@@ -289,9 +289,13 @@
+ 	dumatest.c tstheap.c thread-test.c testmt.c dumatestpp.cpp testoperators.cpp \
+ 	createconf.c
+ 
+-OBJECTS=dumapp.o duma.o sem_inc.o print.o
++OBJECTS = duma.o sem_inc.o print.o
++SO_OBJECTS = duma_so.o sem_inc_so.o print_so.o
+ 
+-SO_OBJECTS=dumapp_so.o duma_so.o sem_inc_so.o print_so.o
++ifeq ($(DUMA_CPP),1)
++OBJECTS += dumapp.o
++SO_OBJECTS += dumapp_so.o
++endif
+ 
+ # Make all the top-level targets the makefile knows about.
+ all:	libduma.a tstheap$(EXEPOSTFIX) dumatest$(EXEPOSTFIX) thread-test$(EXEPOSTFIX) testmt$(EXEPOSTFIX) dumatestpp$(EXEPOSTFIX) testoperators$(EXEPOSTFIX) $(DUMA_DYN_DEPS)
package/duma/duma.mk new file +15 -0
new file mode 100644
index 0000000..3b8675b
@@ -0,0 +1,36 @@
+#############################################################
+#
+# duma
+#
+#############################################################
+DUMA_VERSION = 2_5_15
+DUMA_SOURCE = duma_$(DUMA_VERSION).tar.gz
+DUMA_SITE = http://$(BR2_SOURCEFORGE_MIRROR).dl.sourceforge.net/sourceforge/duma
+DUMA_INSTALL_STAGING = YES
+
+DUMA_OPTIONS = $(if $(BR2_PACKAGE_DUMA_NO_LEAKDETECTION), \
+			-DDUMA_LIB_NO_LEAKDETECTION)
+
+ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
+DUMA_CPP = DUMA_CPP=1

package/duma/duma.mk line 25

Quoted 10 lines
package/duma/duma.mk new file +10 -0
+else
+DUMA_CPP =
+endif
+
+# The dependency of some source files in duma_config.h, which is generated at 
+# build time, is not specified in the Makefile. Force non-parallel build.
+define DUMA_BUILD_CMDS
+	$(MAKE1) CC=$(TARGET_CC) CXX=$(TARGET_CXX) AR=$(TARGET_AR) \
+		RANLIB=$(TARGET_RANLIB) DUMA_OPTIONS=$(strip $(DUMA_OPTIONS)) \
+		$(DUMA_CPP) -C $(@D)

You forgot to pass HOSTCC, introduced in duma-2_5_15-cross-compile.patch

package/duma/duma.mk line 36

Quoted 12 lines
package/duma/duma.mk new file +11 -0
+endef
+
+define DUMA_INSTALL_STAGING_CMDS
+	$(MAKE) prefix=$(STAGING_DIR) install -C $(@D)
+endef
+
+define DUMA_INSTALL_TARGET_CMDS
+	$(MAKE) prefix=$(TARGET_DIR) install -C $(@D)
+endef
+
+$(eval $(call GENTARGETS))

Otherwise, looks good.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH 1/1 package: add the duma memory debugging library

Le Wed, 5 Oct 2011 19:35:41 +0200,
"Yann E. MORIN" <[email protected]> a ?crit :

Quoted 5 lines

package/duma/duma.mk line 25

Quoted 3 lines
package/duma/duma.mk new file +3 -0
+	$(MAKE1) CC=$(TARGET_CC) CXX=$(TARGET_CXX) AR=$(TARGET_AR) \
+		RANLIB=$(TARGET_RANLIB) DUMA_OPTIONS=$(strip $(DUMA_OPTIONS)) \
+		$(DUMA_CPP) -C $(@D)

You forgot to pass HOSTCC, introduced in duma-2_5_15-cross-compile.patch

Probably something like:

	$(MAKE1) $(TARGET_CONFIGURE_OPTS) DUMA_OPTIONS=... -C $(@D)

would be even better. But then, the duma-2_5_15-cross-compile.patch would have to use CC_FOR_BUILD instead of HOSTCC to find the location of the native host compiler.

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#3 lore raw

PATCH 1/1 package: add the duma memory debugging library

Hi Thomas, Yann,

Quoted 8 lines · Thomas Petazzoni

Le Wed, 5 Oct 2011 19:35:41 +0200,
"Yann E. MORIN" <[email protected]> a ?crit :

Quoted 5 lines

package/duma/duma.mk line 25

Quoted 3 lines
package/duma/duma.mk new file +3 -0
+	$(MAKE1) CC=$(TARGET_CC) CXX=$(TARGET_CXX) AR=$(TARGET_AR) \
+		RANLIB=$(TARGET_RANLIB) DUMA_OPTIONS=$(strip $(DUMA_OPTIONS)) \
+		$(DUMA_CPP) -C $(@D)

You forgot to pass HOSTCC, introduced in duma-2_5_15-cross-compile.patch

Well, HOSTCC is set in the top Makefile.

Quoted 7 lines

Probably something like:

	$(MAKE1) $(TARGET_CONFIGURE_OPTS) DUMA_OPTIONS=... -C $(@D)

would be even better. But then, the duma-2_5_15-cross-compile.patch would have to use CC_FOR_BUILD instead of HOSTCC to find the location of the native host compiler.

Looks better. I'll update the patch. Thanks.

baruch

Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -