Jan Kiszka wrote: > Philippe Gerum wrote: >>>> (*) You could avoid passing the function name in the systrace calls, by >>>> relying on the value of __FUNCTION__, with a small hack to trimm the >>>> __wrap_ prefix when needed. Making tracepoints less hairy would ease my >>>> pain reading this stuff. >>> OK, but let's not spend brain cycles on this until we know if and how we >>> can separate the entry/exit tracing from the traced service. If we could >>> leave existing lib code untouched, I would be happier as well. >>> >> It does matter because it reduce visual clutter, and that's a >> prerequisite for merging, that's why I'm suggesting it. >> We already have an automated instrumentation tool for the simulator, but >> I'm not sure automatically inserted tracepoints would always be relevant >> in all cases. > > Doesn't it rely on a patched gcc? Here is a suggestion for an > instrumentation procedure based on standard tools: > > > lib.h: > ------ > int my_lib_func(int arg1, const char *arg2); > > lib.c: > ------ > int my_lib_func(int arg1, const char *arg2) > { > return 13; > } > > main.c: > ------- > #include <stdio.h> > #include "lib.h" > main() > { > printf("my_lib_func = %d\n", > my_lib_func(1, "hello")); > } > > > So far, so ordinary. Now we add entry/exit tracing for my_lib_func: > > > trace.c > ------- > #include <stdio.h> > #include "lib.h" > int __trace_my_lib_func(int arg1, const char *arg2) > { > int ret; > printf("entry: arg1 = %d, arg2 = %s\n", arg1, arg2); > ret = my_lib_func(arg1, arg2); > printf("exit: ret = %d\n", ret); > return ret; > } > > Makefile: > --------- > ifneq (,$(TRACE)) > TRACELIB=trace.o > endif > > main: main.c lib.o > > lib.o: lib.c $(TRACELIB) > gcc -c -o $@ $< > ifneq (,$(TRACE)) > ld -r -o [EMAIL PROTECTED] $@ $(TRACELIB) > objcopy --redefine-sym my_lib_func=__orig_my_lib_func \ > --redefine-sym __trace_my_lib_func=my_lib_func [EMAIL > PROTECTED] $@
We could even build this symbol list dynamically by looking for everything that starts with "__trace_". That way, no one would have to maintain lists of traced functions in separated files or so. > rm -f [EMAIL PROTECTED] > endif > > clean: > rm -f *.o main > > > Build with "make TRACE=1" to get the traced variant, or call "make" for > non-traced mode. > > This means we have a switch in the build process, we don't need to touch > the library sources. We only have to add a __trace_xxx() version for > every xxx() that can even use original headers to call into the original > service. Converting the Makefile stuff into something more handy for > autotools shouldn't be tricky. > > There is just one no-go: functions with variable argument lists. > Fortunately, the only one that comes into my mind right now, > [rtdm_]ioctl(), has a single well-known "unknown" argument and needs to > be unrolled unconditionally anyway. > > What do you think? > > Jan >
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core