Skip to content

Commit 7eebdcb

Browse files
committed
improved portability and fix for large number of threads
1 parent fe0f021 commit 7eebdcb

11 files changed

Lines changed: 652 additions & 4585 deletions

File tree

Makefile.in

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Makefile.in generated by automake 1.14.1 from Makefile.am.
1+
# Makefile.in generated by automake 1.15 from Makefile.am.
22
# @configure_input@
33

4-
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
4+
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
55

66
# This Makefile.in is free software; the Free Software Foundation
77
# gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,17 @@
1414

1515
@SET_MAKE@
1616
VPATH = @srcdir@
17-
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
17+
am__is_gnu_make = { \
18+
if test -z '$(MAKELEVEL)'; then \
19+
false; \
20+
elif test -n '$(MAKE_HOST)'; then \
21+
true; \
22+
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
23+
true; \
24+
else \
25+
false; \
26+
fi; \
27+
}
1828
am__make_running_with_option = \
1929
case $${target_option-} in \
2030
?) ;; \
@@ -78,16 +88,15 @@ POST_UNINSTALL = :
7888
build_triplet = @build@
7989
host_triplet = @host@
8090
subdir = .
81-
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
82-
$(top_srcdir)/configure $(am__configure_deps) ar-lib compile \
83-
config.guess config.sub depcomp install-sh missing ltmain.sh
8491
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
8592
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
8693
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
8794
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
8895
$(top_srcdir)/configure.ac
8996
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
9097
$(ACLOCAL_M4)
98+
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
99+
$(am__configure_deps) $(am__DIST_COMMON)
91100
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
92101
configure.lineno config.status.lineno
93102
mkinstalldirs = $(install_sh) -d
@@ -149,6 +158,8 @@ ETAGS = etags
149158
CTAGS = ctags
150159
CSCOPE = cscope
151160
DIST_SUBDIRS = $(SUBDIRS)
161+
am__DIST_COMMON = $(srcdir)/Makefile.in ar-lib compile config.guess \
162+
config.sub depcomp install-sh ltmain.sh missing
152163
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
153164
distdir = $(PACKAGE)-$(VERSION)
154165
top_distdir = $(distdir)
@@ -204,10 +215,6 @@ CCDEPMODE = @CCDEPMODE@
204215
CFLAGS = @CFLAGS@
205216
CPP = @CPP@
206217
CPPFLAGS = @CPPFLAGS@
207-
CXX = @CXX@
208-
CXXCPP = @CXXCPP@
209-
CXXDEPMODE = @CXXDEPMODE@
210-
CXXFLAGS = @CXXFLAGS@
211218
CYGPATH_W = @CYGPATH_W@
212219
DEFS = @DEFS@
213220
DEPDIR = @DEPDIR@
@@ -263,7 +270,6 @@ abs_top_builddir = @abs_top_builddir@
263270
abs_top_srcdir = @abs_top_srcdir@
264271
ac_ct_AR = @ac_ct_AR@
265272
ac_ct_CC = @ac_ct_CC@
266-
ac_ct_CXX = @ac_ct_CXX@
267273
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
268274
am__include = @am__include@
269275
am__leading_dot = @am__leading_dot@
@@ -302,6 +308,7 @@ pdfdir = @pdfdir@
302308
prefix = @prefix@
303309
program_transform_name = @program_transform_name@
304310
psdir = @psdir@
311+
runstatedir = @runstatedir@
305312
sbindir = @sbindir@
306313
sharedstatedir = @sharedstatedir@
307314
srcdir = @srcdir@
@@ -333,7 +340,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
333340
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
334341
$(am__cd) $(top_srcdir) && \
335342
$(AUTOMAKE) --foreign Makefile
336-
.PRECIOUS: Makefile
337343
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
338344
@case '$?' in \
339345
*config.status*) \
@@ -549,15 +555,15 @@ dist-xz: distdir
549555
$(am__post_remove_distdir)
550556

