Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Build a debug-enabled static library.

Build two versions of kqtest with and without debugging enabled.
Use static linking for kqtest and kqtest_debug.
Add additional Makefile targets for profiling with Valgrind
Enable gprof profiling in the debug targets.


git-svn-id: svn://mark.heily.com/libkqueue/trunk@520 34a59efb-09c4-4dcf-b95f-994a32aba0d8
  • Loading branch information...
commit ea0cc840aa95c0939b1178b7513d2a8a70831d78 1 parent 73390aa
mheily authored
13 Makefile
View
@@ -22,7 +22,7 @@ include config.mk
.PHONY :: install uninstall check dist dist-upload clean merge distclean fresh-build rpm edit cscope
-all: $(PROGRAM).so.$(ABI_VERSION) $(PROGRAM)_debug.so $(PROGRAM).a
+all: $(PROGRAM).so.$(ABI_VERSION) $(PROGRAM)_debug.so $(PROGRAM).a $(PROGRAM)_debug.a
%.o: %.c $(DEPS)
$(CC) -c -o $@ -I./include -I./src/common -DNDEBUG $(CFLAGS) $<
@@ -34,6 +34,12 @@ $(PROGRAM).a:
$(STRIP) $(PROGRAM).a
rm *.o
+$(PROGRAM)_debug.a:
+ rm -f *.o
+ $(CC) -c -I./include -I./src/common -DMAKE_STATIC=1 -pg -static $(CFLAGS) $(SOURCES) $(LDADD)
+ $(AR) rcs $(PROGRAM)_debug.a *.o
+ rm *.o
+
$(PROGRAM).so.$(ABI_VERSION): $(OBJS)
$(CC) -o $@ -I./include -I./src/common -shared $(LDFLAGS) -DNDEBUG $(CFLAGS) $(SOURCES) $(LDADD)
$(STRIP) $(PROGRAM).so.$(ABI_VERSION)
@@ -69,9 +75,12 @@ uninstall:
test/config.mk:
cd test && ../configure
-check: clean all test/config.mk
+check: test/config.mk
cd test && make check
+profile: clean $(PROGRAM)_debug.a
+ cd test && ./kqtest
+
debug: clean all test/config.mk
cd test && make debug
1  src/common/kevent.c
View
@@ -255,6 +255,7 @@ kevent(int kqfd, const struct kevent *changelist, int nchanges,
dbg_printf("--- kevent %u --- (nchanges = %d, nevents = %d)", myid, nchanges, nevents);
} else {
myid = 0;
+ (void) myid;
}
/*
28 test/Makefile
View
@@ -14,7 +14,7 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
-tests=kqtest lockstat static-lib-test
+tests=kqtest kqtest_debug lockstat static-lib-test
include config.mk
@@ -24,28 +24,38 @@ lockstat: lockstat.c
$(CC) -o lockstat $(CFLAGS) lockstat.c $(LDADD)
kqtest: $(SOURCES)
- $(CC) -rdynamic -o kqtest $(CFLAGS) $(SOURCES) $(LDADD)
+ $(CC) -pg -o kqtest -DMAKE_STATIC=1 $(CFLAGS) $(SOURCES) ../libkqueue.a -lpthread
+
+kqtest_debug: $(SOURCES)
+ $(CC) -pg -o kqtest_debug -DMAKE_STATIC=1 $(CFLAGS) $(SOURCES) ../libkqueue_debug.a -lpthread
static-lib-test: $(SOURCES)
$(CC) -o static-lib-test -DMAKE_STATIC=1 $(CFLAGS) $(SOURCES) ../libkqueue.a -lpthread
check: kqtest
- LD_LIBRARY_PATH="..:/usr/sfw/lib/64" PATH="$$PATH:.." ./kqtest $(KQTEST_OPTS)
+ ./kqtest $(KQTEST_OPTS)
debug: kqtest
- LD_LIBRARY_PATH="..:/usr/sfw/lib/64" PATH="$$PATH:.." gdb ./kqtest $(KQTEST_OPTS)
+ gdb ./kqtest $(KQTEST_OPTS)
valgrind: kqtest
- LD_LIBRARY_PATH="..:/usr/sfw/lib/64" \
valgrind --tool=memcheck --leak-check=full --show-reachable=yes --num-callers=20 --track-fds=yes ./kqtest
helgrind: kqtest
- LD_LIBRARY_PATH="..:/usr/sfw/lib/64" \
- valgrind --tool=helgrind ./kqtest
+ valgrind --tool=helgrind ./kqtest -c 25 -n 1
+
+callgrind: kqtest
+ rm -f callgrind.*
+ valgrind --tool=callgrind --branch-sim=yes ./kqtest || true
+ kcachegrind callgrind.*
cachegrind: kqtest
- LD_LIBRARY_PATH="..:/usr/sfw/lib/64" \
- valgrind --tool=cachegrind --branch-sim=yes ./kqtest
+ rm -f cachegrind.*
+ valgrind --tool=cachegrind --branch-sim=yes ./kqtest || true
+ #CLI:
+ #cg_annotate cachegrind.*
+ #GUI:
+ kcachegrind
check-installed:
$(CC) -o kqtest $(CFLAGS) $(SOURCES) $(LDADD) -lkqueue
2  test/config.inc
View
@@ -17,7 +17,7 @@ pre_configure_hook() {
then
ldadd="$ldadd ../libkqueue.so"
else
- ldadd="$ldadd -lkqueue_debug -lpthread -lrt"
+ ldadd="$ldadd ../libkqueue_debug.a -lpthread -lrt"
fi
}
1  test/main.c
View
@@ -204,6 +204,7 @@ main(int argc, char **argv)
struct unit_test tests[] = {
{ "socket", 1, test_evfilt_read },
#ifndef _WIN32
+ // XXX-FIXME -- BROKEN ON LINUX WHEN RUN IN A SEPARATE THREAD
{ "signal", 0, test_evfilt_signal },
#endif
#if FIXME
Please sign in to comment.
Something went wrong with that request. Please try again.