citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit ff79b8767deef8bc3a67c3243fde5e06c35574cc
parent 76436cae12dc035aeee04edae41893758978043c
Author: kyle <kyle@getaddrinfo.net>
Date:   Thu, 29 Oct 2015 00:26:27 -0600

runtime: add skeleton

Diffstat:
Mrun_tests.sh | 6+++---
Aruntime/Makefile | 13+++++++++++++
Aruntime/runtime.c | 16++++++++++++++++
3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/run_tests.sh b/run_tests.sh @@ -9,6 +9,7 @@ if which tput > /dev/null; then RESET=`tput sgr0` fi +export LD_LIBRARY_PATH="runtime" for t in `ls tests/*/prog.c`; do ./instrument $t -- > $temp_file dirname=`dirname ${t}` @@ -21,11 +22,10 @@ for t in `ls tests/*/prog.c`; do fi # try to compile the instrumented file - if ! gcc -o /tmp/bin $temp_file; then - # /tmp/bin won't be created here + if ! gcc -o /tmp/bin -pthread -Lruntime/ $temp_file -lruntime ; then echo "$dirname/instrumented.c:$RED gcc compilation failed$RESET" - rm /tmp/bin + # /tmp/bin won't be created here continue fi diff --git a/runtime/Makefile b/runtime/Makefile @@ -0,0 +1,13 @@ +CFLAGS += -fPIC -pthread +LIB = libruntime.so +SRCS = runtime.c +OBJS = $(SRCS:c=o) + +$(LIB): $(OBJS) + $(CC) -shared -o $(LIB) $(OBJS) + +clean: + rm -f $(OBJS) $(LIB) + +depend: + mkdep $(CFLAGS) $(SRCS) diff --git a/runtime/runtime.c b/runtime/runtime.c @@ -0,0 +1,16 @@ +#include <pthread.h> +#include <stdio.h> + +void * +control_thread(void *arg) +{ + // printf("control thread alive!\n"); +} + +__attribute__((constructor)) +static void runtime_init() +{ + pthread_t tid; + + pthread_create(&tid, NULL, control_thread, NULL); +}