551557
dist-tarZ: distdir
552-
@echo WARNING: "Support for shar distribution archives is" \
553-
"deprecated." >&2
558+
@echo WARNING: "Support for distribution archives compressed with" \
559+
"legacy program 'compress' is deprecated." >&2
554560
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
555561
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
556562
$(am__post_remove_distdir)
557563

558564
dist-shar: distdir
559-
@echo WARNING: "Support for distribution archives compressed with" \
560-
"legacy program 'compress' is deprecated." >&2
565+
@echo WARNING: "Support for shar distribution archives is" \
566+
"deprecated." >&2
561567
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
562568
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
563569
$(am__post_remove_distdir)
@@ -593,17 +599,17 @@ distcheck: dist
593599
esac
594600
chmod -R a-w $(distdir)
595601
chmod u+w $(distdir)
596-
mkdir $(distdir)/_build $(distdir)/_inst
602+
mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
597603
chmod a-w $(distdir)
598604
test -d $(distdir)/_build || exit 0; \
599605
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
600606
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
601607
&& am__cwd=`pwd` \
602-
&& $(am__cd) $(distdir)/_build \
603-
&& ../configure \
608+
&& $(am__cd) $(distdir)/_build/sub \
609+
&& ../../configure \
604610
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
605611
$(DISTCHECK_CONFIGURE_FLAGS) \
606-
--srcdir=.. --prefix="$$dc_install_base" \
612+
--srcdir=../.. --prefix="$$dc_install_base" \
607613
&& $(MAKE) $(AM_MAKEFLAGS) \
608614
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
609615
&& $(MAKE) $(AM_MAKEFLAGS) check \
@@ -779,6 +785,8 @@ uninstall-am:
779785
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
780786
ps ps-am tags tags-am uninstall uninstall-am
781787

788+
.PRECIOUS: Makefile
789+
782790

783791
# Tell versions [3.59,3.63) of GNU make to not export all variables.
784792
# Otherwise a system limit (for SysV at least) may be exceeded.

README.md

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@ resource-constrained environments, such as embedded Linux systems.
99

1010
Supported Platforms
1111
===================
12-
libstackusage should work on most Linux systems with glibc present. It has
13-
however only been tested on:
14-
Ubuntu 14.04 LTS / Intel x64
12+
libstackusage is primarily developed and tested on Linux, but basic
13+
functionality should work in OS X as well. Current version has been tested on:
14+
- OS X El Capitan 10.11
15+
- Ubuntu 16.04 LTS
1516

1617
Installation
1718
============
18-
Download the source code package:
19+
Download the source code:
1920

20-
wget https://github.com/d99kris/libstackusage/archive/master.zip
21-
22-
Extract package and go to extracted directory:
23-
24-
unzip master.zip && cd libstackusage-master
21+
git clone https://github.com/d99kris/libstackusage && cd libstackusage
2522

2623
Configure and build:
2724

@@ -33,65 +30,86 @@ Optionally install in system:
3330

3431
Usage
3532
=====
33+
34+
Linux
35+
-----
36+
3637
General usage syntax:
3738

3839
[SU_STDERR=1] [SU_SYSLOG=1] LD_PRELOAD="/path/to/libstackusage.so" <application>
3940

4041
Example using libstackusage (without system install) with gedit and logging
41-
output at process stop to stderr:
42+
output to stderr:
4243

4344
SU_STDERR=1 LD_PRELOAD="./src/.libs/libstackusage.so" gedit
4445

4546
Example using libstackusage (system installed) with ls and logging
46-
output at process stop to syslog:
47+
output to syslog:
4748

4849
SU_SYSLOG=1 LD_PRELOAD="/usr/lib/libstackusage.so" ls
4950

