diff -Nru latrace-0.5.10.20110523/ChangeLog latrace-0.5.11/ChangeLog --- latrace-0.5.10.20110523/ChangeLog 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/ChangeLog 2011-08-09 16:28:37.000000000 +0000 @@ -1,3 +1,52 @@ +------------------------------------------------------------------------------- +latrace 0.5.11 + +2011-07-28 Jiri Olsa + * doc - update configuration file stuff + * config - add missing help for -N option + * 0.5.11 release changes + +2011-07-07 Jiri Olsa + * args - fix size_t printf compile warning + +2011-06-21 Jiri Olsa + * config - fixed memory leak + +2011-06-15 Jiri Olsa + * global_symbol fix - proper tree management + * make tracer return actual tracee status + * move all tests to scripts + * added following options + LIBS, LIBS_TO, LIBS_FROM, SYM, SYM_OMIT, SYM_BELOW, SYM_NOEXIT + * automated tests for LIBS*/SYM* + * args - adding support to display string pointer and length, + ARGS_STRING_POINTER_LENGTH option + (contributed by Dr. David Alan Gilbert ) + +2011-06-02 Jiri Olsa + * adding large file support + +2011-05-30 Jiri Olsa + * fixed bug in tracer waiting code + (do not exit the loop prematurely) + * reading the -N config file immediatelly within + args processing + +2011-05-25 Jiri Olsa + * adding SIGTERM/SIGINT handlers, + refactoring lt_run to check the latrace got killed + * adding tests for latrace termination + * args - replacing destination strings with void pointers + * tty output - move fd to the config struct + +2011-05-24 Jiri Olsa + * args - use isprint to decide whether to print the character, + force test.sh to use bash, + enable tests for ARM architecture + (contributed by Dr. David Alan Gilbert ) + * fix test_[char|short|int|long] tests + * test_long - separate 32/64 versions + 2011-05-13 Jiri Olsa * build fix for ARM (contributed by Dr. David Alan Gilbert ) diff -Nru latrace-0.5.10.20110523/configure.ac latrace-0.5.11/configure.ac --- latrace-0.5.10.20110523/configure.ac 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/configure.ac 2011-08-09 16:28:37.000000000 +0000 @@ -72,6 +72,7 @@ AC_TYPE_INT8_T AC_TYPE_UINT16_T AC_TYPE_UINT8_T +AC_SYS_LARGEFILE date=`date "+%B %G"` unamem=`uname -m | sed -e 's/i.86/i686/' -e 's/^armv.*/arm/'` @@ -95,7 +96,8 @@ # for following architectures we have automated tests support if test "$unamem" = "x86_64" -o\ - "$unamem" = "i686"; then + "$unamem" = "i686" -o\ + "$unamem" = "arm" ; then AC_SUBST(CONFIG_ARCH_HAVE_TEST, "y") else AC_MSG_WARN([No automated test support]) diff -Nru latrace-0.5.10.20110523/debian/changelog latrace-0.5.11/debian/changelog --- latrace-0.5.10.20110523/debian/changelog 2011-10-17 12:57:21.000000000 +0000 +++ latrace-0.5.11/debian/changelog 2011-10-17 12:57:21.000000000 +0000 @@ -1,8 +1,13 @@ -latrace (0.5.10.20110523-1) unstable; urgency=low +latrace (0.5.11-1) unstable; urgency=low + + * New upstream version + + -- Riku Voipio Tue, 09 Aug 2011 18:14:03 +0300 + +latrace (0.5.10-1) unstable; urgency=low * Repackage and modernize * Initial upload to debian Closes: #605378 - * take git snapshot to get latest ARM fix in. -- Riku Voipio Mon, 23 May 2011 11:50:52 +0300 diff -Nru latrace-0.5.10.20110523/doc/latrace.txt latrace-0.5.11/doc/latrace.txt --- latrace-0.5.10.20110523/doc/latrace.txt 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/doc/latrace.txt 2011-08-09 16:28:37.000000000 +0000 @@ -10,167 +10,180 @@ SYNOPSIS -------- -*latrace* [-ltfsnbcCpADaoyIiBdvTFELVh] command [arg ... ] +latrace [-snltfvhiBdISbcCyYLpoaNADVTFERq] command [arg ... ] DESCRIPTION ----------- -*latrace* is able to run a command and display its dynamic library calls using -a *LD_AUDIT* libc feature (available from libc version 2.4 onward - see <> -). It is also capable to measure and display various statistics of -dynamic calls. - -If the config file is provided, latrace will display symbol's arguments with -detailed output for structures. The config file syntax is similar to the C -language, with several exceptions (see <>). - -The latrace by default fully operates inside of the traced program. However -another pipe mode is available, to move the main work to the latrace binary -(see <>). +The latrace tracer is able to run a command and display its dynamic library calls using +a LD_AUDIT libc feature, available from libc version 2.4 onward. It is also capable +to measure and display various statistics of dynamic calls. See <> +for more details. + +If the header file with functions' declarations is provided, latrace will display +functions's arguments. The header file file syntax is similar to the C language, with +several exceptions See <> for more details. + +The latrace by default fully operates inside of the traced program. However +another "pipe mode" is available to move the main work to the tracer - the latrace +binary. See <> for more details. -Its use is very similar to strace(1) and ltrace(1). +The latrace use is similar to strace(1) and ltrace(1). OPTIONS ------- -*-l, --libs lib1[,lib2,...]*:: +-l, --libs lib1[,lib2,...]:: audit from and to lib1, lib2 ... -*-t, --libs-to lib1[,lib2,...]*:: +-t, --libs-to lib1[,lib2,...]:: audit to lib1, lib2 ... -*-f, --libs-from lib1[,lib2,...]*:: +-f, --libs-from lib1[,lib2,...]:: audit from lib1, lib2 ... -*-s, --sym sym1[,sym2,...]*:: +-s, --sym sym1[,sym2,...]:: audit symbols sym1, sym2 ... -*-n, --sym-omit sym1[,sym2,...]*:: +-n, --sym-omit sym1[,sym2,...]:: omit symbols sym1, sym2 ... -*-S, --timestamp*:: - display timestamp for each symbol - -*-b, --flow-below sym1[,sym2,...]*:: - display flow for sym1, sym2 ... +-L, --lib-subst s1[,s2,...]:: + objsearch LD_AUDIT interface (See <>) -*-c, --counts*:: +-c, --counts:: display statistics counts of symbols - implies pipe mode (see <>) an no symbol output is displayed -*-C, --sort-counts stat*:: +-C, --sort-counts stat:: implies -c, plus sort the statistics by stat with following values: time,per,call,ucall,lib,sym (default is call) -*-p, --pipe*:: +-p, --pipe:: use pipe to latrace process to send audit data (see <>) -*-o, --output file*:: - store output to file +-N, --conf:: + config file (see <>) -*-A, --enable-args*:: +-A, --enable-args:: enable arguments output (definitions from /etc/latrace.conf) -*-D, --detail-args*:: +-D, --detail-args:: display struct arguments in more detail -*-a, --args file*:: +-a, --args file:: specify arguments definition file, implies -A (without the default definition file of course) -*-y, --framesize number*:: +-y, --framesize number:: framesize for storing the stack before pltexit (default 100) -*-Y, --no-framesize-check*:: +-Y, --no-framesize-check:: disable framesize check -*-I, --no-indent-sym*:: +-F, --no-follow-fork:: + dont follow fork calls (childs). This is just supressing the latrace + output from new childs. The nature of the *LD_AUDIT* feature prevents to + disable it completely. + +-E, --no-follow-exec:: + dont follow exec calls + +-S, --timestamp:: + display timestamp for each symbol + +-b, --flow-below sym1[,sym2,...]:: + display flow for sym1, sym2 ... + +-I, --no-indent-sym:: do no indent symbols based on the their stack depth -*-i, --indent-sym indent_size*:: +-i, --indent-sym indent_size:: indent size specification in indent_size -*-B, --braces*:: +-B, --braces:: allways display '{' '}' for the around the symbol body -*-d, --demangle*:: +-d, --demangle:: C++ demangle symbols on the output -*-v, --verbose*:: - verbose output - -*-T, --hide-tid*:: +-T, --hide-tid:: dont display thread id -*-F, --no-follow-fork*:: - dont follow fork calls (childs). This is just supressing the latrace - output from new childs. The nature of the *LD_AUDIT* feature prevents to - disable it completely. - -*-E, --no-follow-exec*:: - dont follow exec calls +-o, --output file:: + store output to file -*-R, --ctl-config*:: +-R, --ctl-config:: controled config feature -*-q, --disable*:: +-q, --disable:: run with disabled auditing +-v, --verbose:: + verbose output + +-V, --version:: + display version + +-h, --help:: + display help + EXAMPLES -------- - The simplest way to run latrace is like this: + -** latrace cat** + latrace cat - To see the argument values specified by default config file run: + -** latrace -A cat** + latrace -A cat - Same as above but using the pipe mode to get all the end symbols printed: + -** latrace -Ap cat** + latrace -Ap cat - To see the argument values specified by specified config file run: + -** latrace -a latrace.conf cat** + latrace -a latrace.conf cat - To get output only for specified symbol (eg. read and write) run: + -** latrace -A -s read,write cat** + latrace -A -s read,write cat - To get flow under the specified symbol (eg. sysconf) run: + -** latrace -b sysconf kill** + latrace -b sysconf kill - To get output only for specified library (eg. libproc) run: + -** latrace -Al libproc w** + latrace -Al libproc w - To get symbol statistics run: + -** latrace -c ls** + latrace -c ls - To get symbol statistics sorted by time run: + -** latrace -C time ls** + latrace -C time ls - To get output stored to the text file run: + -** latrace -o output.latrace ls** + latrace -o output.latrace ls - To change the libkrava1.so dependency to the libkrava2.so run one of these: + -** latrace -L krava1%krava2 ex** + latrace -L krava1%krava2 ex + -** latrace -L krava1~libkrava2.so ex** + latrace -L krava1~libkrava2.so ex + -** latrace -L libkrava1.so=libkrava2.so ex** + latrace -L libkrava1.so=libkrava2.so ex [[DISCUSSION]] DISCUSSION ---------- +[[NAMESCHECK]] NAMES CHECK ~~~~~~~~~~~ For options *"-l -t -f -s -n -b"* the *** symbol can be used to switch to the @@ -207,10 +220,11 @@ "la_PLTENTER" "la_PLTEXIT" "la_objclose" -+ As for the latrace package the audit shared library is called libltaudit.so. + +[[OBJSEARCH]] OBJSEARCH ~~~~~~~~~ The objsearch *LD_AUDIT* interface provide means for changing traced program @@ -267,47 +281,130 @@ [[CONFIG]] CONFIG ~~~~~~ -The latrace config file allows user to define symbols as an classic C -functions with arguments. Argument names will be display together with values +The latrace provide possibility to enable/disable some of the options +by means of configuration file. Some of the options are linked to the +command line arguments some of them are not. When latrace starts the +global configuration file is read. This file is usually being placed +in here: + + /etc/latrace.d/latrace.conf + +Having default values read from this file, user can overload any of them +by command line options or by supling another config file via *-N, --conf* +option. + + +The configuration file syntax is roughly: + +........................................... +INCLUDE + +OPTIONS { + OPTION1 = VALUE + OPTION2 = YES|NO + ... + OPTIONN = VALUE +} + +# comment +........................................... + +*Configuration file options* + +HEADERS = FILE:: + -a, --args + +INDENT_SYM = VALUE:: + -i, --indent-sym + +PIPE = BOOL:: + -p, --pipe + +TIMESTAMP = BOOL:: + -S, --timestamp + +FRAMESIZE = VALUE:: + -y, --framesize + +FRAMESIZE_CHECK = BOOL:: + -Y, --no-framesize-check + +HIDE_TID = BOOL:: + -T, --hide-tid + +FOLLOW_FORK = BOOL:: + -F, --no-follow-fork + +FOLLOW_EXEC = BOOL:: + -E, --no-follow-exec + +DEMANGLE = BOOL:: + -d, --demangle + +BRACES = BOOL:: + -B, --braces + +ENABLE_ARGS = BOOL:: + -A, --enable-args + +DETAIL_ARGS = BOOL:: + -D, --detail-args + +OUTPUT_TTY = FILE:: + - stores tracee terminal output to the file + +LIBS = LIB1[,LIB2,...]:: + -l, --libs + +LIBS_TO = LIB1[,LIB2,...]:: + -t, --libs-to + +LIBS_FROM = LIB1[,LIB2,...]:: + -f, --libs-from + +SYM = SYM1[,SYM2,...]:: + -s, --sym + +SYM_OMIT = SYM1[,SYM2,...]:: + -n, --sym-omit + +SYM_BELOW = SYM1[,SYM2,...]:: + -b, --flow-below + +SYM_NOEXIT = SYM1[,SYM2,...]:: + - symbols which do no run exit callback (plt_exit) + +ARGS_STRING_POINTER_LENGTH = BOOL:: + - function arguments - display string length and pointer value + + +[[HEADERS]] +HEADERS +~~~~~~ +The latrace header file allows user to define symbols as an classic C +functions with arguments. Argument names will be displayed together with values as the latrace output. The more arguments are defined, the more performance and memory penalties should be expected. -The package is delivered with several config files for the most commonly used -functions. List of the glibc header files used follows (the list mostly -follows the ltrace header files list, and author is willing to update it -according to the needs. - - /usr/include/arpa/inet.h - /usr/include/ctype.h - /usr/include/stdlib.h - /usr/include/string.h - /usr/include/ctype.h - /usr/include/ncurses.h - /usr/include/stdio.h - /usr/include/dirent.h - /usr/include/unistd.h - /usr/include/libintl.h - /usr/include/dlfcn.h - /usr/include/fcntl.h - /usr/include/getopt.h - /usr/include/signal.h - /usr/include/sys/ioctl.h - /usr/include/sys/socket.h - /usr/include/netdb.h - /usr/include/pthread.h - /usr/include/sys/resource.h - /usr/include/sys/mman.h -+ - -The config file structure consists of */etc/latrace.conf* file, which is the -default one read by latrace. This config file includes other config files -placed in the */etc/latrace.d* directory. This directory contain all the config -files for the above mentioned header files. - -As already mentioned, the latrace config file syntax lightly follows the C -language syntax. Following part describes the latrace config file -language. - +The package is delivered with several predefined header files for the most +commonly used functions. List of the glibc header files used follows +(the list mostly follows the ltrace header files list, and author is willing to +update it according to the needs) + + ctype.h dirent.h dlfcn.h fcntl.h getopt.h inet.h ioctl.h + libintl.h libio.h locale.h misc.h mman.h ncurses.h netdb.h + pthread.h pwd.h resource.h signal.h socket.h stat.h stdio.h + stdlib.h string.h syslog.h term.h termios.h time.h typedefs.h + unistd.h utmp.h wait.h + +The latrace header files are usually stored under directory: + + /etc/latrace.d/headers/ + +User can specify single header file using command line option or configuration +file. This file then can include other needed headers. As already mentioned, +the latrace config file syntax lightly follows the C language syntax. Following +part describes the latrace config file language. - Several **POD types** (plain old data), are hardcoded in latrace. Size of those @@ -408,38 +505,32 @@ PORTS ----- +The latrace should work on any glibc system with LD_AUDIT support. +However arguments details are architecture specific and need special +support inside latrace itself. + Author is willing to port the latrace to any architecture, as long as he got an access to corresponding system. Currently functional ports are: [horizontal] *x86*:: ok *x86_64*:: ok -*arm*:: ok (contributed and maintained by Akos Pasztory) - - -LD_AUDIT related glibc bugs: - -- *Bug 7055 (no longer reproducible)* -LD_AUDIT - gettimeofday function segfaults if called from interface - - - -- *Bug 9893 (FIXED in 2.10)* -LD_AUDIT - misaligned _dl_call_pltexit parameter causing crash in audit library - - - -- *Bug 3924 (FIXED in 2.7-2)* -LD_AUDIT implementation causing process segfaulting - +*arm*:: ok BUGS ---- MANY, plz report bugs to or . + You can also visit the http://people.redhat.com/jolsa/latrace/ page to see the latest release notes information. +LD_AUDIT related glibc bugs: + +- *Bug 7055 (no longer reproducible)* +- *Bug 9893 (FIXED in 2.10)* +- *Bug 3924 (FIXED in 2.7-2)* + AUTHOR ------ @@ -451,6 +542,8 @@ - Nix - Akos Pasztory - Artur Skawina +- Dr. David Alan Gilbert +- Sebastian Pipping LICENSE diff -Nru latrace-0.5.10.20110523/etc/latrace.d/headers/stdio.h latrace-0.5.11/etc/latrace.d/headers/stdio.h --- latrace-0.5.10.20110523/etc/latrace.d/headers/stdio.h 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/etc/latrace.d/headers/stdio.h 2011-08-09 16:28:37.000000000 +0000 @@ -39,12 +39,12 @@ int fprintf(FILE *stream, char *format); int printf(char *format); -int sprintf(char *s, char *format); +int sprintf(void *s, char *format); int vfprintf(FILE *s, char *format); int vprintf(char *format); -int vsprintf(char *s, char *format); -int snprintf(char *s, size_t maxlen, char *format); -int vsnprintf(char *s, size_t maxlen, char *format); +int vsprintf(void *s, char *format); +int snprintf(void *s, size_t maxlen, char *format); +int vsnprintf(void *s, size_t maxlen, char *format); int vasprintf(void *ptr, char *f); int __asprintf(void *ptr, char *fmt); int asprintf(void *ptr, char *fmt); diff -Nru latrace-0.5.10.20110523/etc/latrace.d/headers/string.h latrace-0.5.11/etc/latrace.d/headers/string.h --- latrace-0.5.10.20110523/etc/latrace.d/headers/string.h 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/etc/latrace.d/headers/string.h 2011-08-09 16:28:37.000000000 +0000 @@ -12,10 +12,10 @@ void* memrchr(void *s, int c, size_t n); -char* strcpy(char *dest, char *src); -char* strncpy(char *dest, char *src, size_t n); -char* strcat(char *dest, char *src); -char* strncat(char *dest, char *src, size_t n); +char* strcpy(void *dest, char *src); +char* strncpy(void *dest, char *src, size_t n); +char* strcat(void *dest, char *src); +char* strncat(void *dest, char *src, size_t n); int strcmp(char *s1, char *s2); int strncmp(char *s1, char *s2, size_t n); int strcoll(char *s1, char *s2); @@ -76,10 +76,10 @@ char* strsep(void *stringp, char *delim); int strverscmp(char *s1, char *s2); char* strsignal(int sig); -char* __stpcpy(char *dest, char *src); -char* stpcpy(char *dest, char *src); -char* __stpncpy(char *dest, char *src, size_t n); -char* stpncpy(char *dest, char *src, size_t n); ++char* __stpcpy(void *dest, char *src); ++char* stpcpy(void *dest, char *src); ++char* __stpncpy(void *dest, char *src, size_t n); ++char* stpncpy(void *dest, char *src, size_t n); char* strfry(char *string); void* memfrob(void *s, size_t n); char* basename(char *filename); diff -Nru latrace-0.5.10.20110523/etc/latrace.d/latrace.conf.in latrace-0.5.11/etc/latrace.d/latrace.conf.in --- latrace-0.5.10.20110523/etc/latrace.d/latrace.conf.in 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/etc/latrace.d/latrace.conf.in 2011-08-09 16:28:37.000000000 +0000 @@ -61,4 +61,38 @@ # no command line option equivalent # stores terminal output to the file # OUTPUT_TTY = "output-tty" + + # Following options: + # LIBS/LIBS_TO/LIBS_FROM + # SYM/SYM_OMIT/SYM_BELOW/SYM_NOEXIT + # + # use list of names as value. Single names in the list are + # separated by comma ','. If the first char of a single name + # is '*', then the name is search for as substring, otherwise + # exact match is used. + + # -l, --libs + # LIBS = krava.so + + # -t, --libs-to + # LIBS_TO = krava.so + + # -f, --libs-from + # LIBS_FROM = krava.so + + # -s, --sym + # SYM = krava + + # -n, --sym-omit + # SYM_OMIT = krava + + # -b, --flow-below + # SYM_BELOW = krava + + # no command line option equivalent + SYM_NOEXIT = _setjmp + + # no command line option equivalent + # function arguments - display string length and pointer value + ARGS_STRING_POINTER_LENGTH = NO } diff -Nru latrace-0.5.10.20110523/Makefile latrace-0.5.11/Makefile --- latrace-0.5.10.20110523/Makefile 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/Makefile 2011-08-09 16:28:37.000000000 +0000 @@ -147,7 +147,8 @@ endif INCLUDES= -I. -Isrc -Isrc/sysdeps/$(CONFIG_SYSDEP_DIR) -ALL_CFLAGS=$(CPPFLAGS) $(CFLAGS) -O2 -fPIC -Wall $(INCLUDES) -D_GNU_SOURCE +ALL_CFLAGS=$(CPPFLAGS) $(CFLAGS) -O2 -fPIC -Wall $(INCLUDES) +ALL_CFLAGS+=-D_GNU_SOURCE -imacros src/autoconf.h %.o: %.c LATRACE-CFLAGS @@ -166,8 +167,6 @@ clean:: $(call remove, $(OBJS) $(PROGRAMS)) - $(call remove, src/args-bison.c src/args-flex.c src/args-bison.h src/args-bison.output) - $(call remove, src/config-bison.c src/config-flex.c src/config-bison.h src/config-bison.output) $(call remove, lib bin share deps.make latrace-$(CONFIG_VERSION)) mrproper:: @@ -191,9 +190,7 @@ # The gcc -M depedencies generation needs to repaired to include # subdirectory name within the target.. at least I haven't find any # gcc option to do that. -# - no dependency for flex and bison definitions -DEPS_OBJS=$(filter-out src/args-flex.o src/args-bison.o,$(OBJS)) -DEPS_OBJS:=$(filter-out src/config-bison.o src/config-flex.o,$(DEPS_OBJS)) +DEPS_OBJS=$(filter-out $(OBJS_DEPS_OMIT),$(OBJS)) deps.make: $(QUIET_DEP)$(RM) -f deps.make; \ diff -Nru latrace-0.5.10.20110523/package/debian/changelog latrace-0.5.11/package/debian/changelog --- latrace-0.5.10.20110523/package/debian/changelog 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/package/debian/changelog 2011-08-09 16:28:48.000000000 +0000 @@ -1,3 +1,16 @@ +latrace (0.5.11-1) unstable; urgency=low + + * New upstream version + + -- Riku Voipio Tue, 09 Aug 2011 18:14:03 +0300 + +latrace (0.5.10-1) unstable; urgency=low + + * Repackage and modernize + * Initial upload to debian Closes: #605378 + + -- Riku Voipio Mon, 23 May 2011 11:50:52 +0300 + latrace (0.5.7-1) unstable; urgency=low * Packaged again. diff -Nru latrace-0.5.10.20110523/package/debian/compat latrace-0.5.11/package/debian/compat --- latrace-0.5.10.20110523/package/debian/compat 1970-01-01 00:00:00.000000000 +0000 +++ latrace-0.5.11/package/debian/compat 2011-08-09 16:28:48.000000000 +0000 @@ -0,0 +1 @@ +8 diff -Nru latrace-0.5.10.20110523/package/debian/conffiles latrace-0.5.11/package/debian/conffiles --- latrace-0.5.10.20110523/package/debian/conffiles 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/package/debian/conffiles 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/etc/latrace.conf -/etc/latrace.d/ctype.conf -/etc/latrace.d/dirent.conf -/etc/latrace.d/dlfcn.conf -/etc/latrace.d/fcntl.conf -/etc/latrace.d/getopt.conf -/etc/latrace.d/inet.conf -/etc/latrace.d/ioctl.conf -/etc/latrace.d/libintl.conf -/etc/latrace.d/libio.conf -/etc/latrace.d/locale.conf -/etc/latrace.d/misc.conf -/etc/latrace.d/ncurses.conf -/etc/latrace.d/netdb.conf -/etc/latrace.d/pthread.conf -/etc/latrace.d/pwd.conf -/etc/latrace.d/signal.conf -/etc/latrace.d/socket.conf -/etc/latrace.d/stat.conf -/etc/latrace.d/stdio.conf -/etc/latrace.d/stdlib.conf -/etc/latrace.d/string.conf -/etc/latrace.d/syslog.conf -/etc/latrace.d/term.conf -/etc/latrace.d/termios.conf -/etc/latrace.d/time.conf -/etc/latrace.d/typedefs.conf -/etc/latrace.d/unistd.conf -/etc/latrace.d/utmp.conf -/etc/latrace.d/wait.conf diff -Nru latrace-0.5.10.20110523/package/debian/control latrace-0.5.11/package/debian/control --- latrace-0.5.10.20110523/package/debian/control 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/package/debian/control 2011-08-09 16:28:48.000000000 +0000 @@ -1,19 +1,18 @@ Source: latrace Section: utils Priority: optional -Maintainer: Akos PASZTORY -Standards-Version: 3.8.0 -Build-Depends: flex, bison, autoconf, binutils-dev (>= 2.19.51), +Maintainer: Riku Voipio +Standards-Version: 3.9.1 +Homepage: http://people.redhat.com/jolsa/latrace/index.shtml +Build-Depends: flex, bison, autoconf, debhelper (>=8), asciidoc, xmlto, docbook-xsl, docbook-xml Package: latrace -Architecture: i386 amd64 armel -Depends: libc6 (>= 2.5) [armel], libc6 (>= 2.7-1) [i386 amd64] +Architecture: i386 amd64 armel armhf +Depends: ${shlibs:Depends}, ${misc:Depends} Description: traces library calls in dynamically linked programs latrace (similar to ltrace) displays dynamic library calls of a program using the LD_AUDIT feature of newer glibc versions. It is also capable to measure and display various statistics of dynamic calls. If a config file is provided, latrace will display function arguments with detailed output for structures. - . - See also http://people.redhat.com/jolsa/latrace/index.shtml diff -Nru latrace-0.5.10.20110523/package/debian/copyright latrace-0.5.11/package/debian/copyright --- latrace-0.5.10.20110523/package/debian/copyright 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/package/debian/copyright 2011-08-09 16:28:48.000000000 +0000 @@ -1,8 +1,10 @@ This package is derived from sources obtained at: - http://latrace.sourceforge.net + http://people.redhat.com/jolsa/latrace/index.shtml + Debian packaging by Akos PASZTORY . +Redone by Riku Voipio . -Copyright (c) 2008, 2009, 2010 Jiri Olsa +Copyright (c) 2008-2011 Jiri Olsa This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff -Nru latrace-0.5.10.20110523/package/debian/rules latrace-0.5.11/package/debian/rules --- latrace-0.5.10.20110523/package/debian/rules 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/package/debian/rules 2011-08-09 16:28:48.000000000 +0000 @@ -1,47 +1,14 @@ #!/usr/bin/make -f -.PHONY: build clean binary-arch binary-indep binary default - -pkg := latrace -pkgdir := debian/$(pkg) -docdir := $(pkgdir)/usr/share/doc/$(pkg) -checkdir = @test -e debian/control || ! echo wrong directory -checkuid = @test "`id -u`" -eq 0 || ! echo need root permissions +clean: + dh_testdir + $(MAKE) clean + rm -f LATRACE-CFLAGS configure config.status config.log + dh_clean -default: -build: debian/stamp-build -debian/stamp-build: - $(checkdir) +override_dh_auto_configure: autoconf ./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib/latrace - make - touch $@ -clean: - $(checkdir) - $(checkuid) - rm -f debian/stamp-* - test ! -f src/autoconf.make || make mrproper - rm -rf debian/latrace - rm -f debian/files debian/substvars -binary-indep: -binary-arch: debian/stamp-build - $(checkdir) - $(checkuid) - install -d $(pkgdir)/DEBIAN $(docdir) - make install ROOTDIR="$(CURDIR)/$(pkgdir)" - cd $(pkgdir) && strip --strip-unneeded -R .note -R .comment \ - usr/bin/latrace usr/lib/latrace/libltaudit.so* - cp -p ChangeLog $(docdir)/changelog - cp -p README ReleaseNotes TODO debian/copyright $(docdir) - cp -p debian/changelog $(docdir)/changelog.Debian - cd $(pkgdir) && find etc -type f -printf "/%p\n" > DEBIAN/conffiles - gzip -9f $(pkgdir)/usr/share/man/man1/latrace.1 - gzip -9f $(docdir)/changelog $(docdir)/changelog.Debian - dpkg-shlibdeps $(pkgdir)/usr/bin/latrace - dpkg-gencontrol -P$(pkgdir) - cd $(pkgdir) && find * -path DEBIAN -prune -o -type f -print0 | \ - xargs -r0 md5sum > DEBIAN/md5sums - chown -R root:root $(pkgdir) - chmod -R u+w,go=rX $(pkgdir) - dpkg-deb -b $(pkgdir) .. -binary: binary-arch binary-indep + +%: + dh $@ diff -Nru latrace-0.5.10.20110523/ReleaseNotes latrace-0.5.11/ReleaseNotes --- latrace-0.5.10.20110523/ReleaseNotes 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/ReleaseNotes 2011-08-09 16:28:37.000000000 +0000 @@ -2,6 +2,39 @@ latrace release notes (olsajiri@gmail.com) ------------------------------------------------------------------------------- +[x] latrace 0.5.11 (7/25/2011) + * enhancing names check with *-logic for + "-l -t -f -s -n -b" options + * moving conf header files to new location + rename s/conf/h/ + * adding support for configuration file + * global symbol handling + one global symbol tree to rule them all + - only one tree is searched during the plt entry/exit + - symbols are added during the bind audit callback + * adding automated test support, so far for x86 and x86_64, + others are disabled. + * adding SIGTERM/SIGINT handlers, + refactoring lt_run to check the latrace got killed + * adding large file support + * make tracer return actual tracee status + * several fixies + - fix display of char arguments + - add threads fifo management to special directory + so the notification is not affected by other files + - fix memory leak in the argument display code + - fix controled config bug - missing shared config assignment + - fixed errors discovered by cppcheck + - build fix for ARM + - args - use isprint to decide whether to print the character, + force test.sh to use bash, + enable tests for ARM architecture + - args - replacing destination strings with void pointers + * thanks to the following for patches: + Dr. David Alan Gilbert + Sebastian Pipping + Artur Skawina + + [x] latrace 0.5.10 (10/13/2010) * added '-n' option, allowing to omit tracing certain symbols * adding stack limits dynamic check (fixing several SIGSEGV issues) diff -Nru latrace-0.5.10.20110523/src/args.c latrace-0.5.11/src/args.c --- latrace-0.5.10.20110523/src/args.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/src/args.c 2011-08-09 16:28:37.000000000 +0000 @@ -19,6 +19,7 @@ */ +#include #include #include #include @@ -837,12 +838,18 @@ char *s = val; int slen = strlen(s); int left = alen; + int info_len = 0; + + if (lt_sh(cfg, args_string_pointer_length)) { + info_len = snprintf(argbuf, left, "(%p, %zu) ", s, strlen(s)); + left -= info_len; + } if ((slen + 2) > left) { - snprintf(argbuf, left, "\"%s", s); + snprintf(argbuf + info_len, left, "\"%s", s); strncpy(argbuf + left - sizeof("...\"") + 1, "...\"", sizeof("...\"")); } else { - strcpy(argbuf, "\""); + strcpy(argbuf + info_len, "\""); strcat(argbuf, s); strcat(argbuf, "\""); } @@ -850,7 +857,7 @@ len = snprintf(argbuf, alen, "NULL"); } else { - if (*((char*) pval) <= ' ') + if (!isprint(*((char*) pval))) len = snprintf(argbuf, alen, "0x%02x", *((unsigned char*) pval)); else diff -Nru latrace-0.5.10.20110523/src/audit.c latrace-0.5.11/src/audit.c --- latrace-0.5.10.20110523/src/audit.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/src/audit.c 2011-08-09 16:28:37.000000000 +0000 @@ -245,19 +245,28 @@ { unsigned int flags = 0; + /* particular symbols specified, omit all others */ if (cfg.symbols_cnt) { flags = LA_SYMB_NOPLTENTER|LA_SYMB_NOPLTEXIT; if (check_names((char*) symname, cfg.symbols)) flags = 0; } + /* we might want just pltenter for some.. eg for _setjmp */ + if (cfg.symbols_noexit_cnt) { + if (check_names((char*) symname, cfg.symbols_noexit)) + flags = LA_SYMB_NOPLTEXIT; + } + + /* and keep omit options the strongest */ if (cfg.symbols_omit_cnt) { if (check_names((char*) symname, cfg.symbols_omit)) flags = LA_SYMB_NOPLTENTER|LA_SYMB_NOPLTEXIT; } /* we are interested in this symbol */ - if (!(flags & LA_SYMB_NOPLTENTER)) + if (lt_sh(&cfg, global_symbols) && + !(flags & LA_SYMB_NOPLTENTER)) lt_symbol_bind(cfg.sh, (void*) sym->st_value, symname); return flags; diff -Nru latrace-0.5.10.20110523/src/audit-init.c latrace-0.5.11/src/audit-init.c --- latrace-0.5.10.20110523/src/audit-init.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/src/audit-init.c 2011-08-09 16:28:37.000000000 +0000 @@ -204,6 +204,14 @@ return -1; } + /* SYM_NOEXIT option */ + if ((*lt_sh(&cfg, symbols_noexit)) && + (-1 == (cfg.symbols_noexit_cnt = get_names(&cfg, lt_sh(&cfg, symbols_noexit), + cfg.symbols_noexit)))) { + printf("latrace failed to parse noexit symbols\n"); + return -1; + } + /* -b */ if ((*lt_sh(&cfg, flow_below)) && (-1 == (cfg.flow_below_cnt = get_names(&cfg, lt_sh(&cfg, flow_below), diff -Nru latrace-0.5.10.20110523/src/autoconf.h.in latrace-0.5.11/src/autoconf.h.in --- latrace-0.5.10.20110523/src/autoconf.h.in 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/src/autoconf.h.in 2011-08-09 16:28:37.000000000 +0000 @@ -33,4 +33,8 @@ /* liberty */ #undef CONFIG_LIBERTY +/* large file support */ +#undef _LARGE_FILES +#undef _FILE_OFFSET_BITS + #endif diff -Nru latrace-0.5.10.20110523/src/config-bison.y latrace-0.5.11/src/config-bison.y --- latrace-0.5.10.20110523/src/config-bison.y 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/src/config-bison.y 2011-08-09 16:28:37.000000000 +0000 @@ -21,6 +21,9 @@ %name-prefix "lt_config_" %{ +#include +#include + #include "config.h" #include "lib-include.h" @@ -43,20 +46,26 @@ #define OPTION_ADD(idx, sval, nval) \ do { \ struct lt_config_opt *opt; \ - opt = lt_config_opt_new(idx, sval, nval); \ + opt = lt_config_opt_new(scfg, idx, sval, nval); \ if (!opt) \ ERROR("failed to process option\n"); \ lt_list_add_tail(&opt->list, &opt_list); \ } while(0) + +static struct lt_list_head ln_names; + %} -%token INCLUDE FILENAME BOOL VALUE END +%token INCLUDE NAME BOOL VALUE END %token OPTIONS %token OPT_HEADERS OPT_INDENT_SYM OPT_PIPE %token OPT_TIMESTAMP OPT_FRAMESIZE OPT_FRAMESIZE_CHECK %token OPT_HIDE_TID OPT_FOLLOW_FORK OPT_FOLLOW_EXEC %token OPT_DEMANGLE OPT_BRACES OPT_ENABLE_ARGS %token OPT_DETAIL_ARGS OPT_OUTPUT_TTY +%token OPT_LIBS OPT_LIBS_TO OPT_LIBS_FROM +%token OPT_SYM OPT_SYM_OMIT OPT_SYM_BELOW OPT_SYM_NOEXIT +%token OPT_ARGS_STRING_POINTER_LENGTH %union { @@ -64,7 +73,7 @@ unsigned long l; } -%type FILENAME +%type NAME %type BOOL %type VALUE @@ -82,7 +91,7 @@ | /* left blank intentionally */ -include_def: INCLUDE '"' FILENAME '"' +include_def: INCLUDE '"' NAME '"' { if (lt_inc_open(scfg->sh, lt_config_sinc, $3)) ERROR("failed to process include"); @@ -102,7 +111,7 @@ } OPTIONS_DEF: -OPTIONS_DEF OPT_HEADERS '=' '"' FILENAME '"' +OPTIONS_DEF OPT_HEADERS '=' '"' NAME '"' { OPTION_ADD(LT_OPT_HEADERS, $5, -1); } @@ -167,18 +176,107 @@ OPTION_ADD(LT_OPT_DETAIL_ARGS, $4, -1); } | -OPTIONS_DEF OPT_OUTPUT_TTY '=' '"' FILENAME '"' +OPTIONS_DEF OPT_OUTPUT_TTY '=' '"' NAME '"' { OPTION_ADD(LT_OPT_OUTPUT_TTY, $5, -1); } | +OPTIONS_DEF OPT_LIBS '=' list_names_comma +{ + char libs[LT_LIBS_MAXSIZE]; + + if (lt_config_ln_fill(&ln_names, libs, LT_LIBS_MAXSIZE)) + ERROR("failed to process libs option"); + + OPTION_ADD(LT_OPT_LIBS, libs, -1); +} +| +OPTIONS_DEF OPT_LIBS_TO '=' list_names_comma +{ + char libs_to[LT_LIBS_MAXSIZE]; + + if (lt_config_ln_fill(&ln_names, libs_to, LT_LIBS_MAXSIZE)) + ERROR("failed to process libs_to option"); + + OPTION_ADD(LT_OPT_LIBS_TO, libs_to, -1); +} +| +OPTIONS_DEF OPT_LIBS_FROM '=' list_names_comma +{ + char libs_from[LT_LIBS_MAXSIZE]; + + if (lt_config_ln_fill(&ln_names, libs_from, LT_LIBS_MAXSIZE)) + ERROR("failed to process libs_from option"); + + OPTION_ADD(LT_OPT_LIBS_FROM, libs_from, -1); +} +| +OPTIONS_DEF OPT_SYM '=' list_names_comma +{ + char sym[LT_LIBS_MAXSIZE]; + + if (lt_config_ln_fill(&ln_names, sym, LT_LIBS_MAXSIZE)) + ERROR("failed to process sym option"); + + OPTION_ADD(LT_OPT_SYM, sym, -1); +} +| +OPTIONS_DEF OPT_SYM_OMIT '=' list_names_comma +{ + char sym_omit[LT_SYMBOLS_MAXSIZE]; + + if (lt_config_ln_fill(&ln_names, sym_omit, LT_SYMBOLS_MAXSIZE)) + ERROR("failed to process sym_omit option"); + + OPTION_ADD(LT_OPT_SYM_OMIT, sym_omit, -1); +} +| +OPTIONS_DEF OPT_SYM_BELOW '=' list_names_comma +{ + char sym_below[LT_SYMBOLS_MAXSIZE]; + + if (lt_config_ln_fill(&ln_names, sym_below, LT_SYMBOLS_MAXSIZE)) + ERROR("failed to process sym_below option"); + + OPTION_ADD(LT_OPT_SYM_BELOW, sym_below, -1); +} +| +OPTIONS_DEF OPT_SYM_NOEXIT '=' list_names_comma +{ + char sym_noexit[LT_SYMBOLS_MAXSIZE]; + + if (lt_config_ln_fill(&ln_names, sym_noexit, LT_SYMBOLS_MAXSIZE)) + ERROR("failed to process sym_below option"); + + OPTION_ADD(LT_OPT_SYM_NOEXIT, sym_noexit, -1); +} +| +OPTIONS_DEF OPT_ARGS_STRING_POINTER_LENGTH '=' BOOL +{ + OPTION_ADD(LT_OPT_ARGS_STRING_POINTER_LENGTH, $4, -1); +} +| /* left blank intentionally */ +list_names_comma: +list_names_comma ',' NAME +{ + if (lt_config_ln_add(&ln_names, $3)) + ERROR("failed to add list name"); +} +| +NAME +{ + if (lt_config_ln_add(&ln_names, $1)) + ERROR("failed to add list name"); +} + %% int lt_config_parse_init(struct lt_config_app *cfg, struct lt_include *inc) { scfg = cfg; lt_config_sinc = inc; + lt_init_list_head(&ln_names); return 0; } diff -Nru latrace-0.5.10.20110523/src/config.c latrace-0.5.11/src/config.c --- latrace-0.5.10.20110523/src/config.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/src/config.c 2011-08-09 16:28:37.000000000 +0000 @@ -60,6 +60,7 @@ printf(" time,per,call,ucall,lib,sym (default is call)\n"); printf(" -p, --pipe use pipe to latrace process to send audit data\n"); printf(" latrace app is then the one displaying the output\n"); + printf(" -N, --conf config file\n"); printf("\n"); #ifndef CONFIG_ARCH_HAVE_ARGS printf(" -[ADa] arguments display support not compiled in\n"); @@ -131,7 +132,7 @@ int ret = 0; lt_config_parse_init(cfg, &inc); - PRINT_VERBOSE(cfg, 1, "arguments definition file %s\n", file); + PRINT_VERBOSE(cfg, 1, "config file %s\n", file); if (lt_inc_open(cfg->sh, &inc, file)) return -1; @@ -283,6 +284,56 @@ cfg->output_tty_file); break; + case LT_OPT_LIBS: + strcpy(lt_sh(cfg, libs_both), sval); + PRINT_VERBOSE(cfg, 1, "LIBS '%s'\n", + lt_sh(cfg, libs_both)); + break; + + case LT_OPT_LIBS_TO: + strcpy(lt_sh(cfg, libs_to), sval); + PRINT_VERBOSE(cfg, 1, "LIBS_TO '%s'\n", + lt_sh(cfg, libs_to)); + break; + + case LT_OPT_LIBS_FROM: + strcpy(lt_sh(cfg, libs_from), sval); + PRINT_VERBOSE(cfg, 1, "LIBS_FROM '%s'\n", + lt_sh(cfg, libs_from)); + break; + + case LT_OPT_SYM: + strcpy(lt_sh(cfg, symbols), sval); + PRINT_VERBOSE(cfg, 1, "SYM '%s'\n", + lt_sh(cfg, symbols)); + break; + + case LT_OPT_SYM_OMIT: + strcpy(lt_sh(cfg, symbols_omit), sval); + PRINT_VERBOSE(cfg, 1, "SYM_OMIT '%s'\n", + lt_sh(cfg, symbols_omit)); + break; + + case LT_OPT_SYM_BELOW: + strcpy(lt_sh(cfg, flow_below), sval); + PRINT_VERBOSE(cfg, 1, "SYM_BELOW '%s'\n", + lt_sh(cfg, flow_below)); + break; + + case LT_OPT_SYM_NOEXIT: + strcpy(lt_sh(cfg, symbols_noexit), sval); + PRINT_VERBOSE(cfg, 1, "SYM_NOEXIT '%s'\n", + lt_sh(cfg, symbols_noexit)); + break; + + case LT_OPT_ARGS_STRING_POINTER_LENGTH: + CHECK_BOOL(val, sval, ival); + lt_sh(cfg, args_string_pointer_length) = val; + + PRINT_VERBOSE(cfg, 1, "ARGS_STRING_POINTER_LENGTH %d\n", + lt_sh(cfg, args_detailed)); + break; + default: return -1; } @@ -309,7 +360,8 @@ return 0; } -struct lt_config_opt *lt_config_opt_new(int idx, char *sval, long nval) +struct lt_config_opt *lt_config_opt_new(struct lt_config_app *cfg, + int idx, char *sval, long nval) { struct lt_config_opt *opt; @@ -322,13 +374,56 @@ opt->sval = sval ? strdup(sval) : NULL; opt->nval = nval; + PRINT_VERBOSE(cfg, 1, "idx %d = %s, %d\n", + opt->idx, opt->sval , opt->nval); return opt; } -int lt_config(struct lt_config_app *cfg, int argc, char **argv) +int lt_config_ln_add(struct lt_list_head *head, char *name) { - char *conf_file = LT_CONF_DIR "/latrace.conf"; + struct lt_config_ln *ln = malloc(sizeof(*ln)); + if (!ln) + return -1; + + ln->name = strdup(name); + lt_init_list_head(&ln->list); + lt_list_add_tail(&ln->list, head); + return 0; +} + +int lt_config_ln_fill(struct lt_list_head *head, char *buf, int size) +{ + struct lt_config_ln *ln, *n; + int first = 1; + char *b = buf; + + buf[0] = 0x00; + + lt_list_for_each_entry_safe(ln, n, head, list) { + int ret; + + ret = snprintf(b, size, "%s%s", + first ? "" : ",", + ln->name); + + if (ret >= size) + return -1; + + size -= ret; + b += ret; + first = 0; + + lt_list_del(&ln->list); + free(ln->name); + free(ln); + } + + return 0; +} + +int lt_config(struct lt_config_app *cfg, int argc, char **argv) +{ memset(cfg, 0, sizeof(*cfg)); cfg->sh = cfg->sh_storage.sh = &cfg->sh_storage; @@ -342,15 +437,14 @@ lt_sh(cfg, args_maxlen) = LR_ARGS_MAXLEN; lt_sh(cfg, args_detail_maxlen) = LR_ARGS_DETAIL_MAXLEN; cfg->csort = LT_CSORT_CALL; + cfg->output_tty_fd = -1; /* read the default config file first */ - if (read_config(cfg, conf_file)) { - printf("failed: read config file '%s'\n", conf_file); + if (read_config(cfg, LT_CONF_DIR "/latrace.conf")) { + printf("failed: read config file '" LT_CONF_DIR "/latrace.conf'\n"); usage(); } - conf_file = NULL; - while (1) { int c; int option_index = 0; @@ -396,45 +490,45 @@ switch (c) { case 'l': - if (strlen(optarg) > LT_LIBS_MAXSIZE) + if (strlen(optarg) >= LT_LIBS_MAXSIZE) return -1; - strncpy(lt_sh(cfg, libs_both), optarg, strlen(optarg)); + process_option_val(cfg, LT_OPT_LIBS, optarg, -1); break; case 't': - if (strlen(optarg) > LT_LIBS_MAXSIZE) + if (strlen(optarg) >= LT_LIBS_MAXSIZE) return -1; - strncpy(lt_sh(cfg, libs_to), optarg, strlen(optarg)); + process_option_val(cfg, LT_OPT_LIBS_TO, optarg, -1); break; case 'f': - if (strlen(optarg) > LT_LIBS_MAXSIZE) + if (strlen(optarg) >= LT_LIBS_MAXSIZE) return -1; - strncpy(lt_sh(cfg, libs_from), optarg, strlen(optarg)); + process_option_val(cfg, LT_OPT_LIBS_FROM, optarg, -1); break; case 's': - if (strlen(optarg) > LT_SYMBOLS_MAXSIZE) + if (strlen(optarg) >= LT_SYMBOLS_MAXSIZE) return -1; - strncpy(lt_sh(cfg, symbols), optarg, strlen(optarg)); + process_option_val(cfg, LT_OPT_SYM, optarg, -1); break; case 'n': - if (strlen(optarg) > LT_SYMBOLS_MAXSIZE) + if (strlen(optarg) >= LT_SYMBOLS_MAXSIZE) return -1; - strncpy(lt_sh(cfg, symbols_omit), optarg, strlen(optarg)); + process_option_val(cfg, LT_OPT_SYM_OMIT, optarg, -1); break; case 'b': - if (strlen(optarg) > LT_SYMBOLS_MAXSIZE) + if (strlen(optarg) >= LT_SYMBOLS_MAXSIZE) return -1; - strncpy(lt_sh(cfg, flow_below), optarg, strlen(optarg)); + process_option_val(cfg, LT_OPT_SYM_BELOW, optarg, -1); break; case 'v': @@ -527,7 +621,11 @@ #endif /* CONFIG_ARCH_HAVE_ARGS */ case 'N': - conf_file = optarg; + /* read user-specifide config file */ + if (read_config(cfg, optarg)) { + printf("failed: read config file '%s'\n", optarg); + usage(); + } break; case 'o': @@ -566,12 +664,6 @@ cfg->arg_num = i_arg; } - /* read user-specifide config file */ - if (conf_file && read_config(cfg, conf_file)) { - printf("failed: read config file '%s'\n", conf_file); - usage(); - } - if (!cfg->prog) { printf("failed: no program specified\n"); usage(); diff -Nru latrace-0.5.10.20110523/src/config-flex.l latrace-0.5.11/src/config-flex.l --- latrace-0.5.10.20110523/src/config-flex.l 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/src/config-flex.l 2011-08-09 16:28:37.000000000 +0000 @@ -50,9 +50,7 @@ num [-0-9] value ({num})+ -alphnum [-0-9a-zA-Z_] -name ({alphnum})+ -filename ([-0-9a-zA-Z\./_])+ +name ([-0-9a-zA-Z\./_\-\*])+ bool YES|NO comment ^([\s\t])*#.* @@ -66,7 +64,7 @@ . { ; } INCLUDE { BEGIN(include); return INCLUDE; } -{filename} { RETURN_STR(FILENAME); } +{name} { RETURN_STR(NAME); } "\"" { return '"'; } \n { BEGIN(INITIAL); NEW_LINE(); } . { ; } @@ -86,15 +84,24 @@ ENABLE_ARGS { return OPT_ENABLE_ARGS; } DETAIL_ARGS { return OPT_DETAIL_ARGS; } OUTPUT_TTY { return OPT_OUTPUT_TTY; } +LIBS { return OPT_LIBS; } +LIBS_TO { return OPT_LIBS_TO; } +LIBS_FROM { return OPT_LIBS_FROM; } +SYM { return OPT_SYM; } +SYM_OMIT { return OPT_SYM_OMIT; } +SYM_BELOW { return OPT_SYM_BELOW; } +SYM_NOEXIT { return OPT_SYM_NOEXIT; } +ARGS_STRING_POINTER_LENGTH { return OPT_ARGS_STRING_POINTER_LENGTH; } {bool} { RETURN_STR(BOOL); } {value} { RETURN_LONG(VALUE); } -{filename} { RETURN_STR(FILENAME); } +{name} { RETURN_STR(NAME); } {comment} { ; } "}" { BEGIN(INITIAL); return '}'; } "{" { return '{'; } "=" { return '='; } "\"" { return '"'; } +"," { return ','; } "\\" { ; } "\n" { NEW_LINE(); } . { ; } diff -Nru latrace-0.5.10.20110523/src/config.h latrace-0.5.11/src/config.h --- latrace-0.5.10.20110523/src/config.h 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/src/config.h 2011-08-09 16:28:37.000000000 +0000 @@ -31,7 +31,6 @@ #include "audit.h" #include "list.h" -#include "autoconf.h" #ifdef CONFIG_ARCH_HAVE_ARGS #include "args.h" @@ -85,6 +84,14 @@ LT_OPT_ENABLE_ARGS, LT_OPT_DETAIL_ARGS, LT_OPT_OUTPUT_TTY, + LT_OPT_LIBS, + LT_OPT_LIBS_TO, + LT_OPT_LIBS_FROM, + LT_OPT_SYM, + LT_OPT_SYM_OMIT, + LT_OPT_SYM_BELOW, + LT_OPT_SYM_NOEXIT, + LT_OPT_ARGS_STRING_POINTER_LENGTH, }; struct lt_config_opt { @@ -109,6 +116,7 @@ #define LT_SYMBOLS_MAXSIZE 200 char symbols[LT_SYMBOLS_MAXSIZE]; char symbols_omit[LT_SYMBOLS_MAXSIZE]; + char symbols_noexit[LT_SYMBOLS_MAXSIZE]; char flow_below[LT_SYMBOLS_MAXSIZE]; @@ -119,6 +127,7 @@ char args_def[LT_MAXFILE]; char args_enabled; char args_detailed; + char args_string_pointer_length; #define LR_ARGS_MAXLEN 1000 int args_maxlen; #define LR_ARGS_DETAIL_MAXLEN 1000 @@ -166,7 +175,8 @@ int csort; - int output_tty; + int output_tty; + int output_tty_fd; char output_tty_file[LT_MAXFILE]; struct lt_thread *threads; @@ -218,6 +228,9 @@ char *symbols_omit[LT_NAMES_MAX]; int symbols_omit_cnt; + char *symbols_noexit[LT_NAMES_MAX]; + int symbols_noexit_cnt; + char *flow_below[LT_NAMES_MAX]; int flow_below_cnt; @@ -228,6 +241,12 @@ int init_ok; }; +/* config - list name support */ +struct lt_config_ln { + char *name; + struct lt_list_head list; +}; + #define lt_sh(cfg, field) ((cfg)->sh->field) #define FIFO_MSG_MAXLEN 2000 @@ -352,14 +371,18 @@ void *ptr, const char *name); /* config options */ -struct lt_config_opt *lt_config_opt_new(int idx, char *sval, long nval); +struct lt_config_opt *lt_config_opt_new(struct lt_config_app *cfg, + int idx, char *sval, long nval); int lt_config_opt_process(struct lt_config_app *cfg, struct lt_list_head *list); +int lt_config_ln_add(struct lt_list_head *head, char *name); +int lt_config_ln_fill(struct lt_list_head *head, char *buf, int size); /* tty */ int tty_master(struct lt_config_app *cfg); int tty_init(struct lt_config_app *cfg, int master); int tty_restore(struct lt_config_app *cfg); int tty_process(struct lt_config_app *cfg, int master); +void tty_close(struct lt_config_app *cfg); #define PRINT(fmt, args...) \ do { \ diff -Nru latrace-0.5.10.20110523/src/latrace.c latrace-0.5.11/src/latrace.c --- latrace-0.5.10.20110523/src/latrace.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/src/latrace.c 2011-08-09 16:28:37.000000000 +0000 @@ -66,11 +66,12 @@ static int main_latrace(int argc, char **argv) { + int ret; + if (-1 == lt_config(&cfg, argc, argv)) return -1; - if (-1 == lt_run(&cfg)) - return -1; + ret = lt_run(&cfg); if ((lt_sh(&cfg, pipe)) && (*lt_sh(&cfg, output))) fclose(lt_sh(&cfg, fout)); @@ -78,7 +79,7 @@ if (lt_sh(&cfg, counts)) lt_stats_show(&cfg); - return 0; + return ret; } int main(int argc, char **argv) diff -Nru latrace-0.5.10.20110523/src/Makefile latrace-0.5.11/src/Makefile --- latrace-0.5.10.20110523/src/Makefile 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/src/Makefile 2011-08-09 16:28:37.000000000 +0000 @@ -42,6 +42,10 @@ OBJS+=$(AUDIT_OBJS) PROGRAMS+= $(AUDIT_BIN) +# no dependency for flex and bison definitions +OBJS_DEPS_OMIT+=\ + src/args-flex.o \ + src/args-bison.o $(AUDIT_BIN): $(AUDIT_OBJS) $(QUIET_LD)$(CC) $(CFLAGS) $(AUDIT_LDFLAGS) -o $@ $^ $(AUDIT_LIBS) @@ -74,6 +78,10 @@ CPPFLAGS+=-DLT_CONF_DIR=\"$(sysconfdir)/latrace.d\" CPPFLAGS+=-DLT_CONF_HEADERS_DIR=\"$(sysconfdir)/latrace.d/headers\" CPPFLAGS+=-DLT_CONF_HEADERS_FILE=\"$(sysconfdir)/latrace.d/headers/latrace.h\" +# no dependency for flex and bison definitions +OBJS_DEPS_OMIT+=\ + src/config-bison.o \ + src/config-flex.o $(LATRACE_BIN): $(LATRACE_OBJS) $(QUIET_LD)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LATRACE_LIB) @@ -82,3 +90,7 @@ $(call install,$(LATRACE_BIN),$(bindir),755) $(call link,$(LATRACE_BIN),$(LATRACE_CTL),$(bindir)) +clean:: + $(call remove, src/config-bison.[ch] src/config-flex.c) + $(call remove, src/args-bison.[ch] src/args-flex.c) + $(call remove, src/config-bison.output src/args-bison.output) diff -Nru latrace-0.5.10.20110523/src/run.c latrace-0.5.11/src/run.c --- latrace-0.5.10.20110523/src/run.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/src/run.c 2011-08-09 16:28:37.000000000 +0000 @@ -33,6 +33,7 @@ #include #include #include +#include #include "config.h" @@ -47,6 +48,8 @@ int fd_tty_master; }; +static volatile int exit_flag = 0; + static int store_config(struct lt_config_app *cfg, char *file) { int fd; @@ -152,7 +155,7 @@ fd_set cfg_set, wrk_set; int fd_notify = pa->fd_notify; int fd_tty_master = pa->fd_tty_master; - int max_fd = fd_notify; + int max_fd = 0; #define MAX(a,b) ((a) < (b) ? (b) : (a)) FD_ZERO(&cfg_set); @@ -173,7 +176,7 @@ max_fd = MAX(fd_notify, fd_tty_master); } - while(!waitpid(pa->pid, &status, WNOHANG) || + while((waitpid(pa->pid, &status, WNOHANG) == 0) || /* let all the thread fifo close */ (finish) || /* Get inside at least once, in case the traced program @@ -194,12 +197,17 @@ struct lt_thread *t; int ret; + /* we got a signal, there's nothing to wait for.. */ + if (exit_flag) + break; + getin = 0; wrk_set = cfg_set; ret = select(max_fd + 1, &wrk_set, NULL, NULL, &tv); if (-1 == ret) { - perror("select failed"); + if (errno != EINTR) + perror("select failed"); return -1; } @@ -302,73 +310,168 @@ return 0; } -int lt_run(struct lt_config_app *cfg) +static void sig_term_handler(int sig) { - char str_dir[LT_MAXFILE]; - char str_cfg[LT_MAXFILE]; - struct lt_process_args pa = { .dir = str_dir }; - int status; + exit_flag = 1; +} - if (get_config_dir(str_dir, LT_MAXFILE)) +static int setup_signals(void) +{ + struct sigaction act; + + bzero(&act, sizeof(act)); + act.sa_handler = sig_term_handler; + + if (sigaction(SIGTERM, &act, NULL) || + sigaction(SIGINT, &act, NULL)) return -1; - sprintf(str_cfg, "%s/config", str_dir); + return 0; +} + +static int run_setup(struct lt_config_app *cfg, + struct lt_process_args *pa) +{ + char str_cfg[LT_MAXFILE]; + + sprintf(str_cfg, "%s/config", pa->dir); if (store_config(cfg, str_cfg)) return -1; /* new thread notification descriptor */ if (lt_sh(cfg, pipe) && - (-1 == (pa.fd_notify = lt_fifo_notify_fd(cfg, str_dir)))) + (-1 == (pa->fd_notify = lt_fifo_notify_fd(cfg, pa->dir)))) return -1; /* tty master descriptor */ if (cfg->output_tty && - (-1 == (pa.fd_tty_master = tty_master(cfg)))) + (-1 == (pa->fd_tty_master = tty_master(cfg)))) return -1; - gettimeofday(&tv_program_start, NULL); + return 0; +} + +static void run_cleanup(struct lt_config_app *cfg, + struct lt_process_args *pa) +{ + if (lt_sh(cfg, pipe)) + close(pa->fd_notify); + + if (cfg->output_tty) + tty_close(cfg); - if (0 == (pa.pid = fork())) { + remove_dir(cfg, pa->dir); +} + +static int run_child(struct lt_config_app *cfg, + struct lt_process_args *pa) +{ + + if (0 == (pa->pid = fork())) { char str_audit[100]; sprintf(str_audit, "%s/libltaudit.so.%s", CONFIG_LIBDIR, CONFIG_VERSION); setenv("LD_AUDIT", str_audit, 1); - setenv("LT_DIR", str_dir, 1); + setenv("LT_DIR", pa->dir, 1); if (cfg->output_tty && - tty_init(cfg, pa.fd_tty_master)) + tty_init(cfg, pa->fd_tty_master)) return -1; PRINT_VERBOSE(cfg, 1, "executing %s\n", cfg->prog); if (-1 == execvp(cfg->prog, cfg->arg)) { + int err = errno; tty_restore(cfg); printf("execve failed for \"%s\" : %s\n", - cfg->prog, strerror(errno)); - return -1; + cfg->prog, strerror(err)); } - } else if (pa.pid < 0) { + exit(-1); + + } else if (pa->pid < 0) { perror("fork failed"); return -1; } - if (lt_sh(cfg, pipe) || cfg->output_tty) - status = process(cfg, &pa); - else - waitpid(pa.pid, &status, 0); + return 0; +} + +static int kill_child(struct lt_config_app *cfg, + struct lt_process_args *pa) +{ + int status; + int cnt = 5 * 1000; + int nomercy = 1; - gettimeofday(&tv_program_stop, NULL); + kill(pa->pid, SIGTERM); - printf("\n%s finished - ", cfg->prog); + /* be gracious, 5 seconds should be enough + * for everyone ;) */ + while(cnt--) { + if (waitpid(pa->pid, &status, WNOHANG)) { + nomercy = 0; + break; + } + usleep(1000); + } - if (WIFEXITED(status)) { - printf("exited, status=%d\n", WEXITSTATUS(status)); - } else if (WIFSIGNALED(status)) { - printf("killed by signal %d\n", WTERMSIG(status)); + if (nomercy) { + kill(pa->pid, SIGKILL); + waitpid(pa->pid, &status, 0); } - remove_dir(cfg, str_dir); - return 0; + return status; +} + +int lt_run(struct lt_config_app *cfg) +{ + char ret = (char) -1; + char str_dir[LT_MAXFILE]; + struct lt_process_args pa = { .dir = str_dir }; + + if (setup_signals()) + return -1; + + if (get_config_dir(pa.dir, LT_MAXFILE)) + return -1; + + do { + int status; + + if (run_setup(cfg, &pa)) + break; + + gettimeofday(&tv_program_start, NULL); + + if (run_child(cfg, &pa)) + break; + + if (lt_sh(cfg, pipe) || cfg->output_tty) + status = process(cfg, &pa); + else + waitpid(pa.pid, &status, 0); + + gettimeofday(&tv_program_stop, NULL); + + if (exit_flag) { + printf("\nlatrace interrupted, killing child (pid %d)\n", + pa.pid); + status = kill_child(cfg, &pa); + } + + printf("\n%s finished - ", cfg->prog); + + if (WIFEXITED(status)) { + printf("exited, status=%d\n", WEXITSTATUS(status)); + } else if (WIFSIGNALED(status)) { + printf("killed by signal %d\n", WTERMSIG(status)); + } + + ret = WEXITSTATUS(status); + } while(0); + + run_cleanup(cfg, &pa); + return ret; } diff -Nru latrace-0.5.10.20110523/src/symbol.c latrace-0.5.11/src/symbol.c --- latrace-0.5.10.20110523/src/symbol.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/src/symbol.c 2011-08-09 16:28:37.000000000 +0000 @@ -95,6 +95,16 @@ struct lt_symbol *s = NULL; void *val; + PRINT_VERBOSE(cfg, 1, "checking %s(%p)\n", name, ptr); + + /* symbol already added */ + s = lt_symbol_get(cfg, ptr, name); + if (s) { + PRINT_VERBOSE(cfg, 1, "found %s, ptr %p, sym %p\n", + name, sym->ptr, sym); + return s; + } + if (!sym) { sym = malloc(sizeof(*sym)); if (!sym) @@ -105,29 +115,20 @@ sym->ptr = ptr; sym->name = name; - PRINT_VERBOSE(cfg, 1, "checking %s(%p)\n", name, ptr); + /* do we care about this symbol? */ + if (symbol_init(cfg, sym, name)) + return NULL; + /* we do, let's add it */ val = tsearch((void *) sym, &root, compare); if (!val) return NULL; + /* symbol properly added */ s = (*(void**) val); - /* symbol already in */ - if (s != sym) { - PRINT_VERBOSE(cfg, 1, "found %s, ptr %p, sym %p\n", - name, sym->ptr, sym); - return s; - } - PRINT_VERBOSE(cfg, 1, "added %s, ptr %p, sym %p\n", name, sym->ptr, sym); - - /* not interesting symbol */ - if (symbol_init(cfg, sym, name)) - return NULL; - - /* symbol properly added */ sym = NULL; return s; } diff -Nru latrace-0.5.10.20110523/src/tty.c latrace-0.5.11/src/tty.c --- latrace-0.5.10.20110523/src/tty.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/src/tty.c 2011-08-09 16:28:37.000000000 +0000 @@ -83,12 +83,19 @@ return 0; } +void tty_close(struct lt_config_app *cfg) +{ + close(cfg->output_tty_fd); +} + int tty_restore(struct lt_config_app *cfg) { int i, num_files = getdtablesize(); - for(i = 0; i < num_files; i++) - close(i); + for(i = 0; i < num_files; i++) { + if (fcntl(i, F_GETFD, NULL) != -1) + close(i); + } open("/dev/tty", O_RDWR); dup(0); @@ -102,9 +109,9 @@ #define BUFSIZE 4096 char buf[BUFSIZE]; ssize_t ret; - static int fd = 0; + int fd = cfg->output_tty_fd; - if (!fd) { + if (fd == -1) { fd = open(cfg->output_tty_file, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); if (fd < 0) { @@ -114,6 +121,8 @@ } PRINT_VERBOSE(cfg, 1, "opened tty output file %s\n", cfg->output_tty_file); + + cfg->output_tty_fd = fd; } ret = read(master, buf, BUFSIZE); diff -Nru latrace-0.5.10.20110523/test/lib-test-args.c latrace-0.5.11/test/lib-test-args.c --- latrace-0.5.10.20110523/test/lib-test-args.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/test/lib-test-args.c 2011-08-09 16:28:37.000000000 +0000 @@ -1,137 +1,137 @@ char test_char_1(char a) { - return a*a; + return 'd'; } char test_char_2(char a, char b) { - return a - b; + return 0xf6; } char test_char_3(char a, char b, char c) { - return a * b - c; + return 0xf7; } char test_char_4(char a, char b, char c, char d) { - return a + b - c * d; + return 0xc9; } char test_char_5(char a, char b, char c, char d, char e) { - return a + b * c / d * e; + return 0x2; } char test_char_6(char a, char b, char c, char d, char e, char f) { - return a / b * c / d * e - f; + return 'c'; } char test_char_7(char a, char b, char c, char d, char e, char f, char g) { - return a / b + c - d * e + f * g; + return 0x19; } char test_char_8(char a, char b, char c, char d, char e, char f, char g, char h) { - return a + b + c - d + e - f + g / h; + return '9'; } char test_char_9(char a, char b, char c, char d, char e, char f, char g, char h, char i) { - return a - b + c - d * e - f / g - h - i; + return 0xd0; } short test_short_1(short a) { - return -a; + return -100; } short test_short_2(short a, short b) { - return a + b; + return 30; } short test_short_3(short a, short b, short c) { - return a + b - c; + return -8; } short test_short_4(short a, short b, short c, short d) { - return a + b * c + d; + return 2097; } short test_short_5(short a, short b, short c, short d, short e) { - return a + b - c + d * e; + return 1583; } short test_short_6(short a, short b, short c, short d, short e, short f) { - return a * b * c + d * e - f; + return -25344; } short test_short_7(short a, short b, short c, short d, short e, short f, short g) { - return a / b + c + d * e - f * g; + return -19; } short test_short_8(short a, short b, short c, short d, short e, short f, short g, short h) { - return a + b + c + d + e + f + g + h; + return 3134; } short test_short_9(short a, short b, short c, short d, short e, short f, short g, short h, short i) { - return a - b - c - d - e - f - g - h - i; + return -2482; } int test_int_1(int a) { - return -a; + return -100; } int test_int_2(int a, int b) { - return a + b; + return 30; } int test_int_3(int a, int b, int c) { - return a + b - c; + return -8; } int test_int_4(int a, int b, int c, int d) { - return a + b * c + d; + return 200997; } int test_int_5(int a, int b, int c, int d, int e) { - return a + b - c + d * e; + return -2144725863; } int test_int_6(int a, int b, int c, int d, int e, int f) { - return a * b * c + d * e - f; + return -1223446720; } int test_int_7(int a, int b, int c, int d, int e, int f, int g) { - return a / b + c + d * e - f * g; + return -19; } int test_int_8(int a, int b, int c, int d, int e, int f, int g, int h) { - return a + b + c + d + e + f + g + h; + return 214322534; } int test_int_9(int a, int b, int c, int d, int e, int f, int g, int h, int i) { - return a - b - c - d - e - f - g - h - i; + return -2482; } long test_long_1(long a) @@ -141,40 +141,40 @@ long test_long_2(long a, long b) { - return a + b; + return a * b; } long test_long_3(long a, long b, long c) { - return a + b - c; + return a * b * c; } long test_long_4(long a, long b, long c, long d) { - return a + b * c + d; + return a * b * c * d; } long test_long_5(long a, long b, long c, long d, long e) { - return a + b - c + d * e; + return a * b * c * d * e; } long test_long_6(long a, long b, long c, long d, long e, long f) { - return a * b * c + d * e - f; + return a * b * c * d * e * f; } long test_long_7(long a, long b, long c, long d, long e, long f, long g) { - return a / b + c + d * e - f * g; + return a * b * c * d * e * f * g; } long test_long_8(long a, long b, long c, long d, long e, long f, long g, long h) { - return a + b + c + d + e + f + g + h; + return 0; } long test_long_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) { - return a - b - c - d - e - f - g - h - i; + return a * b * c * d * e * f * g * h * i; } diff -Nru latrace-0.5.10.20110523/test/lib-test-common.c latrace-0.5.11/test/lib-test-common.c --- latrace-0.5.10.20110523/test/lib-test-common.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/test/lib-test-common.c 2011-08-09 16:28:37.000000000 +0000 @@ -3,3 +3,7 @@ void test_common_f1(void) { } + +void test_common_args_ptrlen(char *ptr) +{ +} diff -Nru latrace-0.5.10.20110523/test/lib-test-libsym1.c latrace-0.5.11/test/lib-test-libsym1.c --- latrace-0.5.10.20110523/test/lib-test-libsym1.c 1970-01-01 00:00:00.000000000 +0000 +++ latrace-0.5.11/test/lib-test-libsym1.c 2011-08-09 16:28:37.000000000 +0000 @@ -0,0 +1,3 @@ +void test_libsym1_1(void) { } +void test_libsym1_2(void) { } +void test_libsym1_3(void) { } diff -Nru latrace-0.5.10.20110523/test/lib-test-libsym2.c latrace-0.5.11/test/lib-test-libsym2.c --- latrace-0.5.10.20110523/test/lib-test-libsym2.c 1970-01-01 00:00:00.000000000 +0000 +++ latrace-0.5.11/test/lib-test-libsym2.c 2011-08-09 16:28:37.000000000 +0000 @@ -0,0 +1,3 @@ +void test_libsym2_1(void) { } +void test_libsym2_2(void) { } +void test_libsym2_3(void) { } diff -Nru latrace-0.5.10.20110523/test/lib-test-libsym3.c latrace-0.5.11/test/lib-test-libsym3.c --- latrace-0.5.10.20110523/test/lib-test-libsym3.c 1970-01-01 00:00:00.000000000 +0000 +++ latrace-0.5.11/test/lib-test-libsym3.c 2011-08-09 16:28:37.000000000 +0000 @@ -0,0 +1,3 @@ +void test_libsym3_1(void) { } +void test_libsym3_2(void) { } +void test_libsym3_3(void) { } diff -Nru latrace-0.5.10.20110523/test/Makefile latrace-0.5.11/test/Makefile --- latrace-0.5.10.20110523/test/Makefile 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/test/Makefile 2011-08-09 16:28:37.000000000 +0000 @@ -7,22 +7,55 @@ lib-test-args.so: test/lib-test-args.o $(QUIET_LD)$(CC) $(CFLAGS) -fPIC -shared $(LDFLAGS) -o $@ $^ +lib-test-libsym1.so: test/lib-test-libsym1.o + $(QUIET_LD)$(CC) $(CFLAGS) -fPIC -shared $(LDFLAGS) -o $@ $^ + +lib-test-libsym2.so: test/lib-test-libsym2.o + $(QUIET_LD)$(CC) $(CFLAGS) -fPIC -shared $(LDFLAGS) -o $@ $^ + +lib-test-libsym3.so: test/lib-test-libsym3.o + $(QUIET_LD)$(CC) $(CFLAGS) -fPIC -shared $(LDFLAGS) -o $@ $^ + test-common: test/test-lib.o test/test-common.o $(QUIET_LD)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ lib-test-common.so test-args: test/test-lib.o test/test-args.o test/sysdeps/$(CONFIG_SYSDEP_DIR)/test-args.o $(QUIET_LD)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ lib-test-args.so +test-kill: test/test-kill.o + $(QUIET_LD)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ + +test-libsym: test/test-libsym.o test/test-lib.o + $(QUIET_LD)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ lib-test-libsym1.so lib-test-libsym2.so lib-test-libsym3.so + OBJS+=test/test-lib.o +PROGRAMS+=\ + lib-test-args.so \ + test-args OBJS+=\ test/lib-test-args.o \ test/test-args.o \ test/sysdeps/$(CONFIG_SYSDEP_DIR)/test-args.o +PROGRAMS+=\ + lib-test-common.so \ + test-common OBJS+=\ test/lib-test-common.o \ test/test-common.o -PROGRAMS+=lib-test-common.so test-common -PROGRAMS+=lib-test-args.so test-args +PROGRAMS+=\ + lib-test-libsym1.so \ + lib-test-libsym2.so \ + lib-test-libsym3.so \ + test-libsym +OBJS+=\ + test/test-libsym.o \ + test/lib-test-libsym1.o + +PROGRAMS+=\ + test-kill +OBJS+=\ + test/test-kill.o + diff -Nru latrace-0.5.10.20110523/test/script/functions.sh latrace-0.5.11/test/script/functions.sh --- latrace-0.5.10.20110523/test/script/functions.sh 1970-01-01 00:00:00.000000000 +0000 +++ latrace-0.5.11/test/script/functions.sh 2011-08-09 16:28:37.000000000 +0000 @@ -0,0 +1,21 @@ +#!/bin/bash + +function CHECK_RET +{ + if [ $? -ne 0 ]; then + echo " FAILED" + exit -1 + else + echo -n "." + fi +} + +function TEST +{ + func=$1 + + source $PWD/test/script/$1.sh + echo -n "$1" + eval $1 + echo OK +} diff -Nru latrace-0.5.10.20110523/test/script/test_args.sh latrace-0.5.11/test/script/test_args.sh --- latrace-0.5.10.20110523/test/script/test_args.sh 1970-01-01 00:00:00.000000000 +0000 +++ latrace-0.5.11/test/script/test_args.sh 2011-08-09 16:28:37.000000000 +0000 @@ -0,0 +1,9 @@ +#!/bin/bash + +. $PWD/test/script/functions.sh + +function test_args +{ + LD_LIBRARY_PATH=$PWD ./latrace -qR -a $PWD/test/lib-test-args.conf ./test-args > /dev/null + CHECK_RET +} diff -Nru latrace-0.5.10.20110523/test/script/test_common.sh latrace-0.5.11/test/script/test_common.sh --- latrace-0.5.10.20110523/test/script/test_common.sh 1970-01-01 00:00:00.000000000 +0000 +++ latrace-0.5.11/test/script/test_common.sh 2011-08-09 16:28:37.000000000 +0000 @@ -0,0 +1,15 @@ +#!/bin/bash + +. $PWD/test/script/functions.sh + +function test_common +{ + cat > /tmp/tc_latrace.conf < /dev/null + CHECK_RET + + rm -f /tmp/tc_latrace.conf +} diff -Nru latrace-0.5.10.20110523/test/script/test_kill.sh latrace-0.5.11/test/script/test_kill.sh --- latrace-0.5.10.20110523/test/script/test_kill.sh 1970-01-01 00:00:00.000000000 +0000 +++ latrace-0.5.11/test/script/test_kill.sh 2011-08-09 16:28:37.000000000 +0000 @@ -0,0 +1,133 @@ +#!/bin/bash + +. $PWD/test/script/functions.sh + +function tk_init +{ + arg=$1 + + if [ x$arg == xnopipe ]; then + cat > /tmp/tk_latrace.conf < /tmp/tk_latrace.conf + fi +} + +function tk_cleanup +{ + rm -f /tmp/tk_latrace.conf + rm -f test-kill.expect + rm -f test-kill.out +} + + +function tk_wait_start +{ + name=$1 + + while [ -z `pgrep $name` ]; + do + usleep 100 + done +} + +function tk_wait_stop +{ + pid=$1 + + while [ `kill -0 $pid 2> /dev/null; echo $?` == "0" ]; + do + usleep 100 + done +} + +function test_kill_handlers +{ + tk_init $1 + ./latrace -N /tmp/tk_latrace.conf -q $PWD/test-kill 1 > test-kill.out & + + tk_wait_start test-kill + + pid_latrace=$! + pid_test=`pgrep test-kill` + + kill -2 $pid_latrace + + tk_wait_stop $pid_latrace + tk_wait_stop $pid_test + + echo -e "\nlatrace interrupted, killing child (pid $pid_test)" > test-kill.expect + echo -e "\n$PWD/test-kill finished - exited, status=0" >> test-kill.expect + + diff test-kill.out test-kill.expect + CHECK_RET +} + +function test_kill_nohandlers +{ + tk_init $1 + ./latrace -N /tmp/tk_latrace.conf -q $PWD/test-kill 2 > test-kill.out & + + tk_wait_start test-kill + + pid_latrace=$! + pid_test=`pgrep test-kill` + + kill -2 $pid_latrace + + tk_wait_stop $pid_latrace + tk_wait_stop $pid_test + + echo -e "\nlatrace interrupted, killing child (pid $pid_test)" > test-kill.expect + echo -e "\n$PWD/test-kill finished - killed by signal 15" >> test-kill.expect + + diff test-kill.out test-kill.expect + if [ $? -ne 0 ]; then + echo "FAILED test_kill" + read + exit + fi + + echo -n . +} + + +function test_kill_blocked +{ + tk_init $1 + ./latrace -N /tmp/tk_latrace.conf -q $PWD/test-kill 3 > test-kill.out & + + tk_wait_start test-kill + + pid_latrace=$! + pid_test=`pgrep test-kill` + + kill -2 $pid_latrace + + tk_wait_stop $pid_latrace + tk_wait_stop $pid_test + + echo -e "\nlatrace interrupted, killing child (pid $pid_test)" > test-kill.expect + echo -e "\n$PWD/test-kill finished - killed by signal 9" >> test-kill.expect + + diff test-kill.out test-kill.expect + CHECK_RET +} + +function test_kill +{ + test_kill_handlers + test_kill_handlers nopipe + + test_kill_nohandlers + test_kill_nohandlers nopipe + + test_kill_blocked + test_kill_blocked nopipe + + tk_cleanup +} diff -Nru latrace-0.5.10.20110523/test/script/test_libsym.sh latrace-0.5.11/test/script/test_libsym.sh --- latrace-0.5.10.20110523/test/script/test_libsym.sh 1970-01-01 00:00:00.000000000 +0000 +++ latrace-0.5.11/test/script/test_libsym.sh 2011-08-09 16:28:37.000000000 +0000 @@ -0,0 +1,141 @@ +. $PWD/test/script/functions.sh + +function tls_cleanup +{ + rm -f /tmp/tls_latrace.conf +} + +function test_libsym_all +{ + LD_LIBRARY_PATH=$PWD ./latrace -qR $PWD/test-libsym all > /dev/null + CHECK_RET +} + +function test_libsym_lib1 +{ + cat > /tmp/tls_latrace.conf < /dev/null + CHECK_RET +} + +function test_libsym_lib2 +{ + cat > /tmp/tls_latrace.conf < /dev/null + CHECK_RET +} + +function test_libsym_lib3 +{ + cat > /tmp/tls_latrace.conf < /dev/null + CHECK_RET +} + +function test_libsym_lib1lib2 +{ + cat > /tmp/tls_latrace.conf < /dev/null + CHECK_RET +} + +function test_libsym_lib2lib3 +{ + cat > /tmp/tls_latrace.conf < /dev/null + CHECK_RET +} + +function test_libsym_lib1lib2lib3 +{ + cat > /tmp/tls_latrace.conf < /dev/null + CHECK_RET +} + +function test_libsym_sym1 +{ + cat > /tmp/tls_latrace.conf < /dev/null + CHECK_RET +} + +function test_libsym_sym2sym3 +{ + cat > /tmp/tls_latrace.conf < /dev/null + CHECK_RET +} + +function test_libsym_omit_sym1 +{ + cat > /tmp/tls_latrace.conf < /dev/null + CHECK_RET +} + +function test_libsym_omit_sym2sym3 +{ + cat > /tmp/tls_latrace.conf < /dev/null + CHECK_RET +} + +function test_libsym +{ + test_libsym_all + test_libsym_lib1 + test_libsym_lib2 + test_libsym_lib3 + test_libsym_lib1lib2 + test_libsym_lib2lib3 + test_libsym_lib1lib2lib3 + test_libsym_sym1 + test_libsym_sym2sym3 + test_libsym_omit_sym1 + test_libsym_omit_sym2sym3 + +# TODO tests for LIBS_TO, LIBS_FROM, SYM_BELOW, SYM_NOEXIT + + tls_cleanup +} diff -Nru latrace-0.5.10.20110523/test/script/test_tty_output.sh latrace-0.5.11/test/script/test_tty_output.sh --- latrace-0.5.10.20110523/test/script/test_tty_output.sh 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/test/script/test_tty_output.sh 2011-08-09 16:28:37.000000000 +0000 @@ -1,4 +1,6 @@ -#!/bin/sh +#!/bin/bash + +. $PWD/test/script/functions.sh function tto_init { @@ -23,12 +25,7 @@ $PWD/test/script/test_tty_output.sh > /dev/null diff /tmp/tto_latrace.output $PWD/test/script/test_tty_output.sh - if [ $? -ne 0 ]; then - echo "FAILED test_tty_output" - exit - fi + CHECK_RET tto_cleanup - - echo . } diff -Nru latrace-0.5.10.20110523/test/sysdeps/arm/test-args.c latrace-0.5.11/test/sysdeps/arm/test-args.c --- latrace-0.5.10.20110523/test/sysdeps/arm/test-args.c 1970-01-01 00:00:00.000000000 +0000 +++ latrace-0.5.11/test/sysdeps/arm/test-args.c 2011-08-09 16:28:37.000000000 +0000 @@ -0,0 +1,2 @@ + +#include diff -Nru latrace-0.5.10.20110523/test/sysdeps/i686/test-args.c latrace-0.5.11/test/sysdeps/i686/test-args.c --- latrace-0.5.10.20110523/test/sysdeps/i686/test-args.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/test/sysdeps/i686/test-args.c 2011-08-09 16:28:37.000000000 +0000 @@ -1,68 +1,2 @@ -#include - -int test_long(struct lt_config_shared *sh) -{ - struct re_test_data data1[] = { - { RE_TEST_TYPE_STR, 0, 27, "test_long_1\\(a = 1294967294\\)" }, - { RE_TEST_TYPE_STR, 28, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_1 = -1294967294" }, - }; - struct re_test_data data2[] = { - { RE_TEST_TYPE_STR, 0, 39, "test_long_2\\(a = 123410, b = -268435455\\)" }, - { RE_TEST_TYPE_STR, 40, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_2 = -268312045" }, - }; - struct re_test_data data3[] = { - { RE_TEST_TYPE_STR, 0, 38, "test_long_3\\(a = 1, b = -2, c = 234217\\)" }, - { RE_TEST_TYPE_STR, 39, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_3 = -234218" }, - }; - struct re_test_data data4[] = { - { RE_TEST_TYPE_STR, 0, 55, "test_long_4\\(a = 2025479151, b = 2, c = 9119999, d = -1\\)" }, - { RE_TEST_TYPE_STR, 56, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_4 = 2043719148" }, - }; - struct re_test_data data5[] = { - { RE_TEST_TYPE_STR, 0, 63, "test_long_5\\(a = -1, b = 2147483647, c = 13, d = 100, e = 34121\\)" }, - { RE_TEST_TYPE_STR, 64, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_5 = -2144071563" }, - }; - struct re_test_data data6[] = { - { RE_TEST_TYPE_STR, 0, 79, "test_long_6\\(a = 100, b = 102143210, c = -345436543, d = 12, e = -45, f = -1324\\)" }, - { RE_TEST_TYPE_STR, 80, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_6 = -1913679240" }, - }; - struct re_test_data data7[] = { - { RE_TEST_TYPE_STR, 0, 71, "test_long_7\\(a = 1, b = 24321, c = -3, d = 4, e = 432145, f = 6, g = 27\\)" }, - { RE_TEST_TYPE_STR, 72, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_7 = 1728415" }, - }; - struct re_test_data data8[] = { - { RE_TEST_TYPE_STR, 0, 96, "test_long_8\\(a = -11111, b = 214321543, c = 30, d = -4, e = 51432123, f = -123, g = 7000, h = 76\\)" }, - { RE_TEST_TYPE_STR, 97, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_8 = 265749534" }, - }; - struct re_test_data data9[] = { - { RE_TEST_TYPE_STR, 0, 93, "test_long_9\\(a = -10, b = 1, c = 3, d = 12424234, e = 9, f = 3, g = 14321311, h = -99, i = 10\\)" }, - { RE_TEST_TYPE_STR, 94, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_9 = -26745482" }, - }; - #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) - - CONFIG_CLEAR_ARGS(sh); - - LOCAL_TEST(data1, DATA_CNT(1), test_long_1(1294967294)); - LOCAL_TEST(data2, DATA_CNT(2), test_long_2(123410, -268435455)); - LOCAL_TEST(data3, DATA_CNT(3), test_long_3(1, -2, 234217)); - LOCAL_TEST(data4, DATA_CNT(4), test_long_4(2025479151, 2, 9119999, -1)); - LOCAL_TEST(data5, DATA_CNT(5), test_long_5(-1, 2147483647, 13, 100, 34121)); - LOCAL_TEST(data6, DATA_CNT(6), test_long_6(100, 102143210, -345436543, 12, -45, -1324)); - LOCAL_TEST(data7, DATA_CNT(7), test_long_7(1, 24321, -3, 4, 432145, 6, 27)); - LOCAL_TEST(data8, DATA_CNT(8), test_long_8(-11111, 214321543, 30, -4, 51432123, -123, 7000, 76)); - LOCAL_TEST(data9, DATA_CNT(9), test_long_9(-10, 1, 3, 12424234, 9, 3, 14321311, -99, 10)); - - PASSED(); - return 0; -} - +#include diff -Nru latrace-0.5.10.20110523/test/sysdeps/x86_64/test-args.c latrace-0.5.11/test/sysdeps/x86_64/test-args.c --- latrace-0.5.10.20110523/test/sysdeps/x86_64/test-args.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/test/sysdeps/x86_64/test-args.c 2011-08-09 16:28:37.000000000 +0000 @@ -1,68 +1,2 @@ -#include - -int test_long(struct lt_config_shared *sh) -{ - struct re_test_data data1[] = { - { RE_TEST_TYPE_STR, 0, 36, "test_long_1\\(a = 1152921504606846975\\)" }, - { RE_TEST_TYPE_STR, 37, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_1 = -1152921504606846975" }, - }; - struct re_test_data data2[] = { - { RE_TEST_TYPE_STR, 0, 47, "test_long_2\\(a = 123410, b = -12391243214298120\\)" }, - { RE_TEST_TYPE_STR, 48, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_2 = -12391243214174710" }, - }; - struct re_test_data data3[] = { - { RE_TEST_TYPE_STR, 0, 38, "test_long_3\\(a = 1, b = -2, c = 234217\\)" }, - { RE_TEST_TYPE_STR, 39, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_3 = -234218" }, - }; - struct re_test_data data4[] = { - { RE_TEST_TYPE_STR, 0, 61, "test_long_4\\(a = 1999990880043210, b = 2, c = 9119999, d = -1\\)" }, - { RE_TEST_TYPE_STR, 62, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_4 = 1999990898283207" }, - }; - struct re_test_data data5[] = { - { RE_TEST_TYPE_STR, 0, 63, "test_long_5\\(a = -1, b = 2147483647, c = 13, d = 100, e = 34121\\)" }, - { RE_TEST_TYPE_STR, 64, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_5 = 2150895733" }, - }; - struct re_test_data data6[] = { - { RE_TEST_TYPE_STR, 0, 91, "test_long_6\\(a = 100, b = 20432143210, c = -345436543, d = 12, e = 9999999999999, f = -1324\\)" }, - { RE_TEST_TYPE_STR, 92, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_6 = -4824496853369340280" }, - }; - struct re_test_data data7[] = { - { RE_TEST_TYPE_STR, 0, 71, "test_long_7\\(a = 1, b = 24321, c = -3, d = 4, e = 432145, f = 6, g = 27\\)" }, - { RE_TEST_TYPE_STR, 72, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_7 = 1728415" }, - }; - struct re_test_data data8[] = { - { RE_TEST_TYPE_STR, 0, 96, "test_long_8\\(a = -11111, b = 214321543, c = 30, d = -4, e = 51432123, f = -123, g = 7000, h = 76\\)" }, - { RE_TEST_TYPE_STR, 97, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_8 = 265749534" }, - }; - struct re_test_data data9[] = { - { RE_TEST_TYPE_STR, 0, 100, "test_long_9\\(a = -10, b = 1, c = 3, d = 124321432234134, e = 9, f = 3, g = 14321311, h = -99, i = 10\\)" }, - { RE_TEST_TYPE_STR, 101, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_9 = -124321446555382" }, - }; - #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) - - CONFIG_CLEAR_ARGS(sh); - - LOCAL_TEST(data1, DATA_CNT(1), test_long_1(1152921504606846975)); - LOCAL_TEST(data2, DATA_CNT(2), test_long_2(123410, -12391243214298120)); - LOCAL_TEST(data3, DATA_CNT(3), test_long_3(1, -2, 234217)); - LOCAL_TEST(data4, DATA_CNT(4), test_long_4(1999990880043210, 2, 9119999, -1)); - LOCAL_TEST(data5, DATA_CNT(5), test_long_5(-1, 2147483647, 13, 100, 34121)); - LOCAL_TEST(data6, DATA_CNT(6), test_long_6(100, 20432143210, -345436543, 12, 9999999999999, -1324)); - LOCAL_TEST(data7, DATA_CNT(7), test_long_7(1, 24321, -3, 4, 432145, 6, 27)); - LOCAL_TEST(data8, DATA_CNT(8), test_long_8(-11111, 214321543, 30, -4, 51432123, -123, 7000, 76)); - LOCAL_TEST(data9, DATA_CNT(9), test_long_9(-10, 1, 3, 124321432234134, 9, 3, 14321311, -99, 10)); - - PASSED(); - return 0; -} - +#include diff -Nru latrace-0.5.10.20110523/test/test-args.c latrace-0.5.11/test/test-args.c --- latrace-0.5.10.20110523/test/test-args.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/test/test-args.c 2011-08-09 16:28:37.000000000 +0000 @@ -27,9 +27,9 @@ { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_4 = 0xc9" }, }; struct re_test_data data5[] = { - { RE_TEST_TYPE_STR, 0, 65, "test_char_5\\(a = 0xff, b = 0x15, c = 0x0d, d = 0x20, e = 0x79 'y'\\)" }, - { RE_TEST_TYPE_STR, 66, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_5 = 0xc7" }, + { RE_TEST_TYPE_STR, 0, 69, "test_char_5\\(a = 0xff, b = 0x15, c = 0x0d, d = 0x20 ' ', e = 0x79 'y'\\)" }, + { RE_TEST_TYPE_STR, 70, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_5 = 0x02" }, }; struct re_test_data data6[] = { { RE_TEST_TYPE_STR, 0, 75, "test_char_6\\(a = 0x64 'd', b = 0xc8, c = 0xd5, d = 0x0c, e = 0xc7, f = 0xf2\\)" }, @@ -44,7 +44,7 @@ struct re_test_data data8[] = { { RE_TEST_TYPE_STR, 0, 95, "test_char_8\\(a = 0xf5, b = 0x15, c = 0x1e, d = 0xfc, e = 0x17, f = 0x85, g = 0x46 'F', h = 0x06\\)" }, { RE_TEST_TYPE_STR, 96, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_8 = 0xc9" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_8 = 0x39 '9'" }, }; struct re_test_data data9[] = { { RE_TEST_TYPE_STR, 0, 109, "test_char_9\\(a = 0xf6, b = 0x01, c = 0x03, d = 0x04, e = 0x09, f = 0x63 'c', g = 0x4e 'N', h = 0xf7, i = 0x0c\\)" }, diff -Nru latrace-0.5.10.20110523/test/test-args.h latrace-0.5.11/test/test-args.h --- latrace-0.5.10.20110523/test/test-args.h 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/test/test-args.h 2011-08-09 16:28:37.000000000 +0000 @@ -13,19 +13,4 @@ sh->hide_tid = 1; \ } while(0) -#define LOCAL_TEST(data, cnt, test) \ -do { \ - char buf[BUFSIZE]; \ - int ret; \ - TEST_START(); \ - test; \ - TEST_STOP(); \ - ret = fout_read(sh, buf, BUFSIZE); \ - if (!ret) \ - return -1; \ - ret = re_test(buf, data, cnt); \ - if (RE_TEST_OK != ret) \ - FAILED("test %i, pattern '%s'\n", ret, data[ret].pat); \ -} while(0) - #endif /* TEST_ARGS_H */ diff -Nru latrace-0.5.10.20110523/test/test-args-long-32.c latrace-0.5.11/test/test-args-long-32.c --- latrace-0.5.10.20110523/test/test-args-long-32.c 1970-01-01 00:00:00.000000000 +0000 +++ latrace-0.5.11/test/test-args-long-32.c 2011-08-09 16:28:37.000000000 +0000 @@ -0,0 +1,69 @@ + +#include + +#include + +int test_long(struct lt_config_shared *sh) +{ + struct re_test_data data1[] = { + { RE_TEST_TYPE_STR, 0, 27, "test_long_1\\(a = 1294967294\\)" }, + { RE_TEST_TYPE_STR, 28, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_1 = -1294967294" }, + }; + struct re_test_data data2[] = { + { RE_TEST_TYPE_STR, 0, 39, "test_long_2\\(a = 123410, b = -268435455\\)" }, + { RE_TEST_TYPE_STR, 40, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_2 = -536747502" }, + }; + struct re_test_data data3[] = { + { RE_TEST_TYPE_STR, 0, 38, "test_long_3\\(a = 1, b = -2, c = 234217\\)" }, + { RE_TEST_TYPE_STR, 39, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_3 = -468434" }, + }; + struct re_test_data data4[] = { + { RE_TEST_TYPE_STR, 0, 55, "test_long_4\\(a = 2025479151, b = 2, c = 9119999, d = -1\\)" }, + { RE_TEST_TYPE_STR, 56, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_4 = 1786259934" }, + }; + struct re_test_data data5[] = { + { RE_TEST_TYPE_STR, 0, 63, "test_long_5\\(a = -1, b = 2147483647, c = 13, d = 100, e = 34121\\)" }, + { RE_TEST_TYPE_STR, 64, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_5 = 44357300" }, + }; + struct re_test_data data6[] = { + { RE_TEST_TYPE_STR, 0, 79, "test_long_6\\(a = 100, b = 102143210, c = -345436543, d = 12, e = -45, f = -1324\\)" }, + { RE_TEST_TYPE_STR, 80, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_6 = 111854720" }, + }; + struct re_test_data data7[] = { + { RE_TEST_TYPE_STR, 0, 71, "test_long_7\\(a = 1, b = 24321, c = -3, d = 4, e = 432145, f = 6, g = 27\\)" }, + { RE_TEST_TYPE_STR, 72, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_7 = -666544408" }, + }; + struct re_test_data data8[] = { + { RE_TEST_TYPE_STR, 0, 96, "test_long_8\\(a = -11111, b = 214321543, c = 30, d = -4, e = 51432123, f = -123, g = 7000, h = 76\\)" }, + { RE_TEST_TYPE_STR, 97, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_8 = 0" }, + }; + struct re_test_data data9[] = { + { RE_TEST_TYPE_STR, 0, 93, "test_long_9\\(a = -10, b = 1, c = 3, d = 12424234, e = 9, f = 3, g = 14321311, h = -99, i = 10\\)" }, + { RE_TEST_TYPE_STR, 94, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_9 = 1488062792" }, + }; + #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) + + CONFIG_CLEAR_ARGS(sh); + + LOCAL_TEST(data1, DATA_CNT(1), test_long_1(1294967294)); + LOCAL_TEST(data2, DATA_CNT(2), test_long_2(123410, -268435455)); + LOCAL_TEST(data3, DATA_CNT(3), test_long_3(1, -2, 234217)); + LOCAL_TEST(data4, DATA_CNT(4), test_long_4(2025479151, 2, 9119999, -1)); + LOCAL_TEST(data5, DATA_CNT(5), test_long_5(-1, 2147483647, 13, 100, 34121)); + LOCAL_TEST(data6, DATA_CNT(6), test_long_6(100, 102143210, -345436543, 12, -45, -1324)); + LOCAL_TEST(data7, DATA_CNT(7), test_long_7(1, 24321, -3, 4, 432145, 6, 27)); + LOCAL_TEST(data8, DATA_CNT(8), test_long_8(-11111, 214321543, 30, -4, 51432123, -123, 7000, 76)); + LOCAL_TEST(data9, DATA_CNT(9), test_long_9(-10, 1, 3, 12424234, 9, 3, 14321311, -99, 10)); + + PASSED(); + return 0; +} diff -Nru latrace-0.5.10.20110523/test/test-args-long-64.c latrace-0.5.11/test/test-args-long-64.c --- latrace-0.5.10.20110523/test/test-args-long-64.c 1970-01-01 00:00:00.000000000 +0000 +++ latrace-0.5.11/test/test-args-long-64.c 2011-08-09 16:28:37.000000000 +0000 @@ -0,0 +1,68 @@ + +#include + +int test_long(struct lt_config_shared *sh) +{ + struct re_test_data data1[] = { + { RE_TEST_TYPE_STR, 0, 36, "test_long_1\\(a = 1152921504606846975\\)" }, + { RE_TEST_TYPE_STR, 37, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_1 = -1152921504606846975" }, + }; + struct re_test_data data2[] = { + { RE_TEST_TYPE_STR, 0, 47, "test_long_2\\(a = 123410, b = -12391243214298120\\)" }, + { RE_TEST_TYPE_STR, 48, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_2 = 1876433041361794928" }, + }; + struct re_test_data data3[] = { + { RE_TEST_TYPE_STR, 0, 38, "test_long_3\\(a = 1, b = -2, c = 234217\\)" }, + { RE_TEST_TYPE_STR, 39, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_3 = -468434" }, + }; + struct re_test_data data4[] = { + { RE_TEST_TYPE_STR, 0, 61, "test_long_4\\(a = 1999990880043210, b = 2, c = 9119999, d = -1\\)" }, + { RE_TEST_TYPE_STR, 62, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_4 = 7830125791102782868" }, + }; + struct re_test_data data5[] = { + { RE_TEST_TYPE_STR, 0, 63, "test_long_5\\(a = -1, b = 2147483647, c = 13, d = 100, e = 34121\\)" }, + { RE_TEST_TYPE_STR, 64, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_5 = -95256576375073100" }, + }; + struct re_test_data data6[] = { + { RE_TEST_TYPE_STR, 0, 91, "test_long_6\\(a = 100, b = 20432143210, c = -345436543, d = 12, e = 9999999999999, f = -1324\\)" }, + { RE_TEST_TYPE_STR, 92, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_6 = -4763653747676887424" }, + }; + struct re_test_data data7[] = { + { RE_TEST_TYPE_STR, 0, 71, "test_long_7\\(a = 1, b = 24321, c = -3, d = 4, e = 432145, f = 6, g = 27\\)" }, + { RE_TEST_TYPE_STR, 72, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_7 = -20431825971480" }, + }; + struct re_test_data data8[] = { + { RE_TEST_TYPE_STR, 0, 96, "test_long_8\\(a = -11111, b = 214321543, c = 30, d = -4, e = 51432123, f = -123, g = 7000, h = 76\\)" }, + { RE_TEST_TYPE_STR, 97, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_8 = 0" }, + }; + struct re_test_data data9[] = { + { RE_TEST_TYPE_STR, 0, 100, "test_long_9\\(a = -10, b = 1, c = 3, d = 124321432234134, e = 9, f = 3, g = 14321311, h = -99, i = 10\\)" }, + { RE_TEST_TYPE_STR, 101, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_long_9 = -3544365624466803272" }, + }; + #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) + + CONFIG_CLEAR_ARGS(sh); + + LOCAL_TEST(data1, DATA_CNT(1), test_long_1(1152921504606846975)); + LOCAL_TEST(data2, DATA_CNT(2), test_long_2(123410, -12391243214298120)); + LOCAL_TEST(data3, DATA_CNT(3), test_long_3(1, -2, 234217)); + LOCAL_TEST(data4, DATA_CNT(4), test_long_4(1999990880043210, 2, 9119999, -1)); + LOCAL_TEST(data5, DATA_CNT(5), test_long_5(-1, 2147483647, 13, 100, 34121)); + LOCAL_TEST(data6, DATA_CNT(6), test_long_6(100, 20432143210, -345436543, 12, 9999999999999, -1324)); + LOCAL_TEST(data7, DATA_CNT(7), test_long_7(1, 24321, -3, 4, 432145, 6, 27)); + LOCAL_TEST(data8, DATA_CNT(8), test_long_8(-11111, 214321543, 30, -4, 51432123, -123, 7000, 76)); + LOCAL_TEST(data9, DATA_CNT(9), test_long_9(-10, 1, 3, 124321432234134, 9, 3, 14321311, -99, 10)); + + PASSED(); + return 0; +} + diff -Nru latrace-0.5.10.20110523/test/test-common.c latrace-0.5.11/test/test-common.c --- latrace-0.5.10.20110523/test/test-common.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/test/test-common.c 2011-08-09 16:28:37.000000000 +0000 @@ -4,7 +4,10 @@ #include extern void test_common_f1(void); +extern void test_common_args_ptrlen(char *ptr); + #define BUFSIZE 1000 +#define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) static int test_function(struct lt_config_shared *sh) { @@ -15,7 +18,6 @@ { RE_TEST_TYPE_STR, -1, -1, "test_common_f1" }, { RE_TEST_TYPE_STR, -1, -1, "\\[.*lib-test-common.so\\]" } }; - #define DATA_CNT (sizeof(data)/sizeof(struct re_test_data)) config_clear(sh); @@ -27,7 +29,37 @@ if (!ret) return -1; - ret = re_test(buf, data, DATA_CNT); + ret = re_test(buf, data, DATA_CNT()); + if (RE_TEST_OK != ret) + FAILED("test %i, pattern '%s'\n", ret, data[ret].pat); + + PASSED(); + return 0; +} + +static int test_args_ptrlen(struct lt_config_shared *sh) +{ + char buf[BUFSIZE]; + int ret; + struct re_test_data data[] = { + { RE_TEST_TYPE_PID, 1, -1, "[0-9]+" }, + { RE_TEST_TYPE_STR, -1, -1, " test_common_args_ptrlen\\(ptr = \\(0x[0-9a-z]+, 5\\) \"krava\"\\)" }, + { RE_TEST_TYPE_STR, -1, -1, "\\[.*lib-test-common.so\\]" } + }; + + config_clear(sh); + sh->args_string_pointer_length = 1; + sh->args_enabled = 1; + + TEST_START(); + test_common_args_ptrlen("krava"); + TEST_STOP(); + + ret = fout_read(sh, buf, BUFSIZE); + if (!ret) + return -1; + + ret = re_test(buf, data, DATA_CNT()); if (RE_TEST_OK != ret) FAILED("test %i, pattern '%s'\n", ret, data[ret].pat); @@ -44,5 +76,6 @@ return -1; TEST(test_function); + TEST(test_args_ptrlen); return 0; } diff -Nru latrace-0.5.10.20110523/test/test-kill.c latrace-0.5.11/test/test-kill.c --- latrace-0.5.10.20110523/test/test-kill.c 1970-01-01 00:00:00.000000000 +0000 +++ latrace-0.5.11/test/test-kill.c 2011-08-09 16:28:37.000000000 +0000 @@ -0,0 +1,45 @@ + +#include +#include + +static int exit_flag = 0; + +static void sig_term_handler(int sig) +{ + exit_flag = 1; +} + +int main(int argc, char **argv) +{ + int ignore = 0; + int handlers = 1;; + + if (argc != 2) + return -1; + + /* + * 1 - handlers + * 2 - no handlers + * 3 - ignore term/int + */ + + switch(*argv[1]) { + case '1': handlers = 1; break; + case '2': handlers = 0; break; + case '3': ignore = 1; break; + default: + return -1; + } + + if (handlers) { + if ((signal(SIGTERM, sig_term_handler) == SIG_ERR) || + (signal(SIGINT, sig_term_handler) == SIG_ERR)) + return -1; + } + + while(!exit_flag || ignore) { + usleep(100); + } + + return 0; +} diff -Nru latrace-0.5.10.20110523/test/test-lib.c latrace-0.5.11/test/test-lib.c --- latrace-0.5.10.20110523/test/test-lib.c 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/test/test-lib.c 2011-08-09 16:28:37.000000000 +0000 @@ -187,6 +187,8 @@ return i; break; } + + /* TODO ??? line += m[0].rm_eo; */ } return RE_TEST_OK; diff -Nru latrace-0.5.10.20110523/test/test-lib.h latrace-0.5.11/test/test-lib.h --- latrace-0.5.10.20110523/test/test-lib.h 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/test/test-lib.h 2011-08-09 16:28:37.000000000 +0000 @@ -62,4 +62,19 @@ #define BUFSIZE 1000 +#define LOCAL_TEST(data, cnt, test) \ +do { \ + char buf[BUFSIZE]; \ + int ret; \ + TEST_START(); \ + test; \ + TEST_STOP(); \ + ret = fout_read(sh, buf, BUFSIZE); \ + if (!ret) \ + return -1; \ + ret = re_test(buf, data, cnt); \ + if (RE_TEST_OK != ret) \ + FAILED("test %i, pattern '%s'\n", ret, data[ret].pat); \ +} while(0) + #endif diff -Nru latrace-0.5.10.20110523/test/test-libsym.c latrace-0.5.11/test/test-libsym.c --- latrace-0.5.10.20110523/test/test-libsym.c 1970-01-01 00:00:00.000000000 +0000 +++ latrace-0.5.11/test/test-libsym.c 2011-08-09 16:28:37.000000000 +0000 @@ -0,0 +1,283 @@ + +#include +#include +#include + +void test_libsym1_1(void); +void test_libsym1_2(void); +void test_libsym1_3(void); +void test_libsym2_1(void); +void test_libsym2_2(void); +void test_libsym2_3(void); +void test_libsym3_1(void); +void test_libsym3_2(void); +void test_libsym3_3(void); + +static void test_libsym(void) +{ + test_libsym1_1(); + test_libsym1_2(); + test_libsym1_3(); + test_libsym2_1(); + test_libsym2_2(); + test_libsym2_3(); + test_libsym3_1(); + test_libsym3_2(); + test_libsym3_3(); +} + +/* TODO + * so far following tests check for displayed output.. need + * some intelligent regex to check unwanted output is really + * not displayed */ + +static int test_all(struct lt_config_shared *sh) +{ + struct re_test_data data1[] = { + { RE_TEST_TYPE_STR, 0, -1, "test_libsym1_1 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym1_2 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym1_3 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_1 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_2 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_3 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_1 \\[[^]]+lib-test-libsym3.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_2 \\[[^]]+lib-test-libsym3.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_3 \\[[^]]+lib-test-libsym3.so\\]" }, + }; + #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) + + config_clear(sh); + sh->hide_tid = 1; + + LOCAL_TEST(data1, DATA_CNT(1), test_libsym()); + PASSED(); + return 0; +} + +static int test_lib1(struct lt_config_shared *sh) +{ + struct re_test_data data1[] = { + { RE_TEST_TYPE_STR, 0, -1, "test_libsym1_1 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym1_2 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym1_3 \\[[^]]+lib-test-libsym1.so\\]" }, + }; + #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) + + config_clear(sh); + sh->hide_tid = 1; + + LOCAL_TEST(data1, DATA_CNT(1), test_libsym()); + PASSED(); + return 0; +} + +static int test_lib2(struct lt_config_shared *sh) +{ + struct re_test_data data1[] = { + { RE_TEST_TYPE_STR, 0, -1, "test_libsym2_1 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_2 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_3 \\[[^]]+lib-test-libsym2.so\\]" }, + }; + #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) + + config_clear(sh); + sh->hide_tid = 1; + + LOCAL_TEST(data1, DATA_CNT(1), test_libsym()); + PASSED(); + return 0; +} + +static int test_lib3(struct lt_config_shared *sh) +{ + struct re_test_data data1[] = { + { RE_TEST_TYPE_STR, 0, -1, "test_libsym3_1 \\[[^]]+lib-test-libsym3.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_2 \\[[^]]+lib-test-libsym3.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_3 \\[[^]]+lib-test-libsym3.so\\]" }, + }; + #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) + + config_clear(sh); + sh->hide_tid = 1; + + LOCAL_TEST(data1, DATA_CNT(1), test_libsym()); + PASSED(); + return 0; +} + +static int test_lib1lib2(struct lt_config_shared *sh) +{ + struct re_test_data data1[] = { + { RE_TEST_TYPE_STR, 0, -1, "test_libsym1_1 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym1_2 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym1_3 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_1 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_2 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_3 \\[[^]]+lib-test-libsym2.so\\]" }, + }; + #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) + + config_clear(sh); + sh->hide_tid = 1; + + LOCAL_TEST(data1, DATA_CNT(1), test_libsym()); + PASSED(); + return 0; +} + +static int test_lib2lib3(struct lt_config_shared *sh) +{ + struct re_test_data data1[] = { + { RE_TEST_TYPE_STR, 0, -1, "test_libsym2_1 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_2 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_3 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_1 \\[[^]]+lib-test-libsym3.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_2 \\[[^]]+lib-test-libsym3.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_3 \\[[^]]+lib-test-libsym3.so\\]" }, + }; + #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) + + config_clear(sh); + sh->hide_tid = 1; + + LOCAL_TEST(data1, DATA_CNT(1), test_libsym()); + PASSED(); + return 0; +} + +static int test_lib1lib2lib3(struct lt_config_shared *sh) +{ + struct re_test_data data1[] = { + { RE_TEST_TYPE_STR, 0, -1, "test_libsym1_1 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym1_2 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym1_3 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_1 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_2 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_3 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_1 \\[[^]]+lib-test-libsym3.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_2 \\[[^]]+lib-test-libsym3.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_3 \\[[^]]+lib-test-libsym3.so\\]" }, + }; + #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) + + config_clear(sh); + sh->hide_tid = 1; + + LOCAL_TEST(data1, DATA_CNT(1), test_libsym()); + PASSED(); + return 0; +} + +static int test_sym1(struct lt_config_shared *sh) +{ + struct re_test_data data1[] = { + { RE_TEST_TYPE_STR, -1, -1, "test_libsym1_1 \\[[^]]+lib-test-libsym1.so\\]" }, + }; + #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) + + config_clear(sh); + sh->hide_tid = 1; + + LOCAL_TEST(data1, DATA_CNT(1), test_libsym()); + PASSED(); + return 0; +} + +static int test_sym2sym3(struct lt_config_shared *sh) +{ + struct re_test_data data1[] = { + { RE_TEST_TYPE_STR, 0, -1, "test_libsym2_2 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_3 \\[[^]]+lib-test-libsym3.so\\]" }, + }; + #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) + + config_clear(sh); + sh->hide_tid = 1; + + LOCAL_TEST(data1, DATA_CNT(1), test_libsym()); + PASSED(); + return 0; +} + +static int test_omit_sym1(struct lt_config_shared *sh) +{ + struct re_test_data data1[] = { + { RE_TEST_TYPE_STR, -1, -1, "test_libsym1_2 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym1_3 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_1 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_2 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_3 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_1 \\[[^]]+lib-test-libsym3.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_2 \\[[^]]+lib-test-libsym3.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_3 \\[[^]]+lib-test-libsym3.so\\]" }, + }; + #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) + + config_clear(sh); + sh->hide_tid = 1; + + LOCAL_TEST(data1, DATA_CNT(1), test_libsym()); + PASSED(); + return 0; +} + +static int test_omit_sym2sym3(struct lt_config_shared *sh) +{ + struct re_test_data data1[] = { + { RE_TEST_TYPE_STR, 0, -1, "test_libsym1_1 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym1_2 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym1_3 \\[[^]]+lib-test-libsym1.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_1 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym2_2 \\[[^]]+lib-test-libsym2.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_1 \\[[^]]+lib-test-libsym3.so\\]" }, + { RE_TEST_TYPE_STR, -1, -1, "test_libsym3_3 \\[[^]]+lib-test-libsym3.so\\]" }, + }; + #define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) + + config_clear(sh); + sh->hide_tid = 1; + + LOCAL_TEST(data1, DATA_CNT(1), test_libsym()); + PASSED(); + return 0; +} + +int main(int argc, char **argv) +{ + struct lt_config_shared *sh; + char *test; + + if (argc != 2) + return -1; + + test = argv[1]; + + sh = config_init(); + if (!sh) + return -1; + + if (!strcmp(test, "all")) + TEST(test_all); + else if (!strcmp(test, "lib1")) + TEST(test_lib1); + else if (!strcmp(test, "lib2")) + TEST(test_lib2); + else if (!strcmp(test, "lib3")) + TEST(test_lib3); + else if (!strcmp(test, "lib1lib2")) + TEST(test_lib1lib2); + else if (!strcmp(test, "lib2lib3")) + TEST(test_lib2lib3); + else if (!strcmp(test, "lib1lib2lib3")) + TEST(test_lib1lib2lib3); + else if (!strcmp(test, "sym1")) + TEST(test_sym1); + else if (!strcmp(test, "sym2sym3")) + TEST(test_sym2sym3); + else if (!strcmp(test, "omit_sym1")) + TEST(test_omit_sym1); + else if (!strcmp(test, "omit_sym2sym3")) + TEST(test_omit_sym2sym3); + + return 0; +} diff -Nru latrace-0.5.10.20110523/test/test.sh latrace-0.5.11/test/test.sh --- latrace-0.5.10.20110523/test/test.sh 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/test/test.sh 2011-08-09 16:28:37.000000000 +0000 @@ -1,14 +1,12 @@ -#!/bin/sh +#!/bin/bash -# common tests -echo "[APP test-common]" -LD_LIBRARY_PATH=$PWD ./latrace -qR ./test-common +# Force locale to ensure we always get the same output +export LC_ALL=C -# arguments tests -echo "[APP test-args]" -LD_LIBRARY_PATH=$PWD ./latrace -qR -a $PWD/test/lib-test-args.conf ./test-args +. $PWD/test/script/functions.sh -# script tests -echo "[SCRIPTS]" -. $PWD/test/script/test_tty_output.sh -test_tty_output +TEST test_args +TEST test_common +TEST test_tty_output +TEST test_kill +TEST test_libsym diff -Nru latrace-0.5.10.20110523/TODO latrace-0.5.11/TODO --- latrace-0.5.10.20110523/TODO 2011-05-14 18:09:35.000000000 +0000 +++ latrace-0.5.11/TODO 2011-08-09 16:28:37.000000000 +0000 @@ -4,11 +4,9 @@ olsajiri@gmail.com -for 0.5.11 +for 0.5.12 + - document the config file usage - testing/fixing bugs - - make automated tests - -for 0.6 - config - arrays in structures - add mask enum support (ORed values) - add support for display number at different bases (2,8,10,16)