[patch] wrap debugging code

Bernhard Fischer rep.nop at aon.at
Sat Jan 28 18:39:11 UTC 2006


Hi there,

Attached patchlet wraps some debugging stuff in macros accordingly and
also removes a bit of whitespace.

I'd like to hear where these macros should be put, see e.g dl-startup.c
the definition of LD_DEBUG_EARLY_DO and also __MALLOC_DO_DEBUG.


-------------- next part --------------
diff -X excl -rduNp uClibc.oorig/include/libc-symbols.h uClibc/include/libc-symbols.h
--- uClibc.oorig/include/libc-symbols.h	2006-01-27 08:24:48.000000000 +0100
+++ uClibc/include/libc-symbols.h	2006-01-28 17:57:05.000000000 +0100
@@ -27,7 +27,7 @@
 #define _GNU_SOURCE 1
 
 /* Prepare for the case that `__builtin_expect' is not available.  */
-#if __GNUC__ == 2 && __GNUC_MINOR__ < 96
+#if (defined __GNUC__ && (__GNUC__ == 2 && __GNUC_MINOR__ < 96))
 # define __builtin_expect(x, expected_value) (x)
 #endif
 #ifndef likely
diff -X excl -rduNp uClibc.oorig/ldso/include/unsecvars.h uClibc/ldso/include/unsecvars.h
--- uClibc.oorig/ldso/include/unsecvars.h	2005-11-23 22:01:16.000000000 +0100
+++ uClibc/ldso/include/unsecvars.h	2006-01-28 17:57:12.000000000 +0100
@@ -5,7 +5,7 @@
  * GNU Lesser General Public License version 2.1 or later.
  */
 
-/* 
+/*
  * Environment variable to be removed for SUID programs.  The names are all
  * stuffed in a single string which means they have to be terminated with a
  * '\0' explicitly.
@@ -19,7 +19,7 @@
 	"LD_TRACE_LOADED_OBJECTS\0" \
 	"TMPDIR\0"
 
-/* 
+/*
  * LD_TRACE_LOADED_OBJECTS is not in glibc-2.3.5's unsecvars.h
  * though used by ldd
  *
diff -X excl -rduNp uClibc.oorig/ldso/ldso/dl-startup.c uClibc/ldso/ldso/dl-startup.c
--- uClibc.oorig/ldso/ldso/dl-startup.c	2006-01-17 12:30:03.000000000 +0100
+++ uClibc/ldso/ldso/dl-startup.c	2006-01-28 18:06:14.000000000 +0100
@@ -266,19 +266,26 @@ static void * __attribute_used__ _dl_sta
 				symbol_addr = 0;
 				sym = NULL;
 				if (symtab_index) {
-					char *strtab;
+/* XXX: move this to some better place */
+#ifdef __SUPPORT_LD_DEBUG_EARLY__
+#define LD_DEBUG_EARLY_DO(...) __VA_ARGS__
+#else
+#define LD_DEBUG_EARLY_DO(...)
+#endif
+					LD_DEBUG_EARLY_DO(char *strtab;)
 					ElfW(Sym) *symtab;
 
 					symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
-					strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
+					LD_DEBUG_EARLY_DO(strtab = (char *) tpnt->dynamic_info[DT_STRTAB];)
 					sym = &symtab[symtab_index];
 					symbol_addr = load_addr + sym->st_value;
 
 					SEND_STDERR_DEBUG("relocating symbol: ");
 					SEND_STDERR_DEBUG(strtab + sym->st_name);
 					SEND_STDERR_DEBUG("\n");
-				} else
+				} else {
 					SEND_STDERR_DEBUG("relocating unknown symbol\n");
+				}
 				/* Use this machine-specific macro to perform the actual relocation.  */
 				PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr, sym);
 			}
diff -X excl -rduNp uClibc.oorig/libc/stdlib/malloc-standard/free.c uClibc/libc/stdlib/malloc-standard/free.c
--- uClibc.oorig/libc/stdlib/malloc-standard/free.c	2006-01-14 12:22:17.000000000 +0100
+++ uClibc/libc/stdlib/malloc-standard/free.c	2006-01-28 17:57:05.000000000 +0100
@@ -401,11 +401,11 @@ void free(void* mem)
        */
 
     else {
-	int ret;
+	__MALLOC_DO_DEBUG(int ret;)
 	size_t offset = p->prev_size;
 	av->n_mmaps--;
 	av->mmapped_mem -= (size + offset);
-	ret = munmap((char*)p - offset, size + offset);
+	__MALLOC_DO_DEBUG(ret =) munmap((char*)p - offset, size + offset;)
 	/* munmap returns non-zero on failure */
 	assert(ret == 0);
     }
diff -X excl -rduNp uClibc.oorig/libc/stdlib/malloc-standard/malloc.h uClibc/libc/stdlib/malloc-standard/malloc.h
--- uClibc.oorig/libc/stdlib/malloc-standard/malloc.h	2006-01-14 12:22:17.000000000 +0100
+++ uClibc/libc/stdlib/malloc-standard/malloc.h	2006-01-28 17:57:05.000000000 +0100
@@ -944,7 +944,7 @@ void   __malloc_consolidate(mstate) attr
 #define check_malloced_chunk(P,N)
 #define check_malloc_state()
 #define assert(x) ((void)0)
-
+#define __MALLOC_DO_DEBUG(...)
 
 #else
 
@@ -954,7 +954,7 @@ void   __malloc_consolidate(mstate) attr
 #define check_remalloced_chunk(P,N) __do_check_remalloced_chunk(P,N)
 #define check_malloced_chunk(P,N)   __do_check_malloced_chunk(P,N)
 #define check_malloc_state()        __do_check_malloc_state()
-
+#define __MALLOC_DO_DEBUG(...) __VA_ARGS__
 extern void __do_check_chunk(mchunkptr p);
 extern void __do_check_free_chunk(mchunkptr p);
 extern void __do_check_inuse_chunk(mchunkptr p);
diff -X excl -rduNp uClibc.oorig/libc/sysdeps/linux/i386/bits/syscalls.h uClibc/libc/sysdeps/linux/i386/bits/syscalls.h
--- uClibc.oorig/libc/sysdeps/linux/i386/bits/syscalls.h	2006-01-24 21:40:41.000000000 +0100
+++ uClibc/libc/sysdeps/linux/i386/bits/syscalls.h	2006-01-28 18:03:43.000000000 +0100
@@ -12,7 +12,7 @@
 #include <bits/sysnum.h>
 
 /*
-   Some of the sneaky macros in the code were taken from 
+   Some of the sneaky macros in the code were taken from
    glibc-2.2.5/sysdeps/unix/sysv/linux/i386/sysdep.h
 */
 
@@ -91,7 +100,7 @@ return (type) (INLINE_SYSCALL(name, 3, a
 type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
 { \
 return (type) (INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4)); \
-} 
+}
 
 #undef _syscall5
 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \



More information about the uClibc mailing list