50-
Example using libstackusage (without system install) with suctest application
51-
logging output at process stop to stderr and syslog:
51+
Example using libstackusage (without system install) with sutest01 application
52+
logging output to stderr and syslog:
53+
54+
SU_STDERR=1 SU_SYSLOG=1 LD_PRELOAD="./src/.libs/libstackusage.so" ./test/sutest01
55+
56+
OS X
57+
----
58+
59+
General usage syntax:
60+
61+
[SU_STDERR=1] [SU_SYSLOG=1] DYLD_INSERT_LIBRARIES="/path/to/libstackusage.1.dylib" DYLD_FORCE_FLAT_NAMESPACE=1 <application>
62+
63+
Example using libstackusage (without system install) with sutest01 application
64+
logging output to stderr and syslog:
65+
66+
SU_STDERR=1 SU_SYSLOG=1 DYLD_INSERT_LIBRARIES="./src/.libs/libstackusage.1.dylib" DYLD_FORCE_FLAT_NAMESPACE=1 ./test/sutest01
5267

53-
SU_STDERR=1 SU_SYSLOG=1 LD_PRELOAD="./src/.libs/libstackusage.so" ./test/suctest
54-
5568
Output
5669
======
5770
Example output:
5871

59-
$ SU_STDERR=1 LD_PRELOAD="./src/.libs/libstackusage.so" ./test/suctest
60-
libstackusage pid tid requested actual maxuse max% dur funcP
61-
libstackusage 3830 0 8388608 8384512 34584 0 0 (nil)
62-
libstackusage 3830 1 16384 16384 11496 70 0 0x4009d0
63-
libstackusage 3830 2 16384 16384 13560 82 0 0x4009d0
64-
libstackusage 3830 3 32768 32768 28552 87 0 0x4009d0
72+
$ SU_STDERR=1 LD_PRELOAD="./src/.libs/libstackusage.so" ./test/sutest01
73+
libstackusage log start -------------------------------------------------
74+
pid id tid requested actual maxuse max% dur funcP
75+
23930 0 23930 8388608 8384512 4144 0 0 (nil)
76+
23930 1 23931 16384 16384 9336 56 0 0x4009b0
77+
23930 2 23932 20480 20480 13528 66 0 0x4009b0
78+
23930 3 23933 24576 24576 16728 68 0 0x4009b0
79+
23930 4 23934 32768 32768 24920 76 0 0x4009b0
80+
23930 5 23935 49152 49152 41304 84 0 0x4009b0
81+
libstackusage log end ---------------------------------------------------
6582

6683
Description of columns:
6784

6885
pid process id
69-
tid thread id (0 = main thread, 1 = first child thread, etc..)
86+
id id (0 = main thread, 1 = first child thread, etc..)
87+
tid thread id / tid (only supported on Linux, others show '0')
7088
requested requested stack size in bytes
71-
actual actual available stack size in bytes (excl. any stack guard)
89+
actual actual stack size in bytes (excl. any stack guard)
7290
maxuse maximum stack usage in bytes
7391
max% maximum use of requested stack size in percentage
7492
dur thread duration in seconds
7593
funcP (nil) for main, pointer to start_routine for child threads
7694

7795
The function that funcP points to can be determined for example using addr2line:
7896

79-
$ addr2line -f -e ./test/suctest 0x4009d0
97+
$ addr2line -f -e ./test/sutest01 0x4009b0
8098
thread_start
81-
./test/suctest.c:76
99+
./test/sutest01.c:101
82100

83101
Design Notes
84102
============
85103
libstackusage intercepts calls to pthread_create and fills the thread
86104
stack with a dummy data pattern. It also registers a callback routine to be
87105
called upon thread termination. For main thread stack it utilizes
88-
__constructor__ and __destructor__ routines.
106+
constructor and destructor routines.
89107

90108
Limitations
91109
===========
92110
Logging to stderr upon process termination may not work for all applications.
93111
Certain applications, like coreutils ls, etc, are closing stdout/stderr before
94-
library __destructor__ is called. For such applications it is recommended to
112+
library destructor is called. For such applications it is recommended to
95113
use syslog logging.
96114

97115
License
@@ -100,5 +118,5 @@ libstackusage is distributed under BSD 3-Clause license. See LICENSE file.
100118

101119
Keywords
102120
========
103-
pthreads, linux, threads, stack usage, stack utilization.
121+
linux, os x, pthreads, stack usage, stack utilization, threads.
104122

0 commit comments

Comments
 (0)