From e25a872fe19d5428945e4a4a9b655d66f0321b27 Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Thu, 12 Aug 2010 12:10:08 -0400 Subject: [PATCH] PR 11369, due to performance issues stap_merge.c is being shipped instead of a .tcl script. stap-merge.1 man page was added to document the command. --- Makefile.am | 10 ++-- runtime/staprun/stap_merge.c | 8 +-- stap-merge.1 | 100 +++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 stap-merge.1 diff --git a/Makefile.am b/Makefile.am index 7128d5f48..980b88bce 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,18 +13,18 @@ AM_CFLAGS = -D_GNU_SOURCE -fexceptions -Wall -Werror -Wunused -Wformat=2 -W AM_CXXFLAGS = -Wall -Werror man_MANS = stapprobes.3stap stapfuncs.3stap stapvars.3stap stapex.3stap \ -dtrace.1 \ +dtrace.1 stap-merge.1\ stappaths.7 \ staprun.8 -bin_PROGRAMS = staprun +bin_PROGRAMS = staprun stap-merge bin_SCRIPTS = stap-report pkglibexec_PROGRAMS = stapio pkglibexec_SCRIPTS = stap-env oldinclude_HEADERS = includes/sys/sdt.h if BUILD_TRANSLATOR -bin_PROGRAMS += stap +bin_PROGRAMS += stap man_MANS += stap.1 bin_SCRIPTS += dtrace @@ -182,6 +182,10 @@ stapio_CFLAGS = $(AM_CFLAGS) @PIECFLAGS@ -fno-strict-aliasing -fno-builtin-strft stapio_LDFLAGS = $(AM_LDFLAGS) @PIELDFLAGS@ stapio_LDADD = -lpthread +stap_merge_SOURCES = runtime/staprun/stap_merge.c +stap_merge_CFLAGS = $(AM_CFLAGS) @PIECFLAGS@ +stap_merge_LDFLAGS = $(AM_LDFLAGS) @PIECFLAGS@ +stap_merge_LDADD = install-exec-hook: if [ `id -u` -eq 0 ]; then chmod 04111 "$(DESTDIR)$(bindir)/staprun"; fi diff --git a/runtime/staprun/stap_merge.c b/runtime/staprun/stap_merge.c index fb8a17c1d..5c0d32f0d 100644 --- a/runtime/staprun/stap_merge.c +++ b/runtime/staprun/stap_merge.c @@ -105,19 +105,19 @@ int main (int argc, char *argv[]) if (verbose) fprintf(stdout, "[CPU:%d, seq=%ld, length=%d]\n", j, min, len); if (len > bufsize) { - bufsize = len * 2; + bufsize = len; if (verbose) fprintf(stderr, "reallocating %d bytes\n", bufsize); buf = realloc(buf, bufsize); if (buf == NULL) { - fprintf(stderr, "Memory allocation failed.\n"); + fprintf(stderr, "Memory allocation failed.\n"); exit(-2); } } - if ((rc = fread(buf, len, 1, fp[j]) <= 0)) { + if ((rc = fread(buf, len, 1, fp[j])) <= 0 ) { fprintf(stderr, "fread error: got %d\n", rc); exit(-3); } - if ((rc = fwrite(buf, len, 1, ofp)) <= 0) { + if ((rc = fwrite(buf, len, 1, ofp)) <= 0 ) { fprintf(stderr, "fread error: got %d\n", rc); exit(-3); } diff --git a/stap-merge.1 b/stap-merge.1 new file mode 100644 index 000000000..d4b2a35df --- /dev/null +++ b/stap-merge.1 @@ -0,0 +1,100 @@ +.\" -*- nroff -*- +.TH STAP-MERGE 1 +.SH NAME +stap\-merge \- systemtap per-cpu binary merger + +.\" macros +.de SAMPLE +.br +.RS +.nf +.nh +.. +.de ESAMPLE +.hy +.fi +.RE +.. + +.SH SYNOPSIS + +.br +.B stap-merge +[ +.I OPTIONS +] +[ +.I INPUT FILENAMES +] + +.SH DESCRIPTION + +The stap-merge executable applies when the \-b option has been used +while running a +.IR stap +script. The \-b option will generate files +per\-cpu, based on the timestamp field. Stap-merge will +then merge and sort through the per\-cpu files based on the timestamp +field. + +.SH OPTIONS + +The systemtap merge executable supports the following options. +.TP +.B \-v +Verbose mode, displays three extra fields per set of collected data. +.SAMPLE +.BR [cpu number, sequence number of data, the length of the data set] +.ESAMPLE +.TP +.BI \-o " OUTPUT_FILENAME" + +Specify the name of the file you would like the output to be +redirected into. If this option is not specified than the +output will be pushed to standard out. + +.SH EXAMPLES +.SAMPLE +$ stap -v -b -e 'probe syscall.open { printf("%s(%d) open\\n", +execname(), pid()) }' + +.ESAMPLE + +This should result in several +.I stpd_cpu +files (each labled with a number +representing which cpu the file was produced from). + +.SAMPLE +$ stap-merge -v stpd_cpu0 stpd_cpu1 + +.ESAMPLE + +Running the stap-merge program in the same directory as the stap +script earlier in the example, will produce an ordered sequence of +packets with the three part label for each set of data. This +result will be pushed through the standard output. An output file +could have been specified using the "-o" option. + +.SH FILES + +.TP +Important files and their corresponding paths can be located in the +stappaths (7) manual page. + +.SH SEE ALSO +.IR stapprobes (3stap), +.IR stapfuncs (3stap), +.IR stappaths (7), +.IR staprun (8), +.IR stapvars (3stap), +.IR stapex (3stap), +.IR stap-client (8), +.IR stap-server (8), +.IR gdb (1) + +.SH BUGS +Use the Bugzilla link of the project web page or our mailing list. +.nh +.BR http://sources.redhat.com/systemtap/ , . +.hy -- 2.43.5