Skip to content

Instantly share code, notes, and snippets.

$ gcc -g3 -Wall -fPIC -shared -o condwait_wrap.so condwait_wrap.c -ldl -lpthread
$ gcc -g3 -Wall -o condwait_test condwait_test.c -lpthread
$ ./condwait_test
Thread exiting
$ LD_PRELOAD=./condwait_wrap.so ./condwait_test
Calling func condwait with cond: 0x600d80, mutex: 0x600dc0...^C
Exit 130
$ ./condwait_test
Thread exiting
$ gcc -Wall -shared -fPIC -o malloc_wrap.so malloc_wrap.c -ldl
$ LD_PRELOAD=./malloc_wrap.so /bin/uname
Malloc request for 34 bytes got memory: 0x1103010
Malloc request for 10 bytes got memory: 0x1103040
Linux
$ LD_PRELOAD=./malloc_wrap.so /bin/uname
Malloc request for 34 bytes got memory: 0x1103010
Malloc request for 10 bytes got memory: 0x1103040
Linux
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
static void *(*malloc_internal)(size_t size);
void __attribute__ ((constructor)) init(void);
/* Library constructor */
;; Load a custom configuration directory
testing.
this_is_a_test
rhel 5.1
--------
10% I/O hit
P: 9668, I: 1000, Min: 9922, Max: 10033, Avg: 9999.77, Dev: 0.0% (2.97), Steal pct: 0.0%
P: 9666, I: 1000, Min: 8993, Max: 11427, Avg: 9999.77, Dev: 0.6% (56.95), Steal pct: 0.0%
P: 9667, I: 1000, Min: 9922, Max: 10022, Avg: 9999.77, Dev: 0.0% (2.83), Steal pct: 0.0%
P: 9668, I: 1000, Min: 7998, Max: 12373, Avg: 10000.14, Dev: 1.0% (98.43), Steal pct: 0.0%
P: 9666, I: 1000, Min: 7299, Max: 12702, Avg: 9999.35, Dev: 1.2% (121.69), Steal pct: 0.0%
P: 9667, I: 1000, Min: 9924, Max: 10032, Avg: 9999.77, Dev: 0.0% (3.17), Steal pct: 0.0%
(re-search-backward "^Location: \\(.*\\)$")