From 89db89af082d4035ebf5821d6574e3c564df343b Mon Sep 17 00:00:00 2001 From: guanglei Date: Mon, 23 Oct 2006 09:50:57 +0000 Subject: [PATCH] New man page for lket-b2a Document signal trace hooks into lket man page bugfix of lket-b2a for event description data insert --- ChangeLog | 6 + Makefile.am | 2 +- Makefile.in | 26 ++-- configure | 3 +- configure.ac | 2 +- lket-b2a.1.in | 257 ++++++++++++++++++++++++++++++++++++ lket.5.in | 98 +++++++++++++- runtime/ChangeLog | 4 + runtime/lket/b2a/lket_b2a.c | 16 ++- 9 files changed, 394 insertions(+), 20 deletions(-) create mode 100644 lket-b2a.1.in diff --git a/ChangeLog b/ChangeLog index 298360ba0..958ca0c28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-10-23 Li Guanglei + * configure.ac, Makefile.am: add lket-b2a.1.in + * Makefile.in, configure: regenreated + * ket-b2a.1.in: new man page for lket-b2a + * lket.5.in: document signal trace hooks + 2006-10-18 Roland McGrath PR 2727 diff --git a/Makefile.am b/Makefile.am index 9231dce33..1ab030711 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,7 +11,7 @@ AM_CFLAGS = -std=gnu99 -D_GNU_SOURCE -fexceptions \ -Wall -Werror -Wshadow -Wunused -Wformat=2 -W AM_CXXFLAGS = -Wall -dist_man_MANS = stap.1 stapprobes.5 stapfuncs.5 stapex.5 lket.5 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.tcp.5 man/stapprobes.udp.5 +dist_man_MANS = stap.1 stapprobes.5 stapfuncs.5 stapex.5 lket.5 lket-b2a.1 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.tcp.5 man/stapprobes.udp.5 bin_PROGRAMS = stap staprun stap_SOURCES = main.cxx \ parse.cxx staptree.cxx elaborate.cxx translate.cxx \ diff --git a/Makefile.in b/Makefile.in index 84bfbb08c..d55a83694 100644 --- a/Makefile.in +++ b/Makefile.in @@ -49,10 +49,11 @@ noinst_PROGRAMS = loc2c-test$(EXEEXT) subdir = . DIST_COMMON = README $(am__configure_deps) $(dist_man_MANS) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(srcdir)/config.in $(srcdir)/lket.5.in $(srcdir)/stap.1.in \ - $(srcdir)/stapex.5.in $(srcdir)/stapfuncs.5.in \ - $(srcdir)/stapprobes.5.in $(srcdir)/stp_check.in \ - $(srcdir)/systemtap.spec.in $(top_srcdir)/configure \ + $(srcdir)/config.in $(srcdir)/lket-b2a.1.in \ + $(srcdir)/lket.5.in $(srcdir)/stap.1.in $(srcdir)/stapex.5.in \ + $(srcdir)/stapfuncs.5.in $(srcdir)/stapprobes.5.in \ + $(srcdir)/stp_check.in $(srcdir)/systemtap.spec.in \ + $(top_srcdir)/configure \ $(top_srcdir)/man/stapprobes.iosched.5.in \ $(top_srcdir)/man/stapprobes.netdev.5.in \ $(top_srcdir)/man/stapprobes.nfs.5.in \ @@ -74,12 +75,13 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = systemtap.spec stp_check stap.1 stapprobes.5 \ - stapfuncs.5 stapex.5 lket.5 man/stapprobes.iosched.5 \ - man/stapprobes.netdev.5 man/stapprobes.nfs.5 \ - man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 \ - man/stapprobes.process.5 man/stapprobes.rpc.5 \ - man/stapprobes.scsi.5 man/stapprobes.signal.5 \ - man/stapprobes.tcp.5 man/stapprobes.udp.5 + stapfuncs.5 stapex.5 lket.5 lket-b2a.1 \ + man/stapprobes.iosched.5 man/stapprobes.netdev.5 \ + man/stapprobes.nfs.5 man/stapprobes.nfsd.5 \ + man/stapprobes.pagefault.5 man/stapprobes.process.5 \ + man/stapprobes.rpc.5 man/stapprobes.scsi.5 \ + man/stapprobes.signal.5 man/stapprobes.tcp.5 \ + man/stapprobes.udp.5 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkglibexecdir)" \ "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man5dir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) @@ -242,7 +244,7 @@ AM_CFLAGS = -std=gnu99 -D_GNU_SOURCE -fexceptions \ -Wall -Werror -Wshadow -Wunused -Wformat=2 -W AM_CXXFLAGS = -Wall -dist_man_MANS = stap.1 stapprobes.5 stapfuncs.5 stapex.5 lket.5 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.tcp.5 man/stapprobes.udp.5 +dist_man_MANS = stap.1 stapprobes.5 stapfuncs.5 stapex.5 lket.5 lket-b2a.1 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.tcp.5 man/stapprobes.udp.5 stap_SOURCES = main.cxx \ parse.cxx staptree.cxx elaborate.cxx translate.cxx \ tapsets.cxx buildrun.cxx loc2c.c @@ -342,6 +344,8 @@ stapex.5: $(top_builddir)/config.status $(srcdir)/stapex.5.in cd $(top_builddir) && $(SHELL) ./config.status $@ lket.5: $(top_builddir)/config.status $(srcdir)/lket.5.in cd $(top_builddir) && $(SHELL) ./config.status $@ +lket-b2a.1: $(top_builddir)/config.status $(srcdir)/lket-b2a.1.in + cd $(top_builddir) && $(SHELL) ./config.status $@ man/stapprobes.iosched.5: $(top_builddir)/config.status $(top_srcdir)/man/stapprobes.iosched.5.in cd $(top_builddir) && $(SHELL) ./config.status $@ man/stapprobes.netdev.5: $(top_builddir)/config.status $(top_srcdir)/man/stapprobes.netdev.5.in diff --git a/configure b/configure index ee4839475..d4f6602cd 100755 --- a/configure +++ b/configure @@ -5878,7 +5878,7 @@ DATE="$date" ac_config_headers="$ac_config_headers config.h:config.in" - ac_config_files="$ac_config_files Makefile systemtap.spec stp_check stap.1 stapprobes.5 stapfuncs.5 stapex.5 lket.5 runtime/lket/b2a/Makefile testsuite/Makefile man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.tcp.5 man/stapprobes.udp.5" + ac_config_files="$ac_config_files Makefile systemtap.spec stp_check stap.1 stapprobes.5 stapfuncs.5 stapex.5 lket.5 lket-b2a.1 runtime/lket/b2a/Makefile testsuite/Makefile man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.tcp.5 man/stapprobes.udp.5" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -6486,6 +6486,7 @@ do "stapfuncs.5" ) CONFIG_FILES="$CONFIG_FILES stapfuncs.5" ;; "stapex.5" ) CONFIG_FILES="$CONFIG_FILES stapex.5" ;; "lket.5" ) CONFIG_FILES="$CONFIG_FILES lket.5" ;; + "lket-b2a.1" ) CONFIG_FILES="$CONFIG_FILES lket-b2a.1" ;; "runtime/lket/b2a/Makefile" ) CONFIG_FILES="$CONFIG_FILES runtime/lket/b2a/Makefile" ;; "testsuite/Makefile" ) CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;; "man/stapprobes.iosched.5" ) CONFIG_FILES="$CONFIG_FILES man/stapprobes.iosched.5" ;; diff --git a/configure.ac b/configure.ac index 6e0238d12..658ebe7c5 100644 --- a/configure.ac +++ b/configure.ac @@ -115,7 +115,7 @@ AC_DEFINE_UNQUOTED(DATE, "$date", [Configuration/build date]) AC_SUBST(DATE, "$date") AC_CONFIG_HEADERS([config.h:config.in]) -AC_CONFIG_FILES(Makefile systemtap.spec stp_check stap.1 stapprobes.5 stapfuncs.5 stapex.5 lket.5 runtime/lket/b2a/Makefile testsuite/Makefile man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.tcp.5 man/stapprobes.udp.5) +AC_CONFIG_FILES(Makefile systemtap.spec stp_check stap.1 stapprobes.5 stapfuncs.5 stapex.5 lket.5 lket-b2a.1 runtime/lket/b2a/Makefile testsuite/Makefile man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.tcp.5 man/stapprobes.udp.5) AC_OUTPUT if test $build_elfutils = yes; then diff --git a/lket-b2a.1.in b/lket-b2a.1.in new file mode 100644 index 000000000..753d8348a --- /dev/null +++ b/lket-b2a.1.in @@ -0,0 +1,257 @@ +.\" -*- nroff -*- +.TH LKET-B2A 1 @DATE@ "IBM" +.SH NAME +lket-b2a \- Converting and dumping utility for LKET binary trace data + +.\" macros +.de SAMPLE +.br +.RS +.nf +.nh +.. +.de ESAMPLE +.hy +.fi +.RE +.. + +.SH SYNOPSIS + +.br +.B lket-b2a +.I OPTIONS +.IR IN_FILENAME ... +.br + +.SH DESCRIPTION + +The trace data generated by +.I LKET +is in binary format by default for +better performance and smaller size. +.I lket-b2a +is used to convert the +binary trace data into readable data in ascii format and save +them into local file or MySQL database for off-line trace analysis. +It uses the per-cpu binary trace data files (stpd_cpu*) as inputs. +You can use "stap -bM" with LKET to get those per-cpu files before using it. + +The database used by +.I lket-b2a +is MySQL. So MySQL must be properly installed +and configured in order to make +.I lket-b2a +able to dump the trace data into MySQL database. + +.SH OPTIONS +.I lket-b2a +supports the following two options. They can be used +together or alone but at least one of them should be specified: + +.TP +.B \-m +convert and dump trace data into MySQL database. For more details, +See the following section. +.TP +.B \-f +convert and dump trace data into local file. For more details, +See the following section. + +.SH DUMP TRACE DATA INTO LOCAL FILE + +The generated output file is named +.IR lket.out . +The following is an example: + +.SAMPLE +root:/home/root/data> lket-b2a -f stpd_cpu* +root:/home/root/data> cat lket.out +LKET Magic: 0xAEFCDB6B +InitHdrLen: 9 +Version Major: 1 +Version Minor: 1 +Big endian: YES +Timing method: do_gettimeofday() +Bits width: 64 +Initial CPU timebase: 187994 (cycles per microsecond) + +0.2084 APPNAME: (null) PID:20922 CPU:3 HOOKGRP:3 HOOKID:1 tid:20936,pid:20936,ppid:35,pname:systemtap/0, +0.2086 APPNAME: (null) PID:20922 CPU:3 HOOKGRP:3 HOOKID:1 tid:20937,pid:20937,ppid:35,pname:systemtap/1, +0.2087 APPNAME: (null) PID:20922 CPU:3 HOOKGRP:3 HOOKID:1 tid:20938,pid:20938,ppid:35,pname:systemtap/2, +[...] +10.24319 APPNAME: sshd PID:7203 CPU:3 HOOKGRP:2 HOOKID:2 syscall:write, +10.24324 APPNAME: sshd PID:7203 CPU:3 HOOKGRP:2 HOOKID:1 syscall:compat_sys_select, +[...] +.ESAMPLE + +.SH DUMP TRACE DATA INTO MYSQL DATABASE + +To avoid either reading the complete trace data into internal data +structures to process, or filter through the raw trace data again +and again to calculate the interesting metrics, +.I lket-b2a +supports convert and save the binary trace data into MySQL database to +facilitate the query and calculation on the trace data. + +.I lket-b2a +creates the database name based on current time. And +.I lket-b2a +will not only save the trace data, but also some meta data into MySQL +database too, such as trace header, trace table description. + +The following is an example of navigating the trace data in MySQL database +created by +.IR lket-b2a : + +Use +.I lket-b2a +to convert and dump the binary trace data of +.I LKET +into MySQL database: + +.SAMPLE +root:/home/root/data> lket-b2a -m stpd_cpu* +.ESAMPLE + +list all databases in MySQL: + +.SAMPLE +mysql> show databases; ++------------------+ +| Database | ++------------------+ +| DB20061023161626 | +| mysql | +| test | ++------------------+ +3 rows in set (0.00 sec) +.ESAMPLE + +DB20061023161626 is the newly created database by "lket-b2a -m stpd_cpu*". We can list +all the tables contained in DB20061023161626: + +.SAMPLE +mysql> use DB20061023161626 +Database changed +mysql> show tables; ++----------------------------+ +| Tables_in_DB20061023161626 | ++----------------------------+ +| 2_1 | +| 2_2 | +| 3_1 | +| 3_3 | +| 3_5 | +| 4_1 | +| 4_3 | +| 4_4 | +| 8_1 | +| 8_3 | +| appNameMap | +| table_desc | +| trace_header | ++----------------------------+ +13 rows in set (0.00 sec) +.ESAMPLE + +The table trace_header is used to store the trace header info: + +.SAMPLE +mysql> select * from trace_header; ++-----------+-----------+------------+-----------------+------------+ +| Major_Ver | Minor_Ver | Big_Endian | Timing_Method | Bits_Width | ++-----------+-----------+------------+-----------------+------------+ +| 1 | 1 | 2 | do_gettimeofday | 64 | ++-----------+-----------+------------+-----------------+------------+ +1 row in set (0.00 sec) +.ESAMPLE + +The table appNameMap is used to store the mapping between PID and process name: + +.SAMPLE +mysql> select * from appNameMap; ++-------+-----------------+ +| pid | pname | ++-------+-----------------+ +| 10764 | systemtap/0 | +| 10765 | systemtap/1 | +| 10766 | systemtap/2 | +| 10767 | systemtap/3 | +| 10768 | systemtap/4 | +| 10769 | systemtap/5 | +| 10770 | systemtap/6 | +| 10771 | systemtap/7 | +| 0 | swapper | +| 1 | init | +| 2 | migration/0 | +| 3 | ksoftirqd/0 | +| 4 | watchdog/0 | +| 5 | migration/1 | +[...] +.ESAMPLE + +Each event corresponds to one table which is named as groupid_hookid. For example +table 8_1 corresponds to +.I addevent.netdev.receive +whose groupid is 8 and hookid is 1: + +.SAMPLE +mysql> select * from table_desc; ++------------+----------------------------------+ +| table_name | table_desc | ++------------+----------------------------------+ +| 2_1 | addevent.syscall.entry | +| 2_2 | addevent.syscall.return | +| 3_1 | process_snapshot | +| 3_3 | addevent.process.execve | +| 3_5 | addevent.process.fork | +| 4_3 | addevent.ioscheduler.elv_next_re | +| 4_4 | addevent.ioscheduler.elv_next_re | +| 4_1 | addevent.ioscheduler.elv_add_req | +| 8_1 | addevent.netdev.receive | +| 8_3 | addevent.netdev.transmit | ++------------+----------------------------------+ +10 rows in set (0.00 sec) +.ESAMPLE + +The hookid of a return type event( +.I addevent.*.return +) should be an +even number and its value should be the corresponding entry event hookid +1. +For example, the hookid of addevent.syscall.return is 2 and the hookid of +addevent.syscall.entry is 1. And what's more, there will be a new column +named +.I entry_usec +for all return type event tables which is the timestamp +of the entry of that event. The column +.I entry_usec +is created and calculated by lket-b2a on the fly while processing the binary trace data. + +.SAMPLE +mysql> select * from 2_1 limit 4; ++---------+--------+--------+------------+--------+--------------+ +| groupid | hookid | usec | process_id | cpu_id | syscall | ++---------+--------+--------+------------+--------+--------------+ +| 2 | 1 | 10727 | 20922 | 2 | read | +| 2 | 1 | 10746 | 20922 | 2 | read | +| 2 | 1 | 729066 | 3605 | 5 | gettimeofday | +| 2 | 1 | 729086 | 3605 | 5 | gettimeofday | ++---------+--------+--------+------------+--------+--------------+ +4 rows in set (0.00 sec) + +mysql> select * from 2_2 limit 4; ++---------+--------+--------+------------+--------+------------+--------------+ +| groupid | hookid | usec | process_id | cpu_id | entry_usec | syscall | ++---------+--------+--------+------------+--------+------------+--------------+ +| 2 | 2 | 10742 | 20922 | 2 | 10727 | read | +| 2 | 2 | 729072 | 3605 | 5 | 729066 | gettimeofday | +| 2 | 2 | 729089 | 3605 | 5 | 729086 | gettimeofday | +| 2 | 2 | 729100 | 3605 | 5 | 729096 | poll | ++---------+--------+--------+------------+--------+------------+--------------+ +4 rows in set (0.00 sec) +.ESAMPLE + +.SH SEE ALSO +.IR stap (1), +.IR lket (5) diff --git a/lket.5.in b/lket.5.in index 19ee87e60..117202297 100644 --- a/lket.5.in +++ b/lket.5.in @@ -45,7 +45,7 @@ The data common(i.e. in the following subsecions) to all event hooks is: .RS -.B usec(INT64),(tid<<32 | groupID<<24 | hookID<<16 | cpu_id<<8)(INT64) +.B timestamp(INT64),(tid<<32 | groupID<<24 | hookID<<16 | cpu_id<<8)(INT64) .RE Each event hook group is a collection of those hooks that have @@ -127,6 +127,102 @@ Data format is: .I common_data, pid(INT32), new_process_name(STRING) +.SS SIGNAL +You could use +.I addevent.signal +to trace signal activities. It contains the following events: +.P +.TP +.B addevent.signal.send.entry +Trace when a signal is sent to a process + +Data format is: +.I common_data, sig(INT8), shared(INT8), send2queue(INT8), pid(INT32) +.TP +.B addevent.signal.send.return +Trace when returning from sending signal + +Data format is: +.I common_data, return(INT8) +.TP +.B addevent.signal.syskill.entry +Trace when sys_kill is called to send a signal to a process. + +Data format is: +.I common_data, pid(INT32), sig(INT8) +.TP +.B addevent.signal.syskill.return +Trace when return from sys_kill + +Data format is: +.I common_data, return(INT8) +.TP +.B addevent.signal.systgkill.entry +Trace when sys_tgkill is called to send a signal to one specific thread + +Data format is: +.I common_data, tid(INT32), pid(INT32), sig(INT8) +.TP +.B addevent.signal.systgkill.return +Trace when returning from sys_tgkill + +Data format is: +.I common_data, return(INT8) +.TP +.B addevent.signal.systkill.entry +Trace when sys_tkill is called to send a signal to a single process. + +Data format is: +.I common_data, pid(INT32), sig(INT8) +.TP +.B addevent.signal.systkill.return +Trace when returning from sys_tkill. + +Data format is: +.I common_data, return(INT8) +.TP +.B addevent.signal.pending.entry +Trace when examine the set of signals that are pending for delivery. + +Data format is: +.I common_data, sigset_addr(INT32), setsize(INT32) +.TP +.B addevent.signal.pending.return +Trace when returning from signal.pending + +Data format is: +.I common_data, return(INT8) +.TP +.B addevent.signal.do_action.entry +Trace when a thread is about to examine and change a signal action + +Data format is: +.I common_data, sig(INT8), handler(INT64) +.TP +.B addevent.signal.do_action.return +Trace when returning from signal.do_action + +Data format is: +.I common_data, return(INT8) +.TP +.B addevent.signal.procmask.entry +Trace when a thread is about to examine and change blocked signals + +Data format is: +.I common_data, how(INT8), sigset(INT64) +.TP +.B addevent.signal.procmask.return +Trace when returning from signal.procmask + +Data format is +.I common_data, return(INT8) +.TP +.B addevent.signal.flush.entry +Trace when flush all pending signals for a task + +Data format is: +.I common_data, pid(INT32) + .SS IO SCHEDULER ACTIVITIES You could use .I addevent.ioscheduler diff --git a/runtime/ChangeLog b/runtime/ChangeLog index ea57a8742..1b6ffcf0e 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,7 @@ +2006-10-23 Li Guanglei + * runtime/lket/b2a/lket_b2a.c: bugfix of event description + data insert. + 2006-10-12 Martin Hunt * stack-ppc64.c (__stp_stack_sprint): Declare sp before _sp. diff --git a/runtime/lket/b2a/lket_b2a.c b/runtime/lket/b2a/lket_b2a.c index eb4c2fc6c..a5f4e457f 100644 --- a/runtime/lket/b2a/lket_b2a.c +++ b/runtime/lket/b2a/lket_b2a.c @@ -654,12 +654,18 @@ void register_evt_desc(FILE *infp, size_t size) if(!has_table) { snprintf(sql, 1024, "create table table_desc ( table_name \ varchar(6), table_desc varchar(32))"); + if(mysql_query(&mysql, sql)) { + fprintf(stderr, "Failed exec SQL: \n %s \n, Error: %s\n", + sql, mysql_error(&mysql)); + exit(-1); + } has_table = 1; - } else { - snprintf(sql, 1024, "insert into table_desc ( table_name,\ - table_desc) values ( \"%d_%d\", \"%s\")", grpid, hookid, - evt_body+2); - } + } + + snprintf(sql, 1024, "insert into table_desc ( table_name,\ + table_desc) values ( \"%d_%d\", \"%s\")", grpid, hookid, + evt_body+2); + if(mysql_query(&mysql, sql)) { fprintf(stderr, "Failed exec SQL: \n %s \n, Error: %s\n", sql, mysql_error(&mysql)); -- 2.43.5