summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am19
-rw-r--r--README34
-rw-r--r--configure.ac3
-rw-r--r--matrace.c6
-rwxr-xr-xmatrace.in14
-rw-r--r--mutrace.c6
-rwxr-xr-xmutrace.in18
7 files changed, 94 insertions, 6 deletions
diff --git a/Makefile.am b/Makefile.am
index e8f4c94..703f610 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -27,7 +27,8 @@ EXTRA_DIST = \
lib_LTLIBRARIES = \
libmutrace.la \
- libmatrace.la
+ libmatrace.la \
+ libmutrace-backtrace-symbols.la
bin_SCRIPTS = \
mutrace \
@@ -69,6 +70,21 @@ libmatrace_la_CFLAGS = \
$(PTHREAD_CFLAGS) \
-DSONAME=\"libmatrace.so\"
+libmutrace_backtrace_symbols_la_SOURCES = \
+ backtrace-symbols.c
+libmutrace_backtrace_symbols_la_LDFLAGS = \
+ -avoid-version \
+ -module \
+ -export-dynamic \
+ -shared \
+ -prefer-pic
+libmutrace_backtrace_symbols_la_LIBADD = \
+ $(PTHREAD_LIBS) \
+ -lrt \
+ -ldl
+libmutrace_backtrace_symbols_la_CFLAGS = \
+ $(PTHREAD_CFLAGS)
+
mutrace: mutrace.in Makefile
sed -e 's,@PACKAGE_STRING\@,$(PACKAGE_STRING),g' \
-e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' < $< > $@
@@ -82,5 +98,6 @@ matrace: matrace.in Makefile
install-exec-hook:
rm -f $(DESTDIR)$(libdir)/libmutrace.la
rm -f $(DESTDIR)$(libdir)/libmatrace.la
+ rm -f $(DESTDIR)$(libdir)/libmutrace-backtrace-symbols.la
ACLOCAL_AMFLAGS = -I m4
diff --git a/README b/README
index 6a311b2..5195524 100644
--- a/README
+++ b/README
@@ -7,14 +7,46 @@ GITWEB:
http://git.0pointer.de/?p=mutrace.git
NOTES:
- For a terse overview wht mutrace can do for you, please read
+ For a terse overview what mutrace can do for you, please read
the announcement blog story:
http://0pointer.de/blog/projects/mutrace.html
+ The tarball includes two profilers:
+
+ mutrace profiles lock contention for you. Just use it as
+ prefix for your usual command line and it will profile
+ mutexes used in all child processes. Example:
+
+ mutrace gedit
+
+ matrace traces memory allocation operations in realtime
+ threads for you. It is of no use in applications that do not
+ make use of realtime scheduling. Example:
+
+ matrace myrealtimetool
+
+ Both tools understand a --debug-info switch in which case the
+ backtraces generated will include debugging information such as
+ line numbers and source file names. This is not enabled by
+ default since generating those traces is not always safe in
+ situations where locks are taken or memory allocated as we do
+ it here. YMMV.
+
+ mutrace cannot be used to profile glibc-internal mutexes.
+
LICENSE:
LGPLv3+
+ Exception:
+
+ backtrace-symbols.c is GPLv2+. Which probably means that using
+ the --debug-info switch for mutrace and matrace might not be
+ legally safe for non-GPL-compatible applications. However,
+ since that module is independantly built into a seperate .so
+ it should still be safe using the profilers without this
+ switch on such software.
+
AUTHORS:
Lennart Poettering
diff --git a/configure.ac b/configure.ac
index 551143c..ccfc514 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,6 +72,9 @@ AC_CHECK_HEADERS([sys/poll.h])
AC_CHECK_HEADERS([sys/ioctl.h])
AC_CHECK_HEADERS([byteswap.h])
+AC_SEARCH_LIBS([bfd_init], [bfd], [], [AC_MSG_ERROR([*** libbfd not found])])
+AC_CHECK_HEADERS([bfd.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])])
+
#### Typdefs, structures, etc. ####
AC_C_CONST
diff --git a/matrace.c b/matrace.c
index ddee2e2..e2183a2 100644
--- a/matrace.c
+++ b/matrace.c
@@ -248,12 +248,18 @@ static bool is_realtime(void) {
static bool verify_frame(const char *s) {
+ /* Generated by glibc's native backtrace_symbols() on Fedora */
if (strstr(s, "/" SONAME "("))
return false;
+ /* Generated by glibc's native backtrace_symbols() on Debian */
if (strstr(s, "/" SONAME " ["))
return false;
+ /* Generated by backtrace-symbols.c */
+ if (strstr(s, __FILE__":"))
+ return false;
+
return true;
}
diff --git a/matrace.in b/matrace.in
index 7d4d8c6..7ab078f 100755
--- a/matrace.in
+++ b/matrace.in
@@ -17,12 +17,14 @@
# You should have received a copy of the GNU Lesser General Public
# License along with mutrace. If not, see <http://www.gnu.org/licenses/>.
-if ! TEMP=`getopt -o +h --long frames:,help -n matrace -- "$@"` ; then
+if ! TEMP=`getopt -o +dh --long frames:,debug-info,help -n matrace -- "$@"` ; then
exit 1
fi
eval set -- "$TEMP"
+debug_info=0
+
while : ; do
case $1 in
--frames)
@@ -30,6 +32,11 @@ while : ; do
shift 2
;;
+ -d|--debug-info)
+ debug_info=1
+ shift 1
+ ;;
+
-h|--help)
cat <<EOF
@PACKAGE_STRING@
@@ -41,6 +48,7 @@ COMMANDS:
OPTIONS:
--frames=INTEGER Set number of frames to show in stack traces
+ -d, --debug-info Make use of debug information in stack traces
EOF
exit 0
;;
@@ -69,4 +77,8 @@ else
export LD_PRELOAD="$LD_PRELOAD libmatrace.so"
fi
+if [ x"$debug_info" = x1 ] ; then
+ export LD_PRELOAD="$LD_PRELOAD:libmutrace-backtrace-symbols.so"
+fi
+
exec "$@"
diff --git a/mutrace.c b/mutrace.c
index e8d0963..288867c 100644
--- a/mutrace.c
+++ b/mutrace.c
@@ -709,12 +709,18 @@ static bool is_realtime(void) {
static bool verify_frame(const char *s) {
+ /* Generated by glibc's native backtrace_symbols() on Fedora */
if (strstr(s, "/" SONAME "("))
return false;
+ /* Generated by glibc's native backtrace_symbols() on Debian */
if (strstr(s, "/" SONAME " ["))
return false;
+ /* Generated by backtrace-symbols.c */
+ if (strstr(s, __FILE__":"))
+ return false;
+
return true;
}
diff --git a/mutrace.in b/mutrace.in
index 8225f03..10b04b6 100755
--- a/mutrace.in
+++ b/mutrace.in
@@ -17,12 +17,14 @@
# You should have received a copy of the GNU Lesser General Public
# License along with mutrace. If not, see <http://www.gnu.org/licenses/>.
-if ! TEMP=`getopt -o +arh --long hash-size:,frames:,locked-min:,owner-changed-min:,contended-min:,max:,trap,help,all -n mutrace -- "$@"` ; then
+if ! TEMP=`getopt -o +ardh --long hash-size:,frames:,locked-min:,owner-changed-min:,contended-min:,max:,trap,help,all,debug-info -n mutrace -- "$@"` ; then
exit 1
fi
eval set -- "$TEMP"
+debug_info=0
+
while : ; do
case $1 in
--hash-size)
@@ -65,6 +67,11 @@ while : ; do
shift 1
;;
+ -d|--debug-info)
+ debug_info=1
+ shift 1
+ ;;
+
-a|--all)
export MUTRACE_LOCKED_MIN=0
export MUTRACE_OWNER_CHANGED_MIN=0
@@ -77,7 +84,7 @@ while : ; do
cat <<EOF
@PACKAGE_STRING@
-Usage: @PACKAGE_NAME@ [OPTIONS...] APPLICATION [ARGUMENTS...]
+Usage: mutrace [OPTIONS...] APPLICATION [ARGUMENTS...]
COMMANDS:
-h, --help Show this help
@@ -85,6 +92,7 @@ COMMANDS:
OPTIONS:
--hash-size=INTEGER Set size of mutex hash table
--frames=INTEGER Set number of frames to show in stack traces
+ -d, --debug-info Make use of debug information in stack traces
--max=INTEGER Show this many mutexes at maximum
--locked-min=INTEGER Only show mutexes that have been locked at
@@ -126,7 +134,11 @@ fi
if [ x"$LD_PRELOAD" = x ] ; then
export LD_PRELOAD="libmutrace.so"
else
- export LD_PRELOAD="$LD_PRELOAD libmutrace.so"
+ export LD_PRELOAD="$LD_PRELOAD:libmutrace.so"
+fi
+
+if [ x"$debug_info" = x1 ] ; then
+ export LD_PRELOAD="$LD_PRELOAD:libmutrace-backtrace-symbols.so"
fi
exec "$@"