e529961e6c
Copy from shells/ksh based on submit request 17433 from user WernerFink OBS-URL: https://build.opensuse.org/request/show/17433 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/ksh?expand=0&rev=31
85 lines
2.0 KiB
Plaintext
85 lines
2.0 KiB
Plaintext
--- src/lib/libast/vmalloc/malloc.c
|
|
+++ src/lib/libast/vmalloc/malloc.c 2009-08-06 10:27:36.465902620 +0000
|
|
@@ -131,13 +131,23 @@ typedef struct ______mstats Mstats_t;
|
|
#undef valloc
|
|
#endif
|
|
|
|
+#define DEBUG_LEAK 1
|
|
+#if defined(DEBUG_LEAK) && (DEBUG_LEAK > 0)
|
|
+Void_t* _global_alloc;
|
|
+Void_t* _global_free;
|
|
+#endif
|
|
+
|
|
#if _WINIX
|
|
|
|
#include <ast_windows.h>
|
|
|
|
#if _UWIN
|
|
|
|
+#if defined(DEBUG_LEAK) && (DEBUG_LEAK > 0)
|
|
+#define VMRECORD(p) (_global_alloc = _vmrecord(p))
|
|
+#else
|
|
#define VMRECORD(p) _vmrecord(p)
|
|
+#endif
|
|
#define VMBLOCK { int _vmblock = _sigblock();
|
|
#define VMUNBLOCK _sigunblock(_vmblock); }
|
|
|
|
@@ -173,7 +183,11 @@ lcl_getenv(const char* s)
|
|
#endif /* _WINIX */
|
|
|
|
#ifndef VMRECORD
|
|
+#if defined(DEBUG_LEAK) && (DEBUG_LEAK > 0)
|
|
+#define VMRECORD(p) (_global_alloc = (p))
|
|
+#else
|
|
#define VMRECORD(p) (p)
|
|
+#endif
|
|
#define VMBLOCK
|
|
#define VMUNBLOCK
|
|
#endif
|
|
@@ -496,6 +510,9 @@ extern void free(data)
|
|
reg Void_t* data;
|
|
#endif
|
|
{
|
|
+#if defined(DEBUG_LEAK) && (DEBUG_LEAK > 0)
|
|
+ _global_free = data;
|
|
+#endif
|
|
#if USE_NATIVE
|
|
#undef free
|
|
#if __STD_C
|
|
--- debug
|
|
+++ debug 2009-08-06 11:13:00.514401978 +0000
|
|
@@ -0,0 +1,33 @@
|
|
+#!/bin/sh
|
|
+tmp=$(mktemp gdbrc.XXXXXX) || exit 1
|
|
+log=$(mktemp gdblg.XXXXXX) || exit 1
|
|
+trap "rm -f $tmp $log" EXIT SIGINT
|
|
+(cat > $tmp)<<---
|
|
+ set logging file $log
|
|
+ set logging overwrite on
|
|
+ set logging redirect on
|
|
+ set logging on
|
|
+ watch _global_alloc
|
|
+ commands
|
|
+ silent
|
|
+ printf "\n alloc = %p\n ======================\n", _global_alloc
|
|
+ if sh.subshell >= 1
|
|
+ bt 12
|
|
+ end
|
|
+ cont
|
|
+ end
|
|
+ watch _global_free
|
|
+ commands
|
|
+ silent
|
|
+ printf "\n free = %p\n ======================\n", _global_free
|
|
+ cont
|
|
+ end
|
|
+ run
|
|
+ quit
|
|
+--
|
|
+env -i gdb -batch-silent -x $tmp --args ./arch/*/src/cmd/ksh93/ksh $1
|
|
+grep -E '^[[:blank:]]+alloc[[:blank:]]+=[[:blank:]]+0x' $log | \
|
|
+ while read alloc sign val; do
|
|
+ grep -qE "^[[:blank:]]+free[[:blank:]]+=[[:blank:]]+$val" $log && continue
|
|
+ sed -rn "/^[[:blank:]]+alloc[[:blank:]]+=[[:blank:]]+$val/,/^$/p" $log
|
|
+ done
|