initial move
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Sat, 11 Mar 2006 17:33:10 +0000 (17:33 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Sat, 11 Mar 2006 17:33:10 +0000 (17:33 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1685 04897980-b3bd-0310-b5e0-8ef037075253

31 files changed:
ltt-control/AUTHORS [new file with mode: 0644]
ltt-control/Makefile.am [new file with mode: 0644]
ltt-control/README [new file with mode: 0644]
ltt-control/configure.in [new file with mode: 0644]
ltt-control/facilities/Makefile.am [new file with mode: 0644]
ltt-control/facilities/core.xml [new file with mode: 0644]
ltt-control/facilities/fs.xml [new file with mode: 0644]
ltt-control/facilities/ipc.xml [new file with mode: 0644]
ltt-control/facilities/kernel.xml [new file with mode: 0644]
ltt-control/facilities/kernel_arch_arm.xml [new file with mode: 0644]
ltt-control/facilities/kernel_arch_i386.xml [new file with mode: 0644]
ltt-control/facilities/kernel_arch_mips.xml [new file with mode: 0644]
ltt-control/facilities/locking.xml [new file with mode: 0644]
ltt-control/facilities/memory.xml [new file with mode: 0644]
ltt-control/facilities/network.xml [new file with mode: 0644]
ltt-control/facilities/network_ip_interface.xml [new file with mode: 0644]
ltt-control/facilities/process.xml [new file with mode: 0644]
ltt-control/facilities/socket.xml [new file with mode: 0644]
ltt-control/facilities/stack_arch_i386.xml [new file with mode: 0644]
ltt-control/facilities/statedump.xml [new file with mode: 0644]
ltt-control/facilities/timer.xml [new file with mode: 0644]
ltt-control/facilities/user_generic.xml [new file with mode: 0644]
ltt-control/liblttctl/Makefile.am [new file with mode: 0644]
ltt-control/liblttctl/liblttctl.c [new file with mode: 0644]
ltt-control/liblttctl/lttctl.h [new file with mode: 0644]
ltt-control/lttctl/Makefile.am [new file with mode: 0644]
ltt-control/lttctl/lttctl.c [new file with mode: 0644]
ltt-control/lttd/Makefile.am [new file with mode: 0644]
ltt-control/lttd/lttd.c [new file with mode: 0644]
ltt/branches/poly/lttd/Makefile.am [deleted file]
ltt/branches/poly/lttd/lttd.c [deleted file]

diff --git a/ltt-control/AUTHORS b/ltt-control/AUTHORS
new file mode 100644 (file)
index 0000000..032edf0
--- /dev/null
@@ -0,0 +1,25 @@
+Linux Trace Toolkit Viewer
+
+Contributors :
+
+Michel Dagenais (New trace format, lttv main)
+Mathieu Desnoyers (Kernel Tracer, Directory structure, build with automake/conf,
+                   lttv gui, control flow view, gui cooperative trace reading
+                   scheduler with interruptible foreground and background
+                   computation, detailed event list (rewrite), trace reading
+                   library (rewrite))
+Benoit Des Ligneris, Éric Clement (Cluster adaptation, work in progress)
+Xang-Xiu Yang (trace reading library and converter, lttv gui, 
+               detailed event list and statistics view)
+Tom Zanussi (RelayFS)
+
+Strongly inspired from the original Linux Trace Toolkit Visualizer made by
+Karim Yaghmour.
+
+Linux Trace Toolkit Viewer, Copyright (C) 2004
+                                                Michel Dagenais
+                                                Mathieu Desnoyers
+                                                Xang-Xiu Yang
+Linux Trace Toolkit comes with ABSOLUTELY NO WARRANTY.
+This is free software, and you are welcome to redistribute it
+under certain conditions. See COPYING for details.
diff --git a/ltt-control/Makefile.am b/ltt-control/Makefile.am
new file mode 100644 (file)
index 0000000..66afa90
--- /dev/null
@@ -0,0 +1,6 @@
+# WARNING : ltt must come before lttv, so that the traceread library is
+# up to date
+
+SUBDIRS = liblttctl ltt lttctl lttv lttd doc facilities
+
+EXTRA_DIST = QUICKSTART
diff --git a/ltt-control/README b/ltt-control/README
new file mode 100644 (file)
index 0000000..836472a
--- /dev/null
@@ -0,0 +1,77 @@
+
+This package contains the trace reading library and trace viewing tools for
+the new Linux Trace Toolkit trace format. It also contains the lttd, lttctl and
+liblttctl programs which are necessary to obtain a trace.
+
+* Compiling
+
+gcc 3.2 or better
+gtk 2.4 or better development libraries
+  (Debian : libgtk2.0, libgtk2.0-dev)
+  (Fedora : gtk2, gtk2-devel)
+  note : For Fedora users : this might require at least core 3 from Fedora,
+  or you might have to compile your own GTK2 library.
+glib 2.4 or better development libraries
+  (Debian : libglib2.0-0, libglib2.0-dev)
+  (Fedora : glib2, glib2-devel)
+libpopt development libraries
+  (Debian : libpopt0, libpopt-dev)
+  (Fedora : popt)
+libpango development libraries
+  (Debian : libpango1.0, libpango1.0-dev)
+  (Fedora : pango, pango-devel)
+libc6 development librairies 
+  (Debian : libc6, libc6-dev)
+  (Fedora : glibc, glibc)
+
+
+To compile the source tree from a tarball, simply follow these steps :
+
+- ./configure
+- make
+- make install
+
+After running ./configure, you can also go in specific subdirectories and
+use make, make install.
+
+
+* Quick Start
+
+See QUICKSTART
+
+* Source Tree Structure
+
+Here is the tree structure of the Linux Trace Toolkit Viewer package.
+
+ltt: new trace format reading library.
+README: This file.
+debian: debian config files (currently empty).
+doc:    Documentation.
+doc/user:      User related documentation.
+doc/developer: Developer related documentation.
+liblttctl:    Library to communicate with the kernel tracer control module.
+lttctl:       Command line program to use the liblttctl library.
+lttd:   Linux Trace Toolkit daemon.
+lttv:   Linux Trace Toolkit trace analysis tool and viewer.
+lttv/modules:  Linux Trace Toolkit analysis tool and viewer plugin modules.
+specs:  RPM config files (currently empty).
+
+
+* For Developers
+
+This source tree is based on the autotools suite from GNU to simplify
+portability. Here are some things you should have on your system in order to
+compile the subversion repository tree :
+
+
+GNU autotools (automake-1,7, autoconf2.50, autoheader2.50)
+(make sure your system wide "automake" points to version 1.7!)
+GNU Libtool
+(for more information, go to http://www.gnu.org/software/autoconf/)
+
+If you get the tree from the repository, you will need to use the autogen.sh
+script. It calls all the GNU tools needed to prepare the tree configuration.
+
+
+
+Mathieu Desnoyers 
diff --git a/ltt-control/configure.in b/ltt-control/configure.in
new file mode 100644 (file)
index 0000000..b9b8c83
--- /dev/null
@@ -0,0 +1,144 @@
+# This file is part of the Linux Trace Toolkit viewer
+# Copyright (C) 2003-2004 Mathieu Desnoyers
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License Version 2 as
+# published by the Free Software Foundation;
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, 
+# MA 02111-1307, USA.
+
+
+
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.57)
+AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
+#AC_WITH_LTDL  # not needed ?
+AM_INIT_AUTOMAKE(LinuxTraceToolkitViewer,0.8.31-11032006)
+AM_CONFIG_HEADER(config.h)
+AM_PROG_LIBTOOL
+
+AM_PATH_GLIB_2_0(2.4.0, ,AC_MSG_ERROR([glib is required in order to compile LinuxTraceToolkit - download it from ftp://ftp.gtk.org/pub/gtk]) , gmodule)
+
+AM_PATH_GTK_2_0(2.4.0, ,AC_MSG_ERROR([gtk is required in order to compile GUI - download it from ftp://ftp.gtk.org/pub/gtk]) , gmodule)
+
+AC_PATH_PROGS(BASH, bash)
+
+AC_SYS_LARGEFILE
+
+# Checks for programs.
+AC_PROG_CC
+
+# Checks for libraries.
+AC_CHECK_LIB([popt], [poptGetNextOpt], POPT_LIBS="-lpopt",AC_MSG_ERROR([libpopt is required in order to compile LinuxTraceToolkit])  )
+#AC_CHECK_LIB([m], [round], M_LIBS="-lm",AC_MSG_ERROR([Mathematical libraries are missing.])  )
+
+AC_CHECK_LIB([util], [forkpty], UTIL_LIBS="-lutil", AC_MSG_ERROR([libutil is
+required in order to compile LinuxTraceToolkit]))
+
+
+# pthread for lttd
+AC_CHECK_LIB(pthread, pthread_join,[THREAD_LIBS="-lpthread"], AC_MSG_ERROR([LinuxThreads is required in order to compile lttd]))
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h pthread.h])
+
+AC_ISC_POSIX
+AC_PROG_CC
+AM_PROG_CC_STDC
+AC_HEADER_STDC
+
+pkg_modules="gtk+-2.0 >= 2.0.0"
+PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
+PACKAGE_CFLAGS="-Wall -Wformat"
+AC_SUBST(PACKAGE_CFLAGS)
+AC_SUBST(PACKAGE_LIBS)
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_HEADER_STDBOOL
+AC_C_CONST
+AC_C_INLINE
+AC_TYPE_OFF_T
+AC_TYPE_SIZE_T
+AC_HEADER_TIME
+
+# Checks for library functions.
+AC_FUNC_ERROR_AT_LINE
+#AC_FUNC_MALLOC
+AC_FUNC_SELECT_ARGTYPES
+AC_CHECK_FUNCS([select])
+
+#CPPFLAGS="$CPPFLAGS -I"
+
+AM_CONDITIONAL(LTTVSTATIC, test "$enable_lttvstatic" = yes)
+lttvlibdir="${libdir}/lttv"
+lttvplugindir="${lttvlibdir}/plugins"
+#lttlibdir="${libdir}/ltt"
+top_lttvdir="\$(top_srcdir)/lttv"
+top_lttvwindowdir="\$(top_srcdir)/lttv/modules/gui/lttvwindow"
+
+DEFAULT_INCLUDES="-I\$(top_srcdir) -I\$(top_lttvdir) -I\$(top_lttvwindowdir)"
+
+#CPPFLAGS="${GLIB_CFLAGS}"
+#AC_SUBST(CPPFLAGS)
+
+lttincludedir="${includedir}/ltt"
+lttvincludedir="${includedir}/lttv"
+lttvwindowincludedir="${includedir}/lttvwindow"
+lttctlincludedir="${includedir}/liblttctl"
+
+AC_SUBST(POPT_LIBS)
+AC_SUBST(UTIL_LIBS)
+AC_SUBST(THREAD_LIBS)
+AC_SUBST(lttvlibdir)
+AC_SUBST(lttvplugindir)
+#AC_SUBST(lttlibdir)
+AC_SUBST(top_lttvdir)
+AC_SUBST(top_lttvwindowdir)
+AC_SUBST(DEFAULT_INCLUDES)
+AC_SUBST(lttincludedir)
+AC_SUBST(lttvincludedir)
+AC_SUBST(lttvwindowincludedir)
+AC_SUBST(lttctlincludedir)
+
+AC_CONFIG_FILES([Makefile
+     liblttctl/Makefile
+     lttctl/Makefile
+                lttv/Makefile
+                lttv/lttv/Makefile
+                lttv/modules/Makefile
+                lttv/modules/text/Makefile
+                lttv/modules/gui/Makefile
+                lttv/modules/gui/lttvwindow/Makefile
+                lttv/modules/gui/interrupts/Makefile
+                lttv/modules/gui/diskperformance/Makefile
+                lttv/modules/gui/lttvwindow/lttvwindow/Makefile
+                lttv/modules/gui/lttvwindow/pixmaps/Makefile
+                lttv/modules/gui/controlflow/Makefile
+                lttv/modules/gui/detailedevents/Makefile
+                lttv/modules/gui/statistics/Makefile
+     lttv/modules/gui/filter/Makefile
+     lttv/modules/gui/tracecontrol/Makefile
+                lttd/Makefile
+                ltt/Makefile
+     doc/Makefile
+     doc/developer/Makefile
+     doc/developer/developer_guide/Makefile
+     doc/developer/developer_guide/docbook/Makefile
+     doc/developer/developer_guide/html/Makefile
+     doc/user/Makefile
+     doc/user/user_guide/Makefile
+     doc/user/user_guide/docbook/Makefile
+     doc/user/user_guide/html/Makefile
+     facilities/Makefile])
+AC_OUTPUT
diff --git a/ltt-control/facilities/Makefile.am b/ltt-control/facilities/Makefile.am
new file mode 100644 (file)
index 0000000..6e87ebd
--- /dev/null
@@ -0,0 +1,41 @@
+
+EXTRA_DIST =  \
+core.xml \
+fs.xml \
+ipc.xml \
+kernel.xml \
+kernel_arch_arm.xml \
+kernel_arch_i386.xml \
+kernel_arch_mips.xml \
+stack_arch_i386.xml \
+locking.xml \
+memory.xml \
+network.xml \
+process.xml \
+socket.xml \
+statedump.xml \
+timer.xml \
+user_generic.xml \
+network_ip_interface.xml
+
+facilities_DATA = \
+core.xml \
+fs.xml \
+ipc.xml \
+kernel.xml \
+kernel_arch_arm.xml \
+kernel_arch_i386.xml \
+kernel_arch_mips.xml \
+stack_arch_i386.xml \
+locking.xml \
+memory.xml \
+network.xml \
+process.xml \
+socket.xml \
+statedump.xml \
+timer.xml \
+user_generic.xml \
+network_ip_interface.xml
+
+
+facilitiesdir = $(pkgdatadir)/facilities
diff --git a/ltt-control/facilities/core.xml b/ltt-control/facilities/core.xml
new file mode 100644 (file)
index 0000000..796ffc5
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<facility name="core">
+  <description>The core facility contains the basic tracing related events</description>
+       
+  <event name="facility_load">
+    <description>Facility is loaded</description>
+               <field name="name"><string></field>
+               <field name="checksum"><uint size="4"></field>
+               <field name="id"><uint size="4"></field>
+               <field name="int_size"><uint size="4"></field>
+               <field name="long_size"><uint size="4"></field>
+               <field name="pointer_size"><uint size="4"></field>
+               <field name="size_t_size"><uint size="4"></field>
+               <field name="has_alignment"><uint size="4"></field>
+  </event>
+
+  <event name="facility_unload">
+    <description>Facility is unloaded</description>
+    <field name="id"><uint size="4"></field>
+  </event>
+
+  <event name="time_heartbeat" scope="tracefile">
+    <description>System time values sent periodically to detect cycle counter
+     rollovers. Useful when only the 32 LSB of the TSC are saved in events
+     header : we save the full 64 bits in this event.
+    </description>
+  </event>
+  
+  <event name="state_dump_facility_load" scope="trace">
+    <description>Facility is loaded while in state dump</description>
+               <field name="name"><string></field>
+               <field name="checksum"><uint size="4"></field>
+               <field name="id"><uint size="4"></field>
+               <field name="int_size"><uint size="4"></field>
+               <field name="long_size"><uint size="4"></field>
+               <field name="pointer_size"><uint size="4"></field>
+               <field name="size_t_size"><uint size="4"></field>
+               <field name="has_alignment"><uint size="4"></field>
+  </event>
+
+</facility>
diff --git a/ltt-control/facilities/fs.xml b/ltt-control/facilities/fs.xml
new file mode 100644 (file)
index 0000000..75668d9
--- /dev/null
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<facility name="fs">
+  <description>The fs facility contains events related to file system operation</description>
+
+  <event name="buf_wait_start">
+    <description>Staring to wait for a buffer</description>
+    <field name="address"> <description>Address of the buffer head.</description> <pointer> </field>
+  </event>
+
+  <event name="buf_wait_end">
+    <description>Ending to wait for a buffer</description>
+    <field name="address"> <description>Address of the buffer head.</description> <pointer> </field>
+  </event>
+
+  <event name="exec">
+    <description>Executing a file</description>
+    <field name="filename"> <description>File name</description>
+                       <sequence>
+                               <uint>
+                               <uchar>
+                       </sequence>
+               </field>
+  </event>
+
+  <event name="open">
+    <description>Opening a file</description>
+    <field name="filename"> <description>File name</description>
+                       <sequence>
+                               <uint>
+                               <uchar>
+                       </sequence>
+               </field>
+    <field name="fd"> <description>File descriptor</description> <uint size="4"> </field>
+  </event>
+
+  <event name="close">
+    <description>Closing a file descriptor</description>
+    <field name="fd"> <description>File descriptor</description> <uint size="4"> </field>
+  </event>
+
+  <event name="read">
+    <description>Reading from a file descriptor</description>
+    <field name="fd"> <description>File descriptor</description> <uint size="4"> </field>
+    <field name="count"> <description>Number of bytes to read</description> <size_t> </field>
+  </event>
+       
+  <event name="write">
+    <description>Write to a file descriptor</description>
+    <field name="fd"> <description>File descriptor</description> <uint size="4"> </field>
+    <field name="count"> <description>Number of bytes to write</description> <size_t> </field>
+  </event>
+
+  <event name="seek">
+    <description>Seek a file descriptor</description>
+    <field name="fd"> <description>File descriptor</description> <uint size="4"> </field>
+    <field name="offset"> <description>Number of bytes to write</description> <off_t> </field>
+    <field name="origin"> <description>Number of bytes to write</description> <uint size="4"> </field>
+  </event>
+
+  <event name="ioctl">
+    <description>Do a IOCTL on a file descriptor</description>
+    <field name="fd"> <description>File descriptor</description> <uint size="4"> </field>
+    <field name="cmd"> <description>Command</description> <uint size="4"> </field>
+    <field name="arg"> <description>Argument</description> <uint size="4"> </field>
+  </event>
+
+  <event name="select">
+    <description>Do a select on a file descriptor</description>
+    <field name="fd"> <description>File descriptor</description> <uint size="4"> </field>
+    <field name="timeout"> <description>Time out</description> <ulong> </field>
+  </event>
+
+  <event name="poll">
+    <description>Do a poll on a file descriptor</description>
+    <field name="fd"> <description>File descriptor</description> <uint size="4"> </field>
+  </event>
+
+</facility>
diff --git a/ltt-control/facilities/ipc.xml b/ltt-control/facilities/ipc.xml
new file mode 100644 (file)
index 0000000..b4f0ee9
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<facility name="ipc">
+  <description>The ipc facility contains events related to Inter Process Communication</description>
+       
+  <event name="call">
+
+    <description>IPC call</description>
+    <field name="call_number"> <description>Number of IPC call</description> <uint size="4"> </field>
+
+    <field name="first"> <description>First argument</description> <int size="4"> </field>
+  </event>
+
+  <event name="msg_create">
+    <description>Get an IPC message queue identifier</description>
+    <field name="id"> <description>Message queue identifier</description><long> </field>
+    <field name="flags"> <description>Message flags</description> <int size="4"> </field>
+  </event>
+
+  <event name="sem_create">
+    <description>Get an IPC semaphore identifier</description>
+    <field name="id"> <description>Semaphore identifier</description> <long> </field>
+    <field name="flags"> <description>Semaphore flags</description> <int size="4"> </field>
+  </event>
+
+  <event name="shm_create">
+    <description>Get an IPC shared memory identifier</description>
+    <field name="id"> <description>Shared memory identifier</description> <long> </field>
+    <field name="flags"> <description>Shared memory flags</description> <int size="4"> </field>
+  </event>
+
+</facility>
diff --git a/ltt-control/facilities/kernel.xml b/ltt-control/facilities/kernel.xml
new file mode 100644 (file)
index 0000000..66a5101
--- /dev/null
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<facility name="kernel">
+  <description>The kernel facility has events related to kernel execution status.</description>
+
+  <type name="tasklet_priority">
+    <enum>
+      <label name="LOW" value="0"> <description>Low priority tasklet</description>
+      <label name="HIGH" value="1"> <description>High priority tasklet</description>
+    </enum>
+  </type>
+
+  <type name="irq_mode">
+    <enum>
+      <label name="user" value="0"> <description>User context</description>
+      <label name="kernel" value="1"> <description>Kernel context</description>
+    </enum>
+  </type>
+
+  <event name="trap_entry">
+    <description>Entry in a trap</description>
+    <field name="trap_id"> <description>Trap number</description> <long> </field>
+    <field name="address"> <description>Address where trap occured</description> <pointer> </field>
+  </event>
+
+  <event name="trap_exit">
+    <description>Exit from a trap</description>
+  </event>
+
+  <event name="soft_irq_entry">
+    <description>Soft IRQ entry</description>
+    <field name="softirq_id"> <description>Soft IRQ number</description> <pointer> </field>
+  </event>
+
+  <event name="soft_irq_exit">
+    <description>Soft IRQ exit</description>
+    <field name="softirq_id"> <description>Soft IRQ number</description> <pointer> </field>
+  </event>
+
+  <event name="tasklet_entry">
+    <description>Tasklet entry</description>
+    <field name="priority"> <description>Tasklet priority</description> <typeref name="tasklet_priority"> </field>
+    <field name="address"> <description>Tasklet function address</description> <pointer> </field>
+    <field name="data"> <description>Tasklet data address</description> <ulong> </field>
+  </event>
+
+  <event name="tasklet_exit">
+    <description>Tasklet exit</description>
+    <field name="priority"> <description>Tasklet priority</description> <typeref name="tasklet_priority"> </field>
+    <field name="address"> <description>Tasklet function address</description> <pointer> </field>
+    <field name="data"> <description>Tasklet data address</description> <ulong> </field>
+  </event>
+
+  <event name="irq_entry">
+    <description>Entry in an irq</description>
+    <field name="irq_id"> <description>IRQ number</description> <uint size="4"> </field>
+    <field name="mode"> <description>Are we executing kernel code</description><typeref name="irq_mode"> </field>
+  </event>
+
+  <event name="irq_exit">
+    <description>Exit from an IRQ</description>
+  </event>
+
+</facility>
diff --git a/ltt-control/facilities/kernel_arch_arm.xml b/ltt-control/facilities/kernel_arch_arm.xml
new file mode 100644 (file)
index 0000000..981924d
--- /dev/null
@@ -0,0 +1,319 @@
+<?xml version="1.0"?>
+<facility name="kernel_arch" arch="arm">
+  <description>The kernel facility has events related to kernel execution status for the arm architecture.</description>
+  <type name="syscall_name">
+    <enum>
+                       <label name="restart_syscall" value="0">
+                       <label name="exit" value="1">
+                       <label name="fork" value="2">
+                       <label name="read" value="3">
+                       <label name="write" value="4">
+                       <label name="open" value="5">
+                       <label name="close" value="6">
+                       <label name="waitpid" value="7">
+                       <label name="creat" value="8">
+                       <label name="link" value="9">
+                       <label name="unlink" value="10">
+                       <label name="execve" value="11">
+                       <label name="chdir" value="12">
+                       <label name="time" value="13">
+                       <label name="mknod" value="14">
+                       <label name="chmod" value="15">
+                       <label name="lchown" value="16">
+                       <label name="break" value="17">
+                       <label name="oldstat" value="18">
+                       <label name="lseek" value="19">
+                       <label name="getpid" value="20">
+                       <label name="mount" value="21">
+                       <label name="umount" value="22">
+                       <label name="setuid" value="23">
+                       <label name="getuid" value="24">
+                       <label name="stime" value="25">
+                       <label name="ptrace" value="26">
+                       <label name="alarm" value="27">
+                       <label name="oldfstat" value="28">
+                       <label name="pause" value="29">
+                       <label name="utime" value="30">
+                       <label name="stty" value="31">
+                       <label name="gtty" value="32">
+                       <label name="access" value="33">
+                       <label name="nice" value="34">
+                       <label name="ftime" value="35">
+                       <label name="sync" value="36">
+                       <label name="kill" value="37">
+                       <label name="rename" value="38">
+                       <label name="mkdir" value="39">
+                       <label name="rmdir" value="40">
+                       <label name="dup" value="41">
+                       <label name="pipe" value="42">
+                       <label name="times" value="43">
+                       <label name="prof" value="44">
+                       <label name="brk" value="45">
+                       <label name="setgid" value="46">
+                       <label name="getgid" value="47">
+                       <label name="signal" value="48">
+                       <label name="geteuid" value="49">
+                       <label name="getegid" value="50">
+                       <label name="acct" value="51">
+                       <label name="umount2" value="52">
+                       <label name="lock" value="53">
+                       <label name="ioctl" value="54">
+                       <label name="fcntl" value="55">
+                       <label name="mpx" value="56">
+                       <label name="setpgid" value="57">
+                       <label name="ulimit" value="58">
+                       <label name="oldolduname" value="59">
+                       <label name="umask" value="60">
+                       <label name="chroot" value="61">
+                       <label name="ustat" value="62">
+                       <label name="dup2" value="63">
+                       <label name="getppid" value="64">
+                       <label name="getpgrp" value="65">
+                       <label name="setsid" value="66">
+                       <label name="sigaction" value="67">
+                       <label name="sgetmask" value="68">
+                       <label name="ssetmask" value="69">
+                       <label name="setreuid" value="70">
+                       <label name="setregid" value="71">
+                       <label name="sigsuspend" value="72">
+                       <label name="sigpending" value="73">
+                       <label name="sethostname" value="74">
+                       <label name="setrlimit" value="75">
+                       <label name="getrlimit" value="76">
+                       <label name="getrusage" value="77">
+                       <label name="gettimeofday" value="78">
+                       <label name="settimeofday" value="79">
+                       <label name="getgroups" value="80">
+                       <label name="setgroups" value="81">
+                       <label name="select" value="82">
+                       <label name="symlink" value="83">
+                       <label name="oldlstat" value="84">
+                       <label name="readlink" value="85">
+                       <label name="uselib" value="86">
+                       <label name="swapon" value="87">
+                       <label name="reboot" value="88">
+                       <label name="readdir" value="89">
+                       <label name="mmap" value="90">
+                       <label name="munmap" value="91">
+                       <label name="truncate" value="92">
+                       <label name="ftruncate" value="93">
+                       <label name="fchmod" value="94">
+                       <label name="fchown" value="95">
+                       <label name="getpriority" value="96">
+                       <label name="setpriority" value="97">
+                       <label name="profil" value="98">
+                       <label name="statfs" value="99">
+                       <label name="fstatfs" value="100">
+                       <label name="ioperm" value="101">
+                       <label name="socketcall" value="102">
+                       <label name="syslog" value="103">
+                       <label name="setitimer" value="104">
+                       <label name="getitimer" value="105">
+                       <label name="stat" value="106">
+                       <label name="lstat" value="107">
+                       <label name="fstat" value="108">
+                       <label name="olduname" value="109">
+                       <label name="iopl" value="110">
+                       <label name="vhangup" value="111">
+                       <label name="idle" value="112">
+                       <label name="vm86old" value="113">
+                       <label name="wait4" value="114">
+                       <label name="swapoff" value="115">
+                       <label name="sysinfo" value="116">
+                       <label name="ipc" value="117">
+                       <label name="fsync" value="118">
+                       <label name="sigreturn" value="119">
+                       <label name="clone" value="120">
+                       <label name="setdomainname" value="121">
+                       <label name="uname" value="122">
+                       <label name="modify_ldt" value="123">
+                       <label name="adjtimex" value="124">
+                       <label name="mprotect" value="125">
+                       <label name="sigprocmask" value="126">
+                       <label name="create_module" value="127">
+                       <label name="init_module" value="128">
+                       <label name="delete_module" value="129">
+                       <label name="get_kernel_syms" value="130">
+                       <label name="quotactl" value="131">
+                       <label name="getpgid" value="132">
+                       <label name="fchdir" value="133">
+                       <label name="bdflush" value="134">
+                       <label name="sysfs" value="135">
+                       <label name="personality" value="136">
+                       <label name="afs_syscall" value="137">
+                       <label name="setfsuid" value="138">
+                       <label name="setfsgid" value="139">
+                       <label name="_llseek" value="140">
+                       <label name="getdents" value="141">
+                       <label name="_newselect" value="142">
+                       <label name="flock" value="143">
+                       <label name="msync" value="144">
+                       <label name="readv" value="145">
+                       <label name="writev" value="146">
+                       <label name="getsid" value="147">
+                       <label name="fdatasync" value="148">
+                       <label name="_sysctl" value="149">
+                       <label name="mlock" value="150">
+                       <label name="munlock" value="151">
+                       <label name="mlockall" value="152">
+                       <label name="munlockall" value="153">
+                       <label name="sched_setparam" value="154">
+                       <label name="sched_getparam" value="155">
+                       <label name="sched_setscheduler" value="156">
+                       <label name="sched_getscheduler" value="157">
+                       <label name="sched_yield" value="158">
+                       <label name="sched_get_priority_max" value="159">
+                       <label name="sched_get_priority_min" value="160">
+                       <label name="sched_rr_get_interval" value="161">
+                       <label name="nanosleep" value="162">
+                       <label name="mremap" value="163">
+                       <label name="setresuid" value="164">
+                       <label name="getresuid" value="165">
+                       <label name="vm86" value="166">
+                       <label name="query_module" value="167">
+                       <label name="poll" value="168">
+                       <label name="nfsservctl" value="169">
+                       <label name="setresgid" value="170">
+                       <label name="getresgid" value="171">
+                       <label name="prctl" value="172">
+                       <label name="rt_sigreturn" value="173">
+                       <label name="rt_sigaction" value="174">
+                       <label name="rt_sigprocmask" value="175">
+                       <label name="rt_sigpending" value="176">
+                       <label name="rt_sigtimedwait" value="177">
+                       <label name="rt_sigqueueinfo" value="178">
+                       <label name="rt_sigsuspend" value="179">
+                       <label name="pread64" value="180">
+                       <label name="pwrite64" value="181">
+                       <label name="chown" value="182">
+                       <label name="getcwd" value="183">
+                       <label name="capget" value="184">
+                       <label name="capset" value="185">
+                       <label name="sigaltstack" value="186">
+                       <label name="sendfile" value="187">
+                       <label name="reserved1" value="188">
+                       <label name="reserved2" value="189">
+                       <label name="vfork" value="190">
+                       <label name="ugetrlimit" value="191">
+                       <label name="mmap2" value="192">
+                       <label name="truncate64" value="193">
+                       <label name="ftruncate64" value="194">
+                       <label name="stat64" value="195">
+                       <label name="lstat64" value="196">
+                       <label name="fstat64" value="197">
+                       <label name="lchown32" value="198">
+                       <label name="getuid32" value="199">
+                       <label name="getgid32" value="200">
+                       <label name="geteuid32" value="201">
+                       <label name="getegid32" value="202">
+                       <label name="setreuid32" value="203">
+                       <label name="setregid32" value="204">
+                       <label name="getgroups32" value="205">
+                       <label name="setgroups32" value="206">
+                       <label name="fchown32" value="207">
+                       <label name="setresuid32" value="208">
+                       <label name="getresuid32" value="209">
+                       <label name="setresgid32" value="210">
+                       <label name="getresgid32" value="211">
+                       <label name="chown32" value="212">
+                       <label name="setuid32" value="213">
+                       <label name="setgid32" value="214">
+                       <label name="setfsuid32" value="215">
+                       <label name="setfsgid32" value="216">
+                       <label name="getdents64" value="217">
+                       <label name="pivot_root" value="218">
+                       <label name="mincore" value="219">
+                       <label name="madvise" value="220">
+                       <label name="fcntl64" value="221">
+                       <label name="tux" value="222">
+                       <label name="unsued" value="223">
+                       <label name="gettid" value="224">
+                       <label name="readahead" value="225">
+                       <label name="setxattr" value="226">
+                       <label name="lsetxattr" value="227">
+                       <label name="fsetxattr" value="228">
+                       <label name="getxattr" value="229">
+                       <label name="lgetxattr" value="230">
+                       <label name="fgetxattr" value="231">
+                       <label name="listxattr" value="232">
+                       <label name="llistxattr" value="233">
+                       <label name="flistxattr" value="234">
+                       <label name="removexattr" value="235">
+                       <label name="lremovexattr" value="236">
+                       <label name="fremovexattr" value="237">
+                       <label name="tkill" value="238">
+                       <label name="sendfile64" value="239">
+                       <label name="futex" value="240">
+                       <label name="sched_setaffinity" value="241">
+                       <label name="sched_getaffinity" value="242">
+                       <label name="io_setup" value="243">
+                       <label name="io_destroy" value="244">
+                       <label name="io_getevents" value="245">
+                       <label name="io_submit" value="246">
+                       <label name="io_cancel" value="247">
+                       <label name="exit_group" value="248">
+                       <label name="lookup_dcookie" value="249">
+                       <label name="epoll_create" value="250">
+                       <label name="epoll_ctl" value="251">
+                       <label name="epoll_wait" value="252">
+                       <label name="remap_file_pages" value="253">
+                       <label name="set_thread_area" value="254">
+                       <label name="get_thread_area" value="255">
+                       <label name="set_tid_address" value="256">
+                       <label name="timer_create" value="257">
+                       <label name="timer_settime" value="258">
+                       <label name="timer_gettime" value="259">
+                       <label name="timer_getoverrun" value="260">
+                       <label name="timer_delete" value="261">
+                       <label name="clock_settime" value="262">
+                       <label name="clock_gettime" value="263">
+                       <label name="clock_getres" value="264">
+                       <label name="clock_nanosleep" value="265">
+                       <label name="statfs64" value="266">
+                       <label name="fstatfs64" value="267">
+                       <label name="tgkill" value="268">
+                       <label name="utimes" value="269">
+                       <label name="arm_fadvise64_64" value="270">
+                       <label name="pciconfig_iobase" value="271">
+                       <label name="pciconfig_read" value="272">
+                       <label name="pciconfig_write" value="273">
+                       <label name="mq_open" value="274">
+                       <label name="mq_unlink" value="275">
+                       <label name="mq_timedsend" value="276">
+                       <label name="mq_timedreceive" value="277">
+                       <label name="mq_notify" value="278">
+                       <label name="mq_getsetattr" value="279">
+                       <label name="waitid" value="280">
+
+                       <label name="add_key" value="309">
+                       <label name="request_key" value="310">
+                       <label name="keyctl" value="311">
+
+                       <label name="vserver" value="313">
+                       <label name="ioprio_set" value="314">
+                       <label name="ioprio_get" value="315">
+                       <label name="inotify_init" value="316">
+                       <label name="inotify_add_watch" value="317">
+                       <label name="inotify_rm_watch" value="318">
+                       <label name="mbind" value="319">
+                       <label name="get_mempolicy" value="320">
+                       <label name="set_mempolicy" value="321">
+                       <label name="arm_syscall_offset" value="1024">
+                       <label name="breakpoint" value="1025">
+                       <label name="cacheflush" value="1026">
+                       <label name="usr26" value="1027">
+                       <label name="usr32" value="1028">
+                       <label name="set_tls" value="1029">
+    </enum>
+  </type>
+
+  <event name="syscall_entry">
+    <description>System call entry</description>
+    <field name="syscall_id"> <description>Syscall entry number in entry.S</description> <typeref name="syscall_name"> </field>
+    <field name="address"> <description>Address from which call was made</description> <pointer> </field>
+  </event>
+       
+       <event name="syscall_exit">
+    <description>System call exit</description>
+  </event>
+</facility>
diff --git a/ltt-control/facilities/kernel_arch_i386.xml b/ltt-control/facilities/kernel_arch_i386.xml
new file mode 100644 (file)
index 0000000..ecab076
--- /dev/null
@@ -0,0 +1,312 @@
+<?xml version="1.0"?>
+<facility name="kernel_arch" arch="i386">
+  <description>The kernel facility has events related to kernel execution status for the i386 architecture.</description>
+  <type name="syscall_name">
+    <enum>
+                       <label name="restart_syscall" value="0">
+                       <label name="exit" value="1">
+                       <label name="fork" value="2">
+                       <label name="read" value="3">
+                       <label name="write" value="4">
+                       <label name="open" value="5">
+                       <label name="close" value="6">
+                       <label name="waitpid" value="7">
+                       <label name="creat" value="8">
+                       <label name="link" value="9">
+                       <label name="unlink" value="10">
+                       <label name="execve" value="11">
+                       <label name="chdir" value="12">
+                       <label name="time" value="13">
+                       <label name="mknod" value="14">
+                       <label name="chmod" value="15">
+                       <label name="lchown" value="16">
+                       <label name="break" value="17">
+                       <label name="oldstat" value="18">
+                       <label name="lseek" value="19">
+                       <label name="getpid" value="20">
+                       <label name="mount" value="21">
+                       <label name="umount" value="22">
+                       <label name="setuid" value="23">
+                       <label name="getuid" value="24">
+                       <label name="stime" value="25">
+                       <label name="ptrace" value="26">
+                       <label name="alarm" value="27">
+                       <label name="oldfstat" value="28">
+                       <label name="pause" value="29">
+                       <label name="utime" value="30">
+                       <label name="stty" value="31">
+                       <label name="gtty" value="32">
+                       <label name="access" value="33">
+                       <label name="nice" value="34">
+                       <label name="ftime" value="35">
+                       <label name="sync" value="36">
+                       <label name="kill" value="37">
+                       <label name="rename" value="38">
+                       <label name="mkdir" value="39">
+                       <label name="rmdir" value="40">
+                       <label name="dup" value="41">
+                       <label name="pipe" value="42">
+                       <label name="times" value="43">
+                       <label name="prof" value="44">
+                       <label name="brk" value="45">
+                       <label name="setgid" value="46">
+                       <label name="getgid" value="47">
+                       <label name="signal" value="48">
+                       <label name="geteuid" value="49">
+                       <label name="getegid" value="50">
+                       <label name="acct" value="51">
+                       <label name="umount2" value="52">
+                       <label name="lock" value="53">
+                       <label name="ioctl" value="54">
+                       <label name="fcntl" value="55">
+                       <label name="mpx" value="56">
+                       <label name="setpgid" value="57">
+                       <label name="ulimit" value="58">
+                       <label name="oldolduname" value="59">
+                       <label name="umask" value="60">
+                       <label name="chroot" value="61">
+                       <label name="ustat" value="62">
+                       <label name="dup2" value="63">
+                       <label name="getppid" value="64">
+                       <label name="getpgrp" value="65">
+                       <label name="setsid" value="66">
+                       <label name="sigaction" value="67">
+                       <label name="sgetmask" value="68">
+                       <label name="ssetmask" value="69">
+                       <label name="setreuid" value="70">
+                       <label name="setregid" value="71">
+                       <label name="sigsuspend" value="72">
+                       <label name="sigpending" value="73">
+                       <label name="sethostname" value="74">
+                       <label name="setrlimit" value="75">
+                       <label name="getrlimit" value="76">
+                       <label name="getrusage" value="77">
+                       <label name="gettimeofday" value="78">
+                       <label name="settimeofday" value="79">
+                       <label name="getgroups" value="80">
+                       <label name="setgroups" value="81">
+                       <label name="select" value="82">
+                       <label name="symlink" value="83">
+                       <label name="oldlstat" value="84">
+                       <label name="readlink" value="85">
+                       <label name="uselib" value="86">
+                       <label name="swapon" value="87">
+                       <label name="reboot" value="88">
+                       <label name="readdir" value="89">
+                       <label name="mmap" value="90">
+                       <label name="munmap" value="91">
+                       <label name="truncate" value="92">
+                       <label name="ftruncate" value="93">
+                       <label name="fchmod" value="94">
+                       <label name="fchown" value="95">
+                       <label name="getpriority" value="96">
+                       <label name="setpriority" value="97">
+                       <label name="profil" value="98">
+                       <label name="statfs" value="99">
+                       <label name="fstatfs" value="100">
+                       <label name="ioperm" value="101">
+                       <label name="socketcall" value="102">
+                       <label name="syslog" value="103">
+                       <label name="setitimer" value="104">
+                       <label name="getitimer" value="105">
+                       <label name="stat" value="106">
+                       <label name="lstat" value="107">
+                       <label name="fstat" value="108">
+                       <label name="olduname" value="109">
+                       <label name="iopl" value="110">
+                       <label name="vhangup" value="111">
+                       <label name="idle" value="112">
+                       <label name="vm86old" value="113">
+                       <label name="wait4" value="114">
+                       <label name="swapoff" value="115">
+                       <label name="sysinfo" value="116">
+                       <label name="ipc" value="117">
+                       <label name="fsync" value="118">
+                       <label name="sigreturn" value="119">
+                       <label name="clone" value="120">
+                       <label name="setdomainname" value="121">
+                       <label name="uname" value="122">
+                       <label name="modify_ldt" value="123">
+                       <label name="adjtimex" value="124">
+                       <label name="mprotect" value="125">
+                       <label name="sigprocmask" value="126">
+                       <label name="create_module" value="127">
+                       <label name="init_module" value="128">
+                       <label name="delete_module" value="129">
+                       <label name="get_kernel_syms" value="130">
+                       <label name="quotactl" value="131">
+                       <label name="getpgid" value="132">
+                       <label name="fchdir" value="133">
+                       <label name="bdflush" value="134">
+                       <label name="sysfs" value="135">
+                       <label name="personality" value="136">
+                       <label name="afs_syscall" value="137">
+                       <label name="setfsuid" value="138">
+                       <label name="setfsgid" value="139">
+                       <label name="_llseek" value="140">
+                       <label name="getdents" value="141">
+                       <label name="_newselect" value="142">
+                       <label name="flock" value="143">
+                       <label name="msync" value="144">
+                       <label name="readv" value="145">
+                       <label name="writev" value="146">
+                       <label name="getsid" value="147">
+                       <label name="fdatasync" value="148">
+                       <label name="_sysctl" value="149">
+                       <label name="mlock" value="150">
+                       <label name="munlock" value="151">
+                       <label name="mlockall" value="152">
+                       <label name="munlockall" value="153">
+                       <label name="sched_setparam" value="154">
+                       <label name="sched_getparam" value="155">
+                       <label name="sched_setscheduler" value="156">
+                       <label name="sched_getscheduler" value="157">
+                       <label name="sched_yield" value="158">
+                       <label name="sched_get_priority_max" value="159">
+                       <label name="sched_get_priority_min" value="160">
+                       <label name="sched_rr_get_interval" value="161">
+                       <label name="nanosleep" value="162">
+                       <label name="mremap" value="163">
+                       <label name="setresuid" value="164">
+                       <label name="getresuid" value="165">
+                       <label name="vm86" value="166">
+                       <label name="query_module" value="167">
+                       <label name="poll" value="168">
+                       <label name="nfsservctl" value="169">
+                       <label name="setresgid" value="170">
+                       <label name="getresgid" value="171">
+                       <label name="prctl" value="172">
+                       <label name="rt_sigreturn" value="173">
+                       <label name="rt_sigaction" value="174">
+                       <label name="rt_sigprocmask" value="175">
+                       <label name="rt_sigpending" value="176">
+                       <label name="rt_sigtimedwait" value="177">
+                       <label name="rt_sigqueueinfo" value="178">
+                       <label name="rt_sigsuspend" value="179">
+                       <label name="pread64" value="180">
+                       <label name="pwrite64" value="181">
+                       <label name="chown" value="182">
+                       <label name="getcwd" value="183">
+                       <label name="capget" value="184">
+                       <label name="capset" value="185">
+                       <label name="sigaltstack" value="186">
+                       <label name="sendfile" value="187">
+                       <label name="getpmsg" value="188">
+                       <label name="putpmsg" value="189">
+                       <label name="vfork" value="190">
+                       <label name="ugetrlimit" value="191">
+                       <label name="mmap2" value="192">
+                       <label name="truncate64" value="193">
+                       <label name="ftruncate64" value="194">
+                       <label name="stat64" value="195">
+                       <label name="lstat64" value="196">
+                       <label name="fstat64" value="197">
+                       <label name="lchown32" value="198">
+                       <label name="getuid32" value="199">
+                       <label name="getgid32" value="200">
+                       <label name="geteuid32" value="201">
+                       <label name="getegid32" value="202">
+                       <label name="setreuid32" value="203">
+                       <label name="setregid32" value="204">
+                       <label name="getgroups32" value="205">
+                       <label name="setgroups32" value="206">
+                       <label name="fchown32" value="207">
+                       <label name="setresuid32" value="208">
+                       <label name="getresuid32" value="209">
+                       <label name="setresgid32" value="210">
+                       <label name="getresgid32" value="211">
+                       <label name="chown32" value="212">
+                       <label name="setuid32" value="213">
+                       <label name="setgid32" value="214">
+                       <label name="setfsuid32" value="215">
+                       <label name="setfsgid32" value="216">
+                       <label name="pivot_root" value="217">
+                       <label name="mincore" value="218">
+                       <label name="madvise" value="219">
+                       <label name="madvise1" value="219">
+                       <label name="getdents64" value="220">
+                       <label name="fcntl64" value="221">
+                       <label name="gettid" value="224">
+                       <label name="readahead" value="225">
+                       <label name="setxattr" value="226">
+                       <label name="lsetxattr" value="227">
+                       <label name="fsetxattr" value="228">
+                       <label name="getxattr" value="229">
+                       <label name="lgetxattr" value="230">
+                       <label name="fgetxattr" value="231">
+                       <label name="listxattr" value="232">
+                       <label name="llistxattr" value="233">
+                       <label name="flistxattr" value="234">
+                       <label name="removexattr" value="235">
+                       <label name="lremovexattr" value="236">
+                       <label name="fremovexattr" value="237">
+                       <label name="tkill" value="238">
+                       <label name="sendfile64" value="239">
+                       <label name="futex" value="240">
+                       <label name="sched_setaffinity" value="241">
+                       <label name="sched_getaffinity" value="242">
+                       <label name="set_thread_area" value="243">
+                       <label name="get_thread_area" value="244">
+                       <label name="io_setup" value="245">
+                       <label name="io_destroy" value="246">
+                       <label name="io_getevents" value="247">
+                       <label name="io_submit" value="248">
+                       <label name="io_cancel" value="249">
+                       <label name="fadvise64" value="250">
+                       <label name="set_zone_reclaim" value="251">
+                       <label name="exit_group" value="252">
+                       <label name="lookup_dcookie" value="253">
+                       <label name="epoll_create" value="254">
+                       <label name="epoll_ctl" value="255">
+                       <label name="epoll_wait" value="256">
+                       <label name="remap_file_pages" value="257">
+                       <label name="set_tid_address" value="258">
+                       <label name="timer_create" value="259">
+                       <label name="timer_settime" value="260">
+                       <label name="timer_gettime">
+                       <label name="timer_getoverrun">
+                       <label name="timer_delete">
+                       <label name="clock_settime">
+                       <label name="clock_gettime">
+                       <label name="clock_getres">
+                       <label name="clock_nanosleep">
+                       <label name="statfs64" value="268">
+                       <label name="fstatfs64" value="269">
+                       <label name="tgkill" value="270">
+                       <label name="utimes" value="271">
+                       <label name="fadvise64_64" value="272">
+                       <label name="vserver" value="273">
+                       <label name="mbind" value="274">
+                       <label name="get_mempolicy" value="275">
+                       <label name="set_mempolicy" value="276">
+                       <label name="mq_open" value="277">
+                       <label name="mq_unlink">
+                       <label name="mq_timedsend">
+                       <label name="mq_timedreceive">
+                       <label name="mq_notify">
+                       <label name="mq_getsetattr">
+                       <label name="sys_kexec_load" value="283">
+                       <label name="waitid" value="284">
+                       <label name="add_key" value="286">
+                       <label name="request_key" value="287">
+                       <label name="keyctl" value="288">
+                       <label name="ioprio_set" value="289">
+                       <label name="ioprio_get" value="290">
+                       <label name="inotify_init" value="291">
+                       <label name="inotify_add_watch" value="292">
+                       <label name="inotify_rm_watch" value="293">
+                       <label name="ltt_trace_generic" value="294">
+                       <label name="ltt_register_generic" value="295">
+    </enum>
+  </type>
+
+  <event name="syscall_entry">
+    <description>System call entry</description>
+    <field name="syscall_id"> <description>Syscall entry number in entry.S</description> <typeref name="syscall_name"> </field>
+    <field name="address"> <description>Address from which call was made</description> <pointer> </field>
+  </event>
+       
+       <event name="syscall_exit">
+    <description>System call exit</description>
+  </event>
+</facility>
diff --git a/ltt-control/facilities/kernel_arch_mips.xml b/ltt-control/facilities/kernel_arch_mips.xml
new file mode 100644 (file)
index 0000000..d2dc54a
--- /dev/null
@@ -0,0 +1,808 @@
+<?xml version="1.0"?>
+<facility name="kernel_arch" arch="mips">
+  <description>The kernel facility has events related to kernel execution status
+       for the MIPS architecture.</description>
+  <type name=syscall_name>
+    <enum>
+                       <label name="o32_base" value="3999"><description>Linux o32 style syscalls</description>
+                       <label name="o32_syscall" value="4000">
+                       <label name="o32_exit" value="4001">
+                       <label name="o32_fork" value="4002">
+                       <label name="o32_read" value="4003">
+                       <label name="o32_write" value="4004">
+                       <label name="o32_open" value="4005">
+                       <label name="o32_close" value="4006">
+                       <label name="o32_waitpid" value="4007">
+                       <label name="o32_creat" value="4008">
+                       <label name="o32_link" value="4009">
+                       <label name="o32_unlink" value="4010">
+                       <label name="o32_execve" value="4011">
+                       <label name="o32_chdir" value="4012">
+                       <label name="o32_time" value="4013">
+                       <label name="o32_mknod" value="4014">
+                       <label name="o32_chmod" value="4015">
+                       <label name="o32_lchown" value="4016">
+                       <label name="o32_break" value="4017">
+                       <label name="o32_unused18" value="4018">
+                       <label name="o32_lseek" value="4019">
+                       <label name="o32_getpid" value="4020">
+                       <label name="o32_mount" value="4021">
+                       <label name="o32_umount" value="4022">
+                       <label name="o32_setuid" value="4023">
+                       <label name="o32_getuid" value="4024">
+                       <label name="o32_stime" value="4025">
+                       <label name="o32_ptrace" value="4026">
+                       <label name="o32_alarm" value="4027">
+                       <label name="o32_unused28" value="4028">
+                       <label name="o32_pause" value="4029">
+                       <label name="o32_utime" value="4030">
+                       <label name="o32_stty" value="4031">
+                       <label name="o32_gtty" value="4032">
+                       <label name="o32_access" value="4033">
+                       <label name="o32_nice" value="4034">
+                       <label name="o32_ftime" value="4035">
+                       <label name="o32_sync" value="4036">
+                       <label name="o32_kill" value="4037">
+                       <label name="o32_rename" value="4038">
+                       <label name="o32_mkdir" value="4039">
+                       <label name="o32_rmdir" value="4040">
+                       <label name="o32_dup" value="4041">
+                       <label name="o32_pipe" value="4042">
+                       <label name="o32_times" value="4043">
+                       <label name="o32_prof" value="4044">
+                       <label name="o32_brk" value="4045">
+                       <label name="o32_setgid" value="4046">
+                       <label name="o32_getgid" value="4047">
+                       <label name="o32_signal" value="4048">
+                       <label name="o32_geteuid" value="4049">
+                       <label name="o32_getegid" value="4050">
+                       <label name="o32_acct" value="4051">
+                       <label name="o32_umount2" value="4052">
+                       <label name="o32_lock" value="4053">
+                       <label name="o32_ioctl" value="4054">
+                       <label name="o32_fcntl" value="4055">
+                       <label name="o32_mpx" value="4056">
+                       <label name="o32_setpgid" value="4057">
+                       <label name="o32_ulimit" value="4058">
+                       <label name="o32_unused59" value="4059">
+                       <label name="o32_umask" value="4060">
+                       <label name="o32_chroot" value="4061">
+                       <label name="o32_ustat" value="4062">
+                       <label name="o32_dup2" value="4063">
+                       <label name="o32_getppid" value="4064">
+                       <label name="o32_getpgrp" value="4065">
+                       <label name="o32_setsid" value="4066">
+                       <label name="o32_sigaction" value="4067">
+                       <label name="o32_sgetmask" value="4068">
+                       <label name="o32_ssetmask" value="4069">
+                       <label name="o32_setreuid" value="4070">
+                       <label name="o32_setregid" value="4071">
+                       <label name="o32_sigsuspend" value="4072">
+                       <label name="o32_sigpending" value="4073">
+                       <label name="o32_sethostname" value="4074">
+                       <label name="o32_setrlimit" value="4075">
+                       <label name="o32_getrlimit" value="4076">
+                       <label name="o32_getrusage" value="4077">
+                       <label name="o32_gettimeofday" value="4078">
+                       <label name="o32_settimeofday" value="4079">
+                       <label name="o32_getgroups" value="4080">
+                       <label name="o32_setgroups" value="4081">
+                       <label name="o32_reserved82" value="4082">
+                       <label name="o32_symlink" value="4083">
+                       <label name="o32_unused84" value="4084">
+                       <label name="o32_readlink" value="4085">
+                       <label name="o32_uselib" value="4086">
+                       <label name="o32_swapon" value="4087">
+                       <label name="o32_reboot" value="4088">
+                       <label name="o32_readdir" value="4089">
+                       <label name="o32_mmap" value="4090">
+                       <label name="o32_munmap" value="4091">
+                       <label name="o32_truncate" value="4092">
+                       <label name="o32_ftruncate" value="4093">
+                       <label name="o32_fchmod" value="4094">
+                       <label name="o32_fchown" value="4095">
+                       <label name="o32_getpriority" value="4096">
+                       <label name="o32_setpriority" value="4097">
+                       <label name="o32_profil" value="4098">
+                       <label name="o32_statfs" value="4099">
+                       <label name="o32_fstatfs" value="4100">
+                       <label name="o32_ioperm" value="4101">
+                       <label name="o32_socketcall" value="4102">
+                       <label name="o32_syslog" value="4103">
+                       <label name="o32_setitimer" value="4104">
+                       <label name="o32_getitimer" value="4105">
+                       <label name="o32_stat" value="4106">
+                       <label name="o32_lstat" value="4107">
+                       <label name="o32_fstat" value="4108">
+                       <label name="o32_unused109" value="4109">
+                       <label name="o32_iopl" value="4110">
+                       <label name="o32_vhangup" value="4111">
+                       <label name="o32_idle" value="4112">
+                       <label name="o32_vm86" value="4113">
+                       <label name="o32_wait4" value="4114">
+                       <label name="o32_swapoff" value="4115">
+                       <label name="o32_sysinfo" value="4116">
+                       <label name="o32_ipc" value="4117">
+                       <label name="o32_fsync" value="4118">
+                       <label name="o32_sigreturn" value="4119">
+                       <label name="o32_clone" value="4120">
+                       <label name="o32_setdomainname" value="4121">
+                       <label name="o32_uname" value="4122">
+                       <label name="o32_modify_ldt" value="4123">
+                       <label name="o32_adjtimex" value="4124">
+                       <label name="o32_mprotect" value="4125">
+                       <label name="o32_sigprocmask" value="4126">
+                       <label name="o32_create_module" value="4127">
+                       <label name="o32_init_module" value="4128">
+                       <label name="o32_delete_module" value="4129">
+                       <label name="o32_get_kernel_syms" value="4130">
+                       <label name="o32_quotactl" value="4131">
+                       <label name="o32_getpgid" value="4132">
+                       <label name="o32_fchdir" value="4133">
+                       <label name="o32_bdflush" value="4134">
+                       <label name="o32_sysfs" value="4135">
+                       <label name="o32_personality" value="4136">
+                       <label name="o32_afs_syscall" value="4137">
+                       <label name="o32_setfsuid" value="4138">
+                       <label name="o32_setfsgid" value="4139">
+                       <label name="o32__llseek" value="4140">
+                       <label name="o32_getdents" value="4141">
+                       <label name="o32__newselect" value="4142">
+                       <label name="o32_flock" value="4143">
+                       <label name="o32_msync" value="4144">
+                       <label name="o32_readv" value="4145">
+                       <label name="o32_writev" value="4146">
+                       <label name="o32_cacheflush" value="4147">
+                       <label name="o32_cachectl" value="4148">
+                       <label name="o32_sysmips" value="4149">
+                       <label name="o32_unused150" value="4150">
+                       <label name="o32_getsid" value="4151">
+                       <label name="o32_fdatasync" value="4152">
+                       <label name="o32__sysctl" value="4153">
+                       <label name="o32_mlock" value="4154">
+                       <label name="o32_munlock" value="4155">
+                       <label name="o32_mlockall" value="4156">
+                       <label name="o32_munlockall" value="4157">
+                       <label name="o32_sched_setparam" value="4158">
+                       <label name="o32_sched_getparam" value="4159">
+                       <label name="o32_sched_setscheduler" value="4160">
+                       <label name="o32_sched_getscheduler" value="4161">
+                       <label name="o32_sched_yield" value="4162">
+                       <label name="o32_sched_get_priority_max" value="4163">
+                       <label name="o32_sched_get_priority_min" value="4164">
+                       <label name="o32_sched_rr_get_interval" value="4165">
+                       <label name="o32_nanosleep" value="4166">
+                       <label name="o32_mremap" value="4167">
+                       <label name="o32_accept" value="4168">
+                       <label name="o32_bind" value="4169">
+                       <label name="o32_connect" value="4170">
+                       <label name="o32_getpeername" value="4171">
+                       <label name="o32_getsockname" value="4172">
+                       <label name="o32_getsockopt" value="4173">
+                       <label name="o32_listen" value="4174">
+                       <label name="o32_recv" value="4175">
+                       <label name="o32_recvfrom" value="4176">
+                       <label name="o32_recvmsg" value="4177">
+                       <label name="o32_send" value="4178">
+                       <label name="o32_sendmsg" value="4179">
+                       <label name="o32_sendto" value="4180">
+                       <label name="o32_setsockopt" value="4181">
+                       <label name="o32_shutdown" value="4182">
+                       <label name="o32_socket" value="4183">
+                       <label name="o32_socketpair" value="4184">
+                       <label name="o32_setresuid" value="4185">
+                       <label name="o32_getresuid" value="4186">
+                       <label name="o32_query_module" value="4187">
+                       <label name="o32_poll" value="4188">
+                       <label name="o32_nfsservctl" value="4189">
+                       <label name="o32_setresgid" value="4190">
+                       <label name="o32_getresgid" value="4191">
+                       <label name="o32_prctl" value="4192">
+                       <label name="o32_rt_sigreturn" value="4193">
+                       <label name="o32_rt_sigaction" value="4194">
+                       <label name="o32_rt_sigprocmask" value="4195">
+                       <label name="o32_rt_sigpending" value="4196">
+                       <label name="o32_rt_sigtimedwait" value="4197">
+                       <label name="o32_rt_sigqueueinfo" value="4198">
+                       <label name="o32_rt_sigsuspend" value="4199">
+                       <label name="o32_pread64" value="4200">
+                       <label name="o32_pwrite64" value="4201">
+                       <label name="o32_chown" value="4202">
+                       <label name="o32_getcwd" value="4203">
+                       <label name="o32_capget" value="4204">
+                       <label name="o32_capset" value="4205">
+                       <label name="o32_sigaltstack" value="4206">
+                       <label name="o32_sendfile" value="4207">
+                       <label name="o32_getpmsg" value="4208">
+                       <label name="o32_putpmsg" value="4209">
+                       <label name="o32_mmap2" value="4210">
+                       <label name="o32_truncate64" value="4211">
+                       <label name="o32_ftruncate64" value="4212">
+                       <label name="o32_stat64" value="4213">
+                       <label name="o32_lstat64" value="4214">
+                       <label name="o32_fstat64" value="4215">
+                       <label name="o32_pivot_root" value="4216">
+                       <label name="o32_mincore" value="4217">
+                       <label name="o32_madvise" value="4218">
+                       <label name="o32_getdents64" value="4219">
+                       <label name="o32_fcntl64" value="4220">
+                       <label name="o32_reserved221" value="4221">
+                       <label name="o32_gettid" value="4222">
+                       <label name="o32_readahead" value="4223">
+                       <label name="o32_setxattr" value="4224">
+                       <label name="o32_lsetxattr" value="4225">
+                       <label name="o32_fsetxattr" value="4226">
+                       <label name="o32_getxattr" value="4227">
+                       <label name="o32_lgetxattr" value="4228">
+                       <label name="o32_fgetxattr" value="4229">
+                       <label name="o32_listxattr" value="4230">
+                       <label name="o32_llistxattr" value="4231">
+                       <label name="o32_flistxattr" value="4232">
+                       <label name="o32_removexattr" value="4233">
+                       <label name="o32_lremovexattr" value="4234">
+                       <label name="o32_fremovexattr" value="4235">
+                       <label name="o32_tkill" value="4236">
+                       <label name="o32_sendfile64" value="4237">
+                       <label name="o32_futex" value="4238">
+                       <label name="o32_sched_setaffinity" value="4239">
+                       <label name="o32_sched_getaffinity" value="4240">
+                       <label name="o32_io_setup" value="4241">
+                       <label name="o32_io_destroy" value="4242">
+                       <label name="o32_io_getevents" value="4243">
+                       <label name="o32_io_submit" value="4244">
+                       <label name="o32_io_cancel" value="4245">
+                       <label name="o32_exit_group" value="4246">
+                       <label name="o32_lookup_dcookie" value="4247">
+                       <label name="o32_epoll_create" value="4248">
+                       <label name="o32_epoll_ctl" value="4249">
+                       <label name="o32_epoll_wait" value="4250">
+                       <label name="o32_remap_file_pages" value="4251">
+                       <label name="o32_set_tid_address" value="4252">
+                       <label name="o32_restart_syscall" value="4253">
+                       <label name="o32_fadvise64" value="4254">
+                       <label name="o32_statfs64" value="4255">
+                       <label name="o32_fstatfs64" value="4256">
+                       <label name="o32_timer_create" value="4257">
+                       <label name="o32_timer_settime" value="4258">
+                       <label name="o32_timer_gettime" value="4259">
+                       <label name="o32_timer_getoverrun" value="4260">
+                       <label name="o32_timer_delete" value="4261">
+                       <label name="o32_clock_settime" value="4262">
+                       <label name="o32_clock_gettime" value="4263">
+                       <label name="o32_clock_getres" value="4264">
+                       <label name="o32_clock_nanosleep" value="4265">
+                       <label name="o32_tgkill" value="4266">
+                       <label name="o32_utimes" value="4267">
+                       <label name="o32_mbind" value="4268">
+                       <label name="o32_get_mempolicy" value="4269">
+                       <label name="o32_set_mempolicy" value="4270">
+                       <label name="o32_mq_open" value="4271">
+                       <label name="o32_mq_unlink" value="4272">
+                       <label name="o32_mq_timedsend" value="4273">
+                       <label name="o32_mq_timedreceive" value="4274">
+                       <label name="o32_mq_notify" value="4275">
+                       <label name="o32_mq_getsetattr" value="4276">
+                       <label name="o32_vserver" value="4277">
+                       <label name="o32_waitid" value="4278">
+
+                       <label name="o32_add_key" value="4280">
+                       <label name="o32_request_key" value="4281">
+                       <label name="o32_keyctl" value="4282">
+                       <label name="o32_set_thread_area" value="4283">
+                       <label name="o32_inotify_init" value="4284">
+                       <label name="o32_inotify_add_watch" value="4285">
+                       <label name="o32_inotify_rm_watch" value="4286">
+
+                       <label name="l64_base" value="4999">
+                       <label name="l64_read" value="5000">
+                       <label name="l64_write" value="5001">
+                       <label name="l64_open" value="5002">
+                       <label name="l64_close" value="5003">
+                       <label name="l64_stat" value="5004">
+                       <label name="l64_fstat" value="5005">
+                       <label name="l64_lstat" value="5006">
+                       <label name="l64_poll" value="5007">
+                       <label name="l64_lseek" value="5008">
+                       <label name="l64_mmap" value="5009">
+                       <label name="l64_mprotect" value="5010">
+                       <label name="l64_munmap" value="5011">
+                       <label name="l64_brk" value="5012">
+                       <label name="l64_rt_sigaction" value="5013">
+                       <label name="l64_rt_sigprocmask" value="5014">
+                       <label name="l64_ioctl" value="5015">
+                       <label name="l64_pread64" value="5016">
+                       <label name="l64_pwrite64" value="5017">
+                       <label name="l64_readv" value="5018">
+                       <label name="l64_writev" value="5019">
+                       <label name="l64_access" value="5020">
+                       <label name="l64_pipe" value="5021">
+                       <label name="l64__newselect" value="5022">
+                       <label name="l64_sched_yield" value="5023">
+                       <label name="l64_mremap" value="5024">
+                       <label name="l64_msync" value="5025">
+                       <label name="l64_mincore" value="5026">
+                       <label name="l64_madvise" value="5027">
+                       <label name="l64_shmget" value="5028">
+                       <label name="l64_shmat" value="5029">
+                       <label name="l64_shmctl" value="5030">
+                       <label name="l64_dup" value="5031">
+                       <label name="l64_dup2" value="5032">
+                       <label name="l64_pause" value="5033">
+                       <label name="l64_nanosleep" value="5034">
+                       <label name="l64_getitimer" value="5035">
+                       <label name="l64_setitimer" value="5036">
+                       <label name="l64_alarm" value="5037">
+                       <label name="l64_getpid" value="5038">
+                       <label name="l64_sendfile" value="5039">
+                       <label name="l64_socket" value="5040">
+                       <label name="l64_connect" value="5041">
+                       <label name="l64_accept" value="5042">
+                       <label name="l64_sendto" value="5043">
+                       <label name="l64_recvfrom" value="5044">
+                       <label name="l64_sendmsg" value="5045">
+                       <label name="l64_recvmsg" value="5046">
+                       <label name="l64_shutdown" value="5047">
+                       <label name="l64_bind" value="5048">
+                       <label name="l64_listen" value="5049">
+                       <label name="l64_getsockname" value="5050">
+                       <label name="l64_getpeername" value="5051">
+                       <label name="l64_socketpair" value="5052">
+                       <label name="l64_setsockopt" value="5053">
+                       <label name="l64_getsockopt" value="5054">
+                       <label name="l64_clone" value="5055">
+                       <label name="l64_fork" value="5056">
+                       <label name="l64_execve" value="5057">
+                       <label name="l64_exit" value="5058">
+                       <label name="l64_wait4" value="5059">
+                       <label name="l64_kill" value="5060">
+                       <label name="l64_uname" value="5061">
+                       <label name="l64_semget" value="5062">
+                       <label name="l64_semop" value="5063">
+                       <label name="l64_semctl" value="5064">
+                       <label name="l64_shmdt" value="5065">
+                       <label name="l64_msgget" value="5066">
+                       <label name="l64_msgsnd" value="5067">
+                       <label name="l64_msgrcv" value="5068">
+                       <label name="l64_msgctl" value="5069">
+                       <label name="l64_fcntl" value="5070">
+                       <label name="l64_flock" value="5071">
+                       <label name="l64_fsync" value="5072">
+                       <label name="l64_fdatasync" value="5073">
+                       <label name="l64_truncate" value="5074">
+                       <label name="l64_ftruncate" value="5075">
+                       <label name="l64_getdents" value="5076">
+                       <label name="l64_getcwd" value="5077">
+                       <label name="l64_chdir" value="5078">
+                       <label name="l64_fchdir" value="5079">
+                       <label name="l64_rename" value="5080">
+                       <label name="l64_mkdir" value="5081">
+                       <label name="l64_rmdir" value="5082">
+                       <label name="l64_creat" value="5083">
+                       <label name="l64_link" value="5084">
+                       <label name="l64_unlink" value="5085">
+                       <label name="l64_symlink" value="5086">
+                       <label name="l64_readlink" value="5087">
+                       <label name="l64_chmod" value="5088">
+                       <label name="l64_fchmod" value="5089">
+                       <label name="l64_chown" value="5090">
+                       <label name="l64_fchown" value="5091">
+                       <label name="l64_lchown" value="5092">
+                       <label name="l64_umask" value="5093">
+                       <label name="l64_gettimeofday" value="5094">
+                       <label name="l64_getrlimit" value="5095">
+                       <label name="l64_getrusage" value="5096">
+                       <label name="l64_sysinfo" value="5097">
+                       <label name="l64_times" value="5098">
+                       <label name="l64_ptrace" value="5099">
+                       <label name="l64_getuid" value="5100">
+                       <label name="l64_syslog" value="5101">
+                       <label name="l64_getgid" value="5102">
+                       <label name="l64_setuid" value="5103">
+                       <label name="l64_setgid" value="5104">
+                       <label name="l64_geteuid" value="5105">
+                       <label name="l64_getegid" value="5106">
+                       <label name="l64_setpgid" value="5107">
+                       <label name="l64_getppid" value="5108">
+                       <label name="l64_getpgrp" value="5109">
+                       <label name="l64_setsid" value="5110">
+                       <label name="l64_setreuid" value="5111">
+                       <label name="l64_setregid" value="5112">
+                       <label name="l64_getgroups" value="5113">
+                       <label name="l64_setgroups" value="5114">
+                       <label name="l64_setresuid" value="5115">
+                       <label name="l64_getresuid" value="5116">
+                       <label name="l64_setresgid" value="5117">
+                       <label name="l64_getresgid" value="5118">
+                       <label name="l64_getpgid" value="5119">
+                       <label name="l64_setfsuid" value="5120">
+                       <label name="l64_setfsgid" value="5121">
+                       <label name="l64_getsid" value="5122">
+                       <label name="l64_capget" value="5123">
+                       <label name="l64_capset" value="5124">
+                       <label name="l64_rt_sigpending" value="5125">
+                       <label name="l64_rt_sigtimedwait" value="5126">
+                       <label name="l64_rt_sigqueueinfo" value="5127">
+                       <label name="l64_rt_sigsuspend" value="5128">
+                       <label name="l64_sigaltstack" value="5129">
+                       <label name="l64_utime" value="5130">
+                       <label name="l64_mknod" value="5131">
+                       <label name="l64_personality" value="5132">
+                       <label name="l64_ustat" value="5133">
+                       <label name="l64_statfs" value="5134">
+                       <label name="l64_fstatfs" value="5135">
+                       <label name="l64_sysfs" value="5136">
+                       <label name="l64_getpriority" value="5137">
+                       <label name="l64_setpriority" value="5138">
+                       <label name="l64_sched_setparam" value="5139">
+                       <label name="l64_sched_getparam" value="5140">
+                       <label name="l64_sched_setscheduler" value="5141">
+                       <label name="l64_sched_getscheduler" value="5142">
+                       <label name="l64_sched_get_priority_max" value="5143">
+                       <label name="l64_sched_get_priority_min" value="5144">
+                       <label name="l64_sched_rr_get_interval" value="5145">
+                       <label name="l64_mlock" value="5146">
+                       <label name="l64_munlock" value="5147">
+                       <label name="l64_mlockall" value="5148">
+                       <label name="l64_munlockall" value="5149">
+                       <label name="l64_vhangup" value="5150">
+                       <label name="l64_pivot_root" value="5151">
+                       <label name="l64__sysctl" value="5152">
+                       <label name="l64_prctl" value="5153">
+                       <label name="l64_adjtimex" value="5154">
+                       <label name="l64_setrlimit" value="5155">
+                       <label name="l64_chroot" value="5156">
+                       <label name="l64_sync" value="5157">
+                       <label name="l64_acct" value="5158">
+                       <label name="l64_settimeofday" value="5159">
+                       <label name="l64_mount" value="5160">
+                       <label name="l64_umount2" value="5161">
+                       <label name="l64_swapon" value="5162">
+                       <label name="l64_swapoff" value="5163">
+                       <label name="l64_reboot" value="5164">
+                       <label name="l64_sethostname" value="5165">
+                       <label name="l64_setdomainname" value="5166">
+                       <label name="l64_create_module" value="5167">
+                       <label name="l64_init_module" value="5168">
+                       <label name="l64_delete_module" value="5169">
+                       <label name="l64_get_kernel_syms" value="5170">
+                       <label name="l64_query_module" value="5171">
+                       <label name="l64_quotactl" value="5172">
+                       <label name="l64_nfsservctl" value="5173">
+                       <label name="l64_getpmsg" value="5174">
+                       <label name="l64_putpmsg" value="5175">
+                       <label name="l64_afs_syscall" value="5176">
+                       <label name="l64_reserved177" value="5177">
+                       <label name="l64_gettid" value="5178">
+                       <label name="l64_readahead" value="5179">
+                       <label name="l64_setxattr" value="5180">
+                       <label name="l64_lsetxattr" value="5181">
+                       <label name="l64_fsetxattr" value="5182">
+                       <label name="l64_getxattr" value="5183">
+                       <label name="l64_lgetxattr" value="5184">
+                       <label name="l64_fgetxattr" value="5185">
+                       <label name="l64_listxattr" value="5186">
+                       <label name="l64_llistxattr" value="5187">
+                       <label name="l64_flistxattr" value="5188">
+                       <label name="l64_removexattr" value="5189">
+                       <label name="l64_lremovexattr" value="5190">
+                       <label name="l64_fremovexattr" value="5191">
+                       <label name="l64_tkill" value="5192">
+                       <label name="l64_reserved193" value="5193">
+                       <label name="l64_futex" value="5194">
+                       <label name="l64_sched_setaffinity" value="5195">
+                       <label name="l64_sched_getaffinity" value="5196">
+                       <label name="l64_cacheflush" value="5197">
+                       <label name="l64_cachectl" value="5198">
+                       <label name="l64_sysmips" value="5199">
+                       <label name="l64_io_setup" value="5200">
+                       <label name="l64_io_destroy" value="5201">
+                       <label name="l64_io_getevents" value="5202">
+                       <label name="l64_io_submit" value="5203">
+                       <label name="l64_io_cancel" value="5204">
+                       <label name="l64_exit_group" value="5205">
+                       <label name="l64_lookup_dcookie" value="5206">
+                       <label name="l64_epoll_create" value="5207">
+                       <label name="l64_epoll_ctl" value="5208">
+                       <label name="l64_epoll_wait" value="5209">
+                       <label name="l64_remap_file_pages" value="5210">
+                       <label name="l64_rt_sigreturn" value="5211">
+                       <label name="l64_set_tid_address" value="5212">
+                       <label name="l64_restart_syscall" value="5213">
+                       <label name="l64_semtimedop" value="5214">
+                       <label name="l64_fadvise64" value="5215">
+                       <label name="l64_timer_create" value="5216">
+                       <label name="l64_timer_settime" value="5217">
+                       <label name="l64_timer_gettime" value="5218">
+                       <label name="l64_timer_getoverrun" value="5219">
+                       <label name="l64_timer_delete" value="5220">
+                       <label name="l64_clock_settime" value="5221">
+                       <label name="l64_clock_gettime" value="5222">
+                       <label name="l64_clock_getres" value="5223">
+                       <label name="l64_clock_nanosleep" value="5224">
+                       <label name="l64_tgkill" value="5225">
+                       <label name="l64_utimes" value="5226">
+                       <label name="l64_mbind" value="5227">
+                       <label name="l64_get_mempolicy" value="5228">
+                       <label name="l64_set_mempolicy" value="5229">
+                       <label name="l64_mq_open" value="5230">
+                       <label name="l64_mq_unlink" value="5231">
+                       <label name="l64_mq_timedsend" value="5232">
+                       <label name="l64_mq_timedreceive" value="5233">
+                       <label name="l64_mq_notify" value="5234">
+                       <label name="l64_mq_getsetattr" value="5235">
+                       <label name="l64_vserver" value="5236">
+                       <label name="l64_waitid" value="5237">
+
+                       <label name="l64_add_key" value="5239">
+                       <label name="l64_request_key" value="5240">
+                       <label name="l64_keyctl" value="5241">
+                       <label name="l64_set_thread_area" value="5242">
+                       <label name="l64_inotify_init" value="5243">
+                       <label name="l64_inotify_add_watch" value="5244">
+                       <label name="l64_inotify_rm_watch" value="5245">
+
+                       <label name="N32_base" value="5999">
+                       <label name="N32_read" value="6000">
+                       <label name="N32_write" value="6001">
+                       <label name="N32_open" value="6002">
+                       <label name="N32_close" value="6003">
+                       <label name="N32_stat" value="6004">
+                       <label name="N32_fstat" value="6005">
+                       <label name="N32_lstat" value="6006">
+                       <label name="N32_poll" value="6007">
+                       <label name="N32_lseek" value="6008">
+                       <label name="N32_mmap" value="6009">
+                       <label name="N32_mprotect" value="6010">
+                       <label name="N32_munmap" value="6011">
+                       <label name="N32_brk" value="6012">
+                       <label name="N32_rt_sigaction" value="6013">
+                       <label name="N32_rt_sigprocmask" value="6014">
+                       <label name="N32_ioctl" value="6015">
+                       <label name="N32_pread64" value="6016">
+                       <label name="N32_pwrite64" value="6017">
+                       <label name="N32_readv" value="6018">
+                       <label name="N32_writev" value="6019">
+                       <label name="N32_access" value="6020">
+                       <label name="N32_pipe" value="6021">
+                       <label name="N32__newselect" value="6022">
+                       <label name="N32_sched_yield" value="6023">
+                       <label name="N32_mremap" value="6024">
+                       <label name="N32_msync" value="6025">
+                       <label name="N32_mincore" value="6026">
+                       <label name="N32_madvise" value="6027">
+                       <label name="N32_shmget" value="6028">
+                       <label name="N32_shmat" value="6029">
+                       <label name="N32_shmctl" value="6030">
+                       <label name="N32_dup" value="6031">
+                       <label name="N32_dup2" value="6032">
+                       <label name="N32_pause" value="6033">
+                       <label name="N32_nanosleep" value="6034">
+                       <label name="N32_getitimer" value="6035">
+                       <label name="N32_setitimer" value="6036">
+                       <label name="N32_alarm" value="6037">
+                       <label name="N32_getpid" value="6038">
+                       <label name="N32_sendfile" value="6039">
+                       <label name="N32_socket" value="6040">
+                       <label name="N32_connect" value="6041">
+                       <label name="N32_accept" value="6042">
+                       <label name="N32_sendto" value="6043">
+                       <label name="N32_recvfrom" value="6044">
+                       <label name="N32_sendmsg" value="6045">
+                       <label name="N32_recvmsg" value="6046">
+                       <label name="N32_shutdown" value="6047">
+                       <label name="N32_bind" value="6048">
+                       <label name="N32_listen" value="6049">
+                       <label name="N32_getsockname" value="6050">
+                       <label name="N32_getpeername" value="6051">
+                       <label name="N32_socketpair" value="6052">
+                       <label name="N32_setsockopt" value="6053">
+                       <label name="N32_getsockopt" value="6054">
+                       <label name="N32_clone" value="6055">
+                       <label name="N32_fork" value="6056">
+                       <label name="N32_execve" value="6057">
+                       <label name="N32_exit" value="6058">
+                       <label name="N32_wait4" value="6059">
+                       <label name="N32_kill" value="6060">
+                       <label name="N32_uname" value="6061">
+                       <label name="N32_semget" value="6062">
+                       <label name="N32_semop" value="6063">
+                       <label name="N32_semctl" value="6064">
+                       <label name="N32_shmdt" value="6065">
+                       <label name="N32_msgget" value="6066">
+                       <label name="N32_msgsnd" value="6067">
+                       <label name="N32_msgrcv" value="6068">
+                       <label name="N32_msgctl" value="6069">
+                       <label name="N32_fcntl" value="6070">
+                       <label name="N32_flock" value="6071">
+                       <label name="N32_fsync" value="6072">
+                       <label name="N32_fdatasync" value="6073">
+                       <label name="N32_truncate" value="6074">
+                       <label name="N32_ftruncate" value="6075">
+                       <label name="N32_getdents" value="6076">
+                       <label name="N32_getcwd" value="6077">
+                       <label name="N32_chdir" value="6078">
+                       <label name="N32_fchdir" value="6079">
+                       <label name="N32_rename" value="6080">
+                       <label name="N32_mkdir" value="6081">
+                       <label name="N32_rmdir" value="6082">
+                       <label name="N32_creat" value="6083">
+                       <label name="N32_link" value="6084">
+                       <label name="N32_unlink" value="6085">
+                       <label name="N32_symlink" value="6086">
+                       <label name="N32_readlink" value="6087">
+                       <label name="N32_chmod" value="6088">
+                       <label name="N32_fchmod" value="6089">
+                       <label name="N32_chown" value="6090">
+                       <label name="N32_fchown" value="6091">
+                       <label name="N32_lchown" value="6092">
+                       <label name="N32_umask" value="6093">
+                       <label name="N32_gettimeofday" value="6094">
+                       <label name="N32_getrlimit" value="6095">
+                       <label name="N32_getrusage" value="6096">
+                       <label name="N32_sysinfo" value="6097">
+                       <label name="N32_times" value="6098">
+                       <label name="N32_ptrace" value="6099">
+                       <label name="N32_getuid" value="6100">
+                       <label name="N32_syslog" value="6101">
+                       <label name="N32_getgid" value="6102">
+                       <label name="N32_setuid" value="6103">
+                       <label name="N32_setgid" value="6104">
+                       <label name="N32_geteuid" value="6105">
+                       <label name="N32_getegid" value="6106">
+                       <label name="N32_setpgid" value="6107">
+                       <label name="N32_getppid" value="6108">
+                       <label name="N32_getpgrp" value="6109">
+                       <label name="N32_setsid" value="6110">
+                       <label name="N32_setreuid" value="6111">
+                       <label name="N32_setregid" value="6112">
+                       <label name="N32_getgroups" value="6113">
+                       <label name="N32_setgroups" value="6114">
+                       <label name="N32_setresuid" value="6115">
+                       <label name="N32_getresuid" value="6116">
+                       <label name="N32_setresgid" value="6117">
+                       <label name="N32_getresgid" value="6118">
+                       <label name="N32_getpgid" value="6119">
+                       <label name="N32_setfsuid" value="6120">
+                       <label name="N32_setfsgid" value="6121">
+                       <label name="N32_getsid" value="6122">
+                       <label name="N32_capget" value="6123">
+                       <label name="N32_capset" value="6124">
+                       <label name="N32_rt_sigpending" value="6125">
+                       <label name="N32_rt_sigtimedwait" value="6126">
+                       <label name="N32_rt_sigqueueinfo" value="6127">
+                       <label name="N32_rt_sigsuspend" value="6128">
+                       <label name="N32_sigaltstack" value="6129">
+                       <label name="N32_utime" value="6130">
+                       <label name="N32_mknod" value="6131">
+                       <label name="N32_personality" value="6132">
+                       <label name="N32_ustat" value="6133">
+                       <label name="N32_statfs" value="6134">
+                       <label name="N32_fstatfs" value="6135">
+                       <label name="N32_sysfs" value="6136">
+                       <label name="N32_getpriority" value="6137">
+                       <label name="N32_setpriority" value="6138">
+                       <label name="N32_sched_setparam" value="6139">
+                       <label name="N32_sched_getparam" value="6140">
+                       <label name="N32_sched_setscheduler" value="6141">
+                       <label name="N32_sched_getscheduler" value="6142">
+                       <label name="N32_sched_get_priority_max" value="6143">
+                       <label name="N32_sched_get_priority_min" value="6144">
+                       <label name="N32_sched_rr_get_interval" value="6145">
+                       <label name="N32_mlock" value="6146">
+                       <label name="N32_munlock" value="6147">
+                       <label name="N32_mlockall" value="6148">
+                       <label name="N32_munlockall" value="6149">
+                       <label name="N32_vhangup" value="6150">
+                       <label name="N32_pivot_root" value="6151">
+                       <label name="N32__sysctl" value="6152">
+                       <label name="N32_prctl" value="6153">
+                       <label name="N32_adjtimex" value="6154">
+                       <label name="N32_setrlimit" value="6155">
+                       <label name="N32_chroot" value="6156">
+                       <label name="N32_sync" value="6157">
+                       <label name="N32_acct" value="6158">
+                       <label name="N32_settimeofday" value="6159">
+                       <label name="N32_mount" value="6160">
+                       <label name="N32_umount2" value="6161">
+                       <label name="N32_swapon" value="6162">
+                       <label name="N32_swapoff" value="6163">
+                       <label name="N32_reboot" value="6164">
+                       <label name="N32_sethostname" value="6165">
+                       <label name="N32_setdomainname" value="6166">
+                       <label name="N32_create_module" value="6167">
+                       <label name="N32_init_module" value="6168">
+                       <label name="N32_delete_module" value="6169">
+                       <label name="N32_get_kernel_syms" value="6170">
+                       <label name="N32_query_module" value="6171">
+                       <label name="N32_quotactl" value="6172">
+                       <label name="N32_nfsservctl" value="6173">
+                       <label name="N32_getpmsg" value="6174">
+                       <label name="N32_putpmsg" value="6175">
+                       <label name="N32_afs_syscall" value="6176">
+                       <label name="N32_reserved177" value="6177">
+                       <label name="N32_gettid" value="6178">
+                       <label name="N32_readahead" value="6179">
+                       <label name="N32_setxattr" value="6180">
+                       <label name="N32_lsetxattr" value="6181">
+                       <label name="N32_fsetxattr" value="6182">
+                       <label name="N32_getxattr" value="6183">
+                       <label name="N32_lgetxattr" value="6184">
+                       <label name="N32_fgetxattr" value="6185">
+                       <label name="N32_listxattr" value="6186">
+                       <label name="N32_llistxattr" value="6187">
+                       <label name="N32_flistxattr" value="6188">
+                       <label name="N32_removexattr" value="6189">
+                       <label name="N32_lremovexattr" value="6190">
+                       <label name="N32_fremovexattr" value="6191">
+                       <label name="N32_tkill" value="6192">
+                       <label name="N32_reserved193" value="6193">
+                       <label name="N32_futex" value="6194">
+                       <label name="N32_sched_setaffinity" value="6195">
+                       <label name="N32_sched_getaffinity" value="6196">
+                       <label name="N32_cacheflush" value="6197">
+                       <label name="N32_cachectl" value="6198">
+                       <label name="N32_sysmips" value="6199">
+                       <label name="N32_io_setup" value="6200">
+                       <label name="N32_io_destroy" value="6201">
+                       <label name="N32_io_getevents" value="6202">
+                       <label name="N32_io_submit" value="6203">
+                       <label name="N32_io_cancel" value="6204">
+                       <label name="N32_exit_group" value="6205">
+                       <label name="N32_lookup_dcookie" value="6206">
+                       <label name="N32_epoll_create" value="6207">
+                       <label name="N32_epoll_ctl" value="6208">
+                       <label name="N32_epoll_wait" value="6209">
+                       <label name="N32_remap_file_pages" value="6210">
+                       <label name="N32_rt_sigreturn" value="6211">
+                       <label name="N32_fcntl64" value="6212">
+                       <label name="N32_set_tid_address" value="6213">
+                       <label name="N32_restart_syscall" value="6214">
+                       <label name="N32_semtimedop" value="6215">
+                       <label name="N32_fadvise64" value="6216">
+                       <label name="N32_statfs64" value="6217">
+                       <label name="N32_fstatfs64" value="6218">
+                       <label name="N32_sendfile64" value="6219">
+                       <label name="N32_timer_create" value="6220">
+                       <label name="N32_timer_settime" value="6221">
+                       <label name="N32_timer_gettime" value="6222">
+                       <label name="N32_timer_getoverrun" value="6223">
+                       <label name="N32_timer_delete" value="6224">
+                       <label name="N32_clock_settime" value="6225">
+                       <label name="N32_clock_gettime" value="6226">
+                       <label name="N32_clock_getres" value="6227">
+                       <label name="N32_clock_nanosleep" value="6228">
+                       <label name="N32_tgkill" value="6229">
+                       <label name="N32_utimes" value="6230">
+                       <label name="N32_mbind" value="6231">
+                       <label name="N32_get_mempolicy" value="6232">
+                       <label name="N32_set_mempolicy" value="6233">
+                       <label name="N32_mq_open" value="6234">
+                       <label name="N32_mq_unlink" value="6235">
+                       <label name="N32_mq_timedsend" value="6236">
+                       <label name="N32_mq_timedreceive" value="6237">
+                       <label name="N32_mq_notify" value="6238">
+                       <label name="N32_mq_getsetattr" value="6239">
+                       <label name="N32_vserver" value="6240">
+                       <label name="N32_waitid" value="6241">
+
+                       <label name="N32_add_key" value="6243">
+                       <label name="N32_request_key" value="6244">
+                       <label name="N32_keyctl" value="6245">
+                       <label name="N32_set_thread_area" value="6246">
+                       <label name="N32_inotify_init" value="6247">
+                       <label name="N32_inotify_add_watch" value="6248">
+                       <label name="N32_inotify_rm_watch" value="6249">
+    </enum>
+  </type>
+
+  <event name="syscall_entry">
+    <description>System call entry</description>
+    <field name="syscall_id"> <description>Syscall entry number in
+               entry.S</description> <typeref name="syscall_name"> </field>
+    <field name="address"> <description>Address from which call was made</description> <pointer> </field>
+  </event>
+       
+       <event name="syscall_exit">
+    <description>System call exit</description>
+  </event>
+</facility>
diff --git a/ltt-control/facilities/locking.xml b/ltt-control/facilities/locking.xml
new file mode 100644 (file)
index 0000000..9b80fcc
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<facility name="locking">
+  <description>The locking facility instruments the kernel locking.</description>
+  <event name="spin_lock_wait">
+    <description>Takes a spinlock</description>
+    <field name="spinlock"> <description>Spinlock address</description> <pointer> </field>
+  </event>
+
+  <event name="spin_lock_try">
+    <description>Tries a spinlock</description>
+    <field name="spinlock"> <description>Spinlock address</description> <pointer> </field>
+  </event>
+
+  <event name="spin_lock_entry">
+    <description>Get a spinlock</description>
+    <field name="spinlock"> <description>Spinlock address</description> <pointer> </field>
+  </event>
+
+  <event name="spin_lock_exit">
+    <description>Releases a spinlock</description>
+    <field name="spinlock"> <description>Spinlock address</description> <pointer> </field>
+  </event>
+
+
+</facility>
diff --git a/ltt-control/facilities/memory.xml b/ltt-control/facilities/memory.xml
new file mode 100644 (file)
index 0000000..abd7de5
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<facility name="memory">
+  <description>The memory facility has memory management events.</description>
+
+  <event name="page_alloc">
+    <description>Page allocation</description>
+    <field name="order"> <description>Order of the page to allocate</description> <uint size="4"> </field>
+    <field name="address"> <description>Assigned page address, or 0 if failed.</description> <pointer> </field>
+  </event>
+
+  <event name="page_free">
+    <description>Page free</description>
+    <field name="order"> <description>Order of the page to free</description> <uint size="4"> </field>
+    <field name="address"> <description>Address of the page to free.</description> <pointer> </field>
+  </event>
+
+  <event name="swap_in">
+    <description>Page swapped into memory</description>
+    <field name="address"> <description>Address of the page to swap in.</description> <pointer> </field>
+  </event>
+
+  <event name="swap_out">
+    <description>Page swapped to disk</description>
+    <field name="address"> <description>Address of the page to swap out.</description> <pointer> </field>
+  </event>
+
+  <event name="page_wait_start">
+    <description>Staring to wait for a page</description>
+    <field name="address"> <description>Address of the page we wait for.</description> <pointer> </field>
+  </event>
+
+  <event name="page_wait_end">
+    <description>Ending wait for a page</description>
+    <field name="address"> <description>Address of the page we wait for.</description> <pointer> </field>
+  </event>
+
+</facility>
diff --git a/ltt-control/facilities/network.xml b/ltt-control/facilities/network.xml
new file mode 100644 (file)
index 0000000..0bfcf9b
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<facility name="network">
+  <description>The network facility contains events related to low level network operations</description>
+
+  <event name="packet_in">
+    <description>A packet is arriving</description>
+    <field name="skbuff"> <description>Socket buffer pointer : identify the socket buffer</description> <pointer> </field>
+    <field name="protocol"> <description>Protocol of the packet</description><uint size="2"> </field>
+  </event>
+
+  <event name="packet_out">
+    <description>We send a packet</description>
+    <field name="skbuff"> <description>Socket buffer pointer : identify the socket buffer</description> <pointer> </field>
+    <field name="protocol"> <description>Protocol of the packet</description><uint size="2"> </field>
+  </event>
+
+</facility>
diff --git a/ltt-control/facilities/network_ip_interface.xml b/ltt-control/facilities/network_ip_interface.xml
new file mode 100644 (file)
index 0000000..93f4dee
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<facility name="network_ip_interface">
+    <description>Network IP interface status</description>
+    
+  <event name="dev_up">
+    <description>IP interface up</description>
+      <field name="name"> <description>Interface name</description><string></field>
+      <field name="addr"> <description>IP address</description> <uint size="4" byte_order="network"> </field>
+  </event>  
+  
+  <event name="dev_down">
+    <description>IP interface down</description>
+      <field name="name"> <description>Interface name</description><string></field>
+  </event> 
+  
+</facility>
diff --git a/ltt-control/facilities/process.xml b/ltt-control/facilities/process.xml
new file mode 100644 (file)
index 0000000..6d80c55
--- /dev/null
@@ -0,0 +1,97 @@
+<?xml version="1.0"?>
+<facility name="process">
+  <description>The process facility has events related to process handling in the kernel.</description>
+
+  <type name="signal_name">
+    <enum>
+      <label name="SIGHUP" value="1"> <description>Hangup (POSIX).</description>
+      <label name="SIGINT" value="2"> <description>Interrupt (ANSI).</description>
+      <label name="SIGQUIT" value="3"> <description>Quit (POSIX).</description>
+      <label name="SIGILL" value="4"> <description>Illegal instruction (ANSI).</description>
+      <label name="SIGTRAP" value="5"> <description>Trace trap (POSIX).</description>
+      <label name="SIGABRT" value="6"> <description>Abort (ANSI).</description>
+      <label name="SIGBUS" value="7"> <description>BUS error (4.2 BSD).</description>
+      <label name="SIGFPE" value="8"> <description>Floating-point exception (ANSI).</description>
+      <label name="SIGKILL" value="9"> <description>Kill, unblockable (POSIX).</description>
+      <label name="SIGUSR1" value="10"> <description>User-defined signal 1 (POSIX).</description>
+      <label name="SIGSEGV" value="11"> <description>Segmentation violation (ANSI).</description>
+      <label name="SIGUSR2" value="12"> <description>User-defined signal 2 (POSIX).</description>
+      <label name="SIGPIPE" value="13"> <description>Broken pipe (POSIX).</description>
+      <label name="SIGALRM" value="14"> <description>Alarm clock (POSIX).</description>
+      <label name="SIGTERM" value="15"> <description>Termination (ANSI).</description>
+      <label name="SIGSTKFLT" value="16"> <description>Stack fault.</description>
+  
+      <label name="SIGCHLD" value="17"> <description>Child status has changed (POSIX).</description>
+      <label name="SIGCONT" value="18"> <description>Continue (POSIX).</description>
+      <label name="SIGSTOP" value="19"> <description>Stop, unblockable (POSIX).</description>
+      <label name="SIGTSTP" value="20"> <description>Keyboard stop (POSIX).</description>
+      <label name="SIGTTIN" value="21"> <description>Background read from tty (POSIX).</description>
+      <label name="SIGTTOU" value="22"> <description>Background write to tty (POSIX).</description>
+      <label name="SIGURG" value="23"> <description>Urgent condition on socket (4.2 BSD).</description>
+      <label name="SIGXCPU" value="24"> <description>CPU limit exceeded (4.2 BSD).</description>
+      <label name="SIGXFSZ" value="25"> <description>File size limit exceeded (4.2 BSD).</description>
+      <label name="SIGVTALRM" value="26"> <description>Virtual alarm clock (4.2 BSD).</description>
+      <label name="SIGPROF" value="27"> <description>Profiling alarm clock (4.2 BSD).</description>
+      <label name="SIGWINCH" value="28"> <description>Window size change (4.3 BSD, Sun).</description>
+      <label name="SIGIO" value="29"> <description>I/O now possible (4.2 BSD). (aka SIGPOLL)</description>
+      <label name="SIGPWR" value="30"> <description>Power failure restart (System V).</description>
+      <label name="SIGSYS" value="31"> <description>Bad system call.</description>
+    </enum>
+  </type>
+
+  <event name="fork">
+    <description>Process fork</description>
+    <field name="parent_pid"> <description>PID of the parent process</description> <uint> </field>
+    <field name="child_pid"> <description>PID of the child process</description> <uint> </field>
+  </event>
+       
+  <event name="kernel_thread">
+    <description>Just created a new kernel thread</description>
+    <field name="pid"> <description>PID of the kernel thread</description> <uint> </field>
+    <field name="function"> <description>Function called</description> <pointer> </field>
+  </event>
+
+
+  <event name="exit">
+    <description>Process exit</description>
+    <field name="pid"> <description>PID of the process</description> <uint> </field>
+  </event>
+
+  <event name="wait">
+    <description>Process wait</description>
+    <field name="parent_pid"> <description>PID of the waiting process</description> <uint> </field>
+    <field name="child_pid"> <description>PID of the process waited for</description> <uint> </field>
+  </event>
+
+  <event name="free">
+    <description>Process kernel data structure free (end of life of a zombie)</description>
+    <field name="pid"> <description>PID of the freed process</description> <uint> </field>
+  </event>
+
+  <event name="kill">
+    <description>Process kill system call</description>
+    <field name="pid"> <description>PID of the process</description> <uint> </field>
+    <field name="target_pid"> <description>PID of the process to kill</description> <uint> </field>
+    <field name="signal"> <description>Signal number</description> <typeref name="signal_name"> </field>
+  </event>
+
+  <event name="signal">
+    <description>Process signal reception</description>
+    <field name="pid"> <description>PID of the receiving process</description> <uint> </field>
+    <field name="signal"> <description>Signal number</description> <typeref name="signal_name"> </field>
+  </event>
+
+  <event name="wakeup">
+    <description>Process wakeup</description>
+    <field name="pid"> <description>PID of the receiving process</description> <uint> </field>
+    <field name="state"> <description>State of the awakened process. -1 unrunnable, 0 runnable, >0 stopped.</description> <int> </field>
+  </event>
+
+  <event name="schedchange">
+    <description>Scheduling change</description>
+    <field name="out"> <description>Outgoing process</description> <uint> </field>
+    <field name="in"> <description>Incoming process</description> <uint> </field>
+    <field name="out_state"> <description>Outgoing process' state. -1 unrunnable, 0 runnable, >0 stopped.</description> <int> </field>
+  </event>
+
+</facility>
diff --git a/ltt-control/facilities/socket.xml b/ltt-control/facilities/socket.xml
new file mode 100644 (file)
index 0000000..8439d19
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<facility name="socket">
+  <description>The socket facility contains events related to sockets</description>
+
+  <event name="call">
+    <description>Generic socket call : FIXME : should be more detailed.</description>
+    <field name="call_number"> <description>Number of socket call</description> <int size="4"> </field>
+    <field name="first_argument"> <description>First argument of socket call</description> <ulong> </field>
+  </event>
+
+  <event name="create">
+    <description>Create a socket</description>
+    <field name="socket"> <description>Socket structure address</description> <pointer> </field>
+    <field name="family"> <description>Socket family</description> <int size="4"> </field>
+    <field name="type"> <description>Socket type</description> <int size="4"> </field>
+    <field name="protocol"> <description>Socket protocol</description> <int size="4"> </field>
+    <field name="fd"> <description>Socket file descriptor</description> <int size="4"> </field>
+  </event>
+
+  <event name="sendmsg">
+    <description>Sending a socket message</description>
+    <field name="socket"> <description>Socket structure address</description> <pointer> </field>
+    <field name="family"> <description>Socket family</description> <int size="4"> </field>
+    <field name="type"> <description>Socket type</description> <int size="4"> </field>
+    <field name="protocol"> <description>Socket protocol</description> <int size="4"> </field>
+    <field name="size"> <description>Size of the message</description> <size_t> </field>
+  </event>
+
+  <event name="recvmsg">
+    <description>Receiving a socket message</description>
+    <field name="socket"> <description>Socket structure address</description> <pointer> </field>
+    <field name="family"> <description>Socket family</description> <int size="4"> </field>
+    <field name="type"> <description>Socket type</description> <int size="4"> </field>
+    <field name="protocol"> <description>Socket protocol</description> <int size="4"> </field>
+    <field name="size"> <description>Size of the message</description> <size_t> </field>
+  </event>
+
+</facility>
diff --git a/ltt-control/facilities/stack_arch_i386.xml b/ltt-control/facilities/stack_arch_i386.xml
new file mode 100644 (file)
index 0000000..3eeee38
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<facility name="stack_arch" arch="i386">
+  <description>The stack facility has events related to getting process stack.</description>
+
+  <event name="process_dump">
+    <description>Process EIP on the user stack</description>
+    <field name="eip"> <description>Sequence of EIP</description>
+                       <sequence write="custom">
+                               <uint>
+                               <ulong>
+                       </sequence>
+               </field>
+  </event>
+
+  <event name="kernel_dump">
+    <description>EIP on the kernel stack</description>
+    <field name="eip"> <description>Sequence of EIP</description>
+                       <sequence write="custom">
+                               <uint>
+                               <ulong>
+                       </sequence>
+               </field>
+  </event>
+
+</facility>
diff --git a/ltt-control/facilities/statedump.xml b/ltt-control/facilities/statedump.xml
new file mode 100644 (file)
index 0000000..2d40984
--- /dev/null
@@ -0,0 +1,97 @@
+<?xml version="1.0"?>
+<facility name="statedump">
+  <description>The statedump facility contains the events generated at trace startup</description>
+
+  <type name=execution_mode>
+    <enum>
+      <label name="USER_MODE" value="0"> <description>Task is executing user code</description>
+      <label name="SYSCALL" value="1"> <description>Task is in a system call</description>
+      <label name="TRAP" value="2"> <description>Task is in a trap</description>
+      <label name="IRQ" value="3"> <description></description>
+      <label name="SOFTIRQ" value="4"> <description></description>
+      <label name="MODE_UNKNOWN" value="5"> <description>Execution mode cannot be determined for this task</description>
+    </enum>
+  </type>
+
+  <type name=execution_submode>
+    <enum>
+      <label name="NONE" value="0"> <description>No execution submode to report</description>
+      <label name="UNKNOWN" value="1"> <description>Task execution submode cannot be determined</description>
+    </enum>
+  </type>
+
+  <type name=process_status>
+    <enum>
+      <label name="UNNAMED" value="0"> <description></description>
+      <label name="WAIT_FORK" value="1"> <description></description>
+      <label name="WAIT_CPU" value="2"> <description></description>
+      <label name="EXIT" value="3"> <description></description>
+      <label name="ZOMBIE" value="4"> <description></description>
+      <label name="WAIT" value="5"> <description></description>
+      <label name="RUN" value="6"> <description></description>
+      <label name="DEAD" value="7"> <description></description>
+    </enum>
+  </type>
+
+       <type name=interface_state>
+               <enum>
+      <label name="UP" value="0"> <description></description>
+      <label name="DOWN" value="1"> <description></description>
+               </enum>
+       </type>
+
+  <event name="enumerate_file_descriptors">
+    <description>List of open file descriptors</description>
+      <field name="name"><description>File name</description><string></field>
+      <field name="PID"><description>Process identifier</description><uint size="4"></field>
+      <field name="fd"><description>File descriptor index in this process's task_struct</description><uint size="4"></field>
+  </event>
+
+  <event name="enumerate_vm_maps">
+    <description>List of active vm maps</description>
+      <field name="PID"><description>Process identifier</description><uint size="4"></field>
+      <field name="start"> <description>VM's start address</description> <pointer> </field>
+      <field name="end"> <description>VM's end address</description> <pointer> </field>
+      <field name="flags"> <description>VM area flags</description> <uint size="1"> </field>
+      <field name="pgoff"> <description>VM's page offset</description> <long> </field>
+      <field name="inode"> <description>Inode associated with this VM</description> <long> </field>
+  </event>
+
+  <event name="enumerate_modules">
+    <description>List of loaded kernel modules</description>
+      <field name="name"><description>Module name</description><string></field>
+      <field name="state"><description>Module's state</description><uint size="4"></field>
+      <field name="ref"><description>Number of references to this module</description><uint size="4"></field>
+  </event>
+
+  <event name="enumerate_interrupts">
+    <description>List of registered interrupts</description>
+      <field name="name"> <description>Interrupt name</description> <string> </field>
+      <field name="action"> <description>action triggered by interrupt</description> <string> </field>
+      <field name="num"> <description>Interrupt number</description> <uint size="4"> </field>
+  </event>
+
+  <event name="enumerate_process_state">
+    <description>State of each process when statedump is performed</description>
+      <field name="pid"><description>Process identifier</description><uint size="4"></field>
+      <field name="parent_pid"><description>Parent process identifier</description><uint size="4"></field>
+      <field name="name"> <description>Process name</description><string></field>
+      <field name="mode"> <description>Execution mode</description> <typeref name="execution_mode"> </field>
+      <field name="submode"> <description>Execution submode</description> <typeref name="execution_submode"> </field>
+      <field name="status"> <description>Process status</description> <typeref name="process_status"> </field>
+  </event>
+
+  <event name="enumerate_network_ip_interface">
+    <description>List of each IP interface up</description>
+      <field name="name"> <description>Interface name</description><string></field>
+      <field name="addr"> <description>IP address</description> <uint size="4" byte_order="network"> </field>
+                       <field name="status"> <description>Status of the interface</description> <typeref name="interface_state"> </field>
+  </event>  
+  
+  <event name="statedump_end">
+    <description>Kernel state dump complete</description>
+  </event>
+
+</facility>
+
+
diff --git a/ltt-control/facilities/timer.xml b/ltt-control/facilities/timer.xml
new file mode 100644 (file)
index 0000000..c07256f
--- /dev/null
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<facility name="timer">
+  <description>The timer facility has events related to timer events in the kernel.</description>
+
+  <type name="itimer_kind">
+    <enum>
+      <label name="ITIMER_REAL" value="0"> <description>decrements in real time,
+      and delivers SIGALRM upon expiration.</description>
+      <label name="ITIMER_VIRTUAL" value="1"> <description>decrements only when the
+      process is executing, and delivers SIGVTALRM upon expiration.</description>
+      <label name="ITIMER_PROF" value="2"> <description>decrements both when the
+      process executes and when the system is executing on behalf of the
+      process. Coupled with ITIMER_VIRTUAL, this timer is usually used to
+      profile the time spent by the application in user and kernel space.
+      SIGPROF is delivered upon expiration.</description>
+    </enum>
+  </type>
+
+  <event name="expired">
+    <description>A timer or itimer has expired.</description>
+    <field name="pid">
+                       <description>PID of the process to wake up.</description>
+                       <uint size="4">
+               </field>
+  </event>
+
+  <event name="softirq">
+    <description>The timer softirq is currently runned.</description>
+  </event>
+
+  <event name="set_itimer">
+    <description>An interval timer is set.</description>
+    <field name="which"> <description>kind of interval timer.</description>
+           <typeref name="itimer_kind">
+               </field>
+    <field name="interval_seconds"><uint size="4"></field>
+    <field name="interval_microseconds"><uint size="4"></field>
+    <field name="value_seconds"><uint size="4"></field>
+    <field name="value_microseconds"><uint size="4"></field>
+  </event>
+
+</facility>
diff --git a/ltt-control/facilities/user_generic.xml b/ltt-control/facilities/user_generic.xml
new file mode 100644 (file)
index 0000000..2dc7267
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<facility name="user_generic">
+  <description>Generic user space facility</description>
+       
+  <event name="string">
+       <description>Takes a string from user space</description>
+               <field name="data"><string></field>
+  </event>
+
+  <event name="string_pointer">
+       <description>Takes a string and pointer from user space</description>
+               <field name="string"><string></field>
+               <field name="pointer"><pointer></field>
+  </event>
+       
+       <event name="slow_printf" param="buffer">
+       <description>Takes a buffer of variable size (written by printf) and log it.</description>
+               <field name="string"><string></field>
+  </event>
+       
+       <event name="function_entry" attribute="no_instrument_function">
+               <description>Entry in a function</description>
+               <field name="this_fn"><pointer></field>
+               <field name="call_site"><pointer></field>
+       </event>
+
+       <event name="function_exit" attribute="no_instrument_function">
+               <description>Exit from a function</description>
+               <field name="this_fn"><pointer></field>
+               <field name="call_site"><pointer></field>
+       </event>
+
+</facility>
diff --git a/ltt-control/liblttctl/Makefile.am b/ltt-control/liblttctl/Makefile.am
new file mode 100644 (file)
index 0000000..1c650f0
--- /dev/null
@@ -0,0 +1,7 @@
+
+
+lib_LTLIBRARIES = liblttctl.la
+liblttctl_la_SOURCES = liblttctl.c
+
+lttctlinclude_HEADERS = \
+       lttctl.h
diff --git a/ltt-control/liblttctl/liblttctl.c b/ltt-control/liblttctl/liblttctl.c
new file mode 100644 (file)
index 0000000..d6f411b
--- /dev/null
@@ -0,0 +1,483 @@
+/* libltt
+ *
+ * Linux Trace Toolkit Netlink Control Library
+ *
+ * Controls the ltt-control kernel module through a netlink socket.
+ *
+ * Heavily inspired from libipq.c (iptables) made by 
+ * James Morris <jmorris@intercode.com.au>
+ *
+ * Copyright 2005 -
+ *     Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
+ *
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *     
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <liblttctl/lttctl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <error.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+
+
+
+/* Private interface */
+
+enum {
+       LTTCTL_ERR_NONE = 0,
+       LTTCTL_ERR_IMPL,
+       LTTCTL_ERR_HANDLE,
+       LTTCTL_ERR_SOCKET,
+       LTTCTL_ERR_BIND,
+       LTTCTL_ERR_BUFFER,
+       LTTCTL_ERR_RECV,
+       LTTCTL_ERR_NLEOF,
+       LTTCTL_ERR_ADDRLEN,
+       LTTCTL_ERR_STRUNC,
+       LTTCTL_ERR_RTRUNC,
+       LTTCTL_ERR_NLRECV,
+       LTTCTL_ERR_SEND,
+       LTTCTL_ERR_SUPP,
+       LTTCTL_ERR_RECVBUF,
+       LTTCTL_ERR_TIMEOUT,
+        LTTCTL_ERR_PROTOCOL
+};
+#define LTTCTL_MAXERR LTTCTL_ERR_PROTOCOL
+
+
+struct lttctl_errmap_t {
+       int errcode;
+       char *message;
+} lttctl_errmap[] = {
+       { LTTCTL_ERR_NONE, "Unknown error" },
+       { LTTCTL_ERR_IMPL, "Implementation error" },
+       { LTTCTL_ERR_HANDLE, "Unable to create netlink handle" },
+       { LTTCTL_ERR_SOCKET, "Unable to create netlink socket" },
+       { LTTCTL_ERR_BIND, "Unable to bind netlink socket" },
+       { LTTCTL_ERR_BUFFER, "Unable to allocate buffer" },
+       { LTTCTL_ERR_RECV, "Failed to receive netlink message" },
+       { LTTCTL_ERR_NLEOF, "Received EOF on netlink socket" },
+       { LTTCTL_ERR_ADDRLEN, "Invalid peer address length" },
+       { LTTCTL_ERR_STRUNC, "Sent message truncated" },
+       { LTTCTL_ERR_RTRUNC, "Received message truncated" },
+       { LTTCTL_ERR_NLRECV, "Received error from netlink" },
+       { LTTCTL_ERR_SEND, "Failed to send netlink message" },
+       { LTTCTL_ERR_SUPP, "Operation not supported" },
+       { LTTCTL_ERR_RECVBUF, "Receive buffer size invalid" },
+       { LTTCTL_ERR_TIMEOUT, "Timeout"},
+       { LTTCTL_ERR_PROTOCOL, "Invalid protocol specified" }
+};
+
+static int lttctl_errno = LTTCTL_ERR_NONE;
+
+
+static ssize_t lttctl_netlink_sendto(const struct lttctl_handle *h,
+                                  const void *msg, size_t len);
+
+static ssize_t lttctl_netlink_recvfrom(const struct lttctl_handle *h,
+                                    unsigned char *buf, size_t len,
+                                    int timeout);
+
+static ssize_t lttctl_netlink_sendmsg(const struct lttctl_handle *h,
+                                   const struct msghdr *msg,
+                                   unsigned int flags);
+
+static char *lttctl_strerror(int errcode);
+
+void lttctl_perror(const char *s);
+
+static ssize_t lttctl_netlink_sendto(const struct lttctl_handle *h,
+                                  const void *msg, size_t len)
+{
+       int status = sendto(h->fd, msg, len, 0,
+                           (struct sockaddr *)&h->peer, sizeof(h->peer));
+       if (status < 0)
+               lttctl_errno = LTTCTL_ERR_SEND;
+       
+       return status;
+}
+
+static ssize_t lttctl_netlink_sendmsg(const struct lttctl_handle *h,
+                                   const struct msghdr *msg,
+                                   unsigned int flags)
+{
+       int status = sendmsg(h->fd, msg, flags);
+       if (status < 0)
+               lttctl_errno = LTTCTL_ERR_SEND;
+       return status;
+}
+
+static ssize_t lttctl_netlink_recvfrom(const struct lttctl_handle *h,
+                                    unsigned char *buf, size_t len,
+                                    int timeout)
+{
+       int addrlen, status;
+       struct nlmsghdr *nlh;
+
+       if (len < sizeof(struct nlmsghdr)) {
+               lttctl_errno = LTTCTL_ERR_RECVBUF;
+               lttctl_perror("Netlink recvfrom");
+               return -1;
+       }
+       addrlen = sizeof(h->peer);
+
+       if (timeout != 0) {
+               int ret;
+               struct timeval tv;
+               fd_set read_fds;
+               
+               if (timeout < 0) {
+                       /* non-block non-timeout */
+                       tv.tv_sec = 0;
+                       tv.tv_usec = 0;
+               } else {
+                       tv.tv_sec = timeout / 1000000;
+                       tv.tv_usec = timeout % 1000000;
+               }
+
+               FD_ZERO(&read_fds);
+               FD_SET(h->fd, &read_fds);
+               ret = select(h->fd+1, &read_fds, NULL, NULL, &tv);
+               if (ret < 0) {
+                       if (errno == EINTR) {
+                               printf("eintr\n");
+                               return 0;
+                       } else {
+                               lttctl_errno = LTTCTL_ERR_RECV;
+                               lttctl_perror("Netlink recvfrom");
+                               return -1;
+                       }
+               }
+               if (!FD_ISSET(h->fd, &read_fds)) {
+                       lttctl_errno = LTTCTL_ERR_TIMEOUT;
+                       printf("timeout\n");
+                       return 0;
+               }
+       }
+       status = recvfrom(h->fd, buf, len, 0,
+                             (struct sockaddr *)&h->peer, &addrlen);
+       
+       if (status < 0) {
+               lttctl_errno = LTTCTL_ERR_RECV;
+               lttctl_perror("Netlink recvfrom");
+               return status;
+       }
+       if (addrlen != sizeof(h->peer)) {
+               lttctl_errno = LTTCTL_ERR_RECV;
+               lttctl_perror("Netlink recvfrom");
+               return -1;
+       }
+       if (h->peer.nl_pid != 0) {
+               lttctl_errno = LTTCTL_ERR_RECV;
+               lttctl_perror("Netlink recvfrom");
+               return -1;
+       }
+       if (status == 0) {
+               lttctl_errno = LTTCTL_ERR_NLEOF;
+               lttctl_perror("Netlink recvfrom");
+               return -1;
+       }
+       nlh = (struct nlmsghdr *)buf;
+       if (nlh->nlmsg_flags & MSG_TRUNC || nlh->nlmsg_len > status) {
+               lttctl_errno = LTTCTL_ERR_RTRUNC;
+               lttctl_perror("Netlink recvfrom");
+               return -1;
+       }
+       
+
+       return status;
+}
+
+
+static char *lttctl_strerror(int errcode)
+{
+       if (errcode < 0 || errcode > LTTCTL_MAXERR)
+               errcode = LTTCTL_ERR_IMPL;
+       return lttctl_errmap[errcode].message;
+}
+
+
+char *lttctl_errstr(void)
+{
+       return lttctl_strerror(lttctl_errno);
+}
+
+void lttctl_perror(const char *s)
+{
+       if (s)
+               fputs(s, stderr);
+       else
+               fputs("ERROR", stderr);
+       if (lttctl_errno)
+               fprintf(stderr, ": %s", lttctl_errstr());
+       if (errno)
+               fprintf(stderr, ": %s", strerror(errno));
+       fputc('\n', stderr);
+}
+
+/* public interface */
+
+/*
+ * Create and initialise an lttctl handle.
+ */
+struct lttctl_handle *lttctl_create_handle(void)
+{
+       int status;
+       struct lttctl_handle *h;
+
+       h = (struct lttctl_handle *)malloc(sizeof(struct lttctl_handle));
+       if (h == NULL) {
+               lttctl_errno = LTTCTL_ERR_HANDLE;
+               lttctl_perror("Create handle");
+               goto alloc_error;
+       }
+       
+       memset(h, 0, sizeof(struct lttctl_handle));
+       
+  h->fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_LTT);
+        
+       if (h->fd == -1) {
+               lttctl_errno = LTTCTL_ERR_SOCKET;
+               lttctl_perror("Create handle");
+               goto socket_error;
+       }
+       memset(&h->local, 0, sizeof(struct sockaddr_nl));
+       h->local.nl_family = AF_NETLINK;
+       h->local.nl_pid = getpid();
+       h->local.nl_groups = 0;
+       status = bind(h->fd, (struct sockaddr *)&h->local, sizeof(h->local));
+       if (status == -1) {
+               lttctl_errno = LTTCTL_ERR_BIND;
+               lttctl_perror("Create handle");
+               goto bind_error;
+       }
+       memset(&h->peer, 0, sizeof(struct sockaddr_nl));
+       h->peer.nl_family = AF_NETLINK;
+       h->peer.nl_pid = 0;
+       h->peer.nl_groups = 0;
+       return h;
+       
+       /* Error condition */
+bind_error:
+socket_error:
+               close(h->fd);
+alloc_error:
+               free(h);
+       return NULL;
+}
+
+/*
+ * No error condition is checked here at this stage, but it may happen
+ * if/when reliable messaging is implemented.
+ */
+int lttctl_destroy_handle(struct lttctl_handle *h)
+{
+       if (h) {
+               close(h->fd);
+               free(h);
+       }
+       return 0;
+}
+
+
+int lttctl_create_trace(const struct lttctl_handle *h,
+               char *name, enum trace_mode mode, unsigned subbuf_size, unsigned n_subbufs)
+{
+       int err;
+       
+       struct {
+               struct nlmsghdr nlh;
+               lttctl_peer_msg_t       msg;
+       } req;
+       struct {
+               struct nlmsghdr nlh;
+               struct nlmsgerr nlerr;
+               lttctl_peer_msg_t       msg;
+       } ack;
+
+       memset(&req, 0, sizeof(req));
+       req.nlh.nlmsg_len = NLMSG_LENGTH(sizeof(lttctl_peer_msg_t));
+       req.nlh.nlmsg_flags = NLM_F_REQUEST|NLM_F_ACK;
+       req.nlh.nlmsg_type = LTTCTLM_CONTROL;
+       req.nlh.nlmsg_pid = h->local.nl_pid;
+       req.nlh.nlmsg_seq = 0;
+
+       strncpy(req.msg.trace_name, name, NAME_MAX);
+       req.msg.op = OP_CREATE;
+       req.msg.args.new_trace.mode = mode;
+       req.msg.args.new_trace.subbuf_size = subbuf_size;
+       req.msg.args.new_trace.n_subbufs = n_subbufs;
+
+       err = lttctl_netlink_sendto(h, (void *)&req, req.nlh.nlmsg_len);
+       if(err < 0) goto senderr;
+
+       err = lttctl_netlink_recvfrom(h, (void*)&ack, sizeof(ack), 0);
+       if(err < 0) goto senderr;
+
+       err = ack.nlerr.error;
+       if(err != 0) {
+               errno = err;
+               lttctl_perror("Create Trace Error");
+               return err;
+       }
+
+       return 0;
+
+senderr:
+       lttctl_perror("Create Trace Error");
+  err = EPERM;
+       return err;
+}
+
+int lttctl_destroy_trace(const struct lttctl_handle *h,
+               char *name)
+{
+       struct {
+               struct nlmsghdr nlh;
+               lttctl_peer_msg_t       msg;
+       } req;
+       struct {
+               struct nlmsghdr nlh;
+               struct nlmsgerr nlerr;
+               lttctl_peer_msg_t       msg;
+       } ack;
+       int err;
+
+       memset(&req, 0, sizeof(req));
+       req.nlh.nlmsg_len = NLMSG_LENGTH(sizeof(lttctl_peer_msg_t));
+       req.nlh.nlmsg_flags = NLM_F_REQUEST;
+       req.nlh.nlmsg_type = LTTCTLM_CONTROL;
+       req.nlh.nlmsg_pid = h->local.nl_pid;
+
+       strncpy(req.msg.trace_name, name, NAME_MAX);
+       req.msg.op = OP_DESTROY;
+
+       err = lttctl_netlink_sendto(h, (void *)&req, req.nlh.nlmsg_len);
+       if(err < 0) goto senderr;
+
+       err = lttctl_netlink_recvfrom(h, (void*)&ack, sizeof(ack), 0);
+       if(err < 0) goto senderr;
+
+       err = ack.nlerr.error;
+       if(err != 0) {
+               errno = err;
+               lttctl_perror("Destroy Trace Channels Error");
+               return err;
+       }
+
+       return 0;
+
+senderr:
+       lttctl_perror("Destroy Trace Channels Error");
+  err = EPERM;
+       return err;
+
+}
+
+int lttctl_start(const struct lttctl_handle *h,
+               char *name)
+{
+       struct {
+               struct nlmsghdr nlh;
+               lttctl_peer_msg_t       msg;
+       } req;
+       struct {
+               struct nlmsghdr nlh;
+               struct nlmsgerr nlerr;
+               lttctl_peer_msg_t       msg;
+       } ack;
+
+       int err;
+
+       memset(&req, 0, sizeof(req));
+       req.nlh.nlmsg_len = NLMSG_LENGTH(sizeof(lttctl_peer_msg_t));
+       req.nlh.nlmsg_flags = NLM_F_REQUEST;
+       req.nlh.nlmsg_type = LTTCTLM_CONTROL;
+       req.nlh.nlmsg_pid = h->local.nl_pid;
+
+       strncpy(req.msg.trace_name, name, NAME_MAX);
+       req.msg.op = OP_START;
+
+       err = lttctl_netlink_sendto(h, (void *)&req, req.nlh.nlmsg_len);
+       if(err < 0) goto senderr;
+
+       err = lttctl_netlink_recvfrom(h, (void*)&ack, sizeof(ack), 0);
+       if(err < 0) goto senderr;
+
+       err = ack.nlerr.error;
+       if(err != 0) {
+               errno = err;
+               lttctl_perror("Start Trace Error");
+               return err;
+       }
+
+       return 0;
+
+senderr:
+  err = EPERM;
+       lttctl_perror("Start Trace Error");
+       return err;
+
+}
+
+int lttctl_stop(const struct lttctl_handle *h,
+               char *name)
+{
+       struct {
+               struct nlmsghdr nlh;
+               lttctl_peer_msg_t       msg;
+       } req;
+       struct {
+               struct nlmsghdr nlh;
+               struct nlmsgerr nlerr;
+               lttctl_peer_msg_t       msg;
+       } ack;
+       int err;
+
+       memset(&req, 0, sizeof(req));
+       req.nlh.nlmsg_len = NLMSG_LENGTH(sizeof(lttctl_peer_msg_t));
+       req.nlh.nlmsg_flags = NLM_F_REQUEST;
+       req.nlh.nlmsg_type = LTTCTLM_CONTROL;
+       req.nlh.nlmsg_pid = h->local.nl_pid;
+
+       strncpy(req.msg.trace_name, name, NAME_MAX);
+       req.msg.op = OP_STOP;
+
+       err = lttctl_netlink_sendto(h, (void *)&req, req.nlh.nlmsg_len);
+       if(err < 0) goto senderr;
+
+       err = lttctl_netlink_recvfrom(h, (void*)&ack, sizeof(ack), 0);
+       if(err < 0) goto senderr;
+
+       err = ack.nlerr.error;
+       if(err != 0) {
+               errno = err;
+               lttctl_perror("Stop Trace Error");
+               return err;
+       }
+
+       return 0;
+
+senderr:
+  err = EPERM;
+       lttctl_perror("Stop Trace Error");
+       return err;
+}
+
diff --git a/ltt-control/liblttctl/lttctl.h b/ltt-control/liblttctl/lttctl.h
new file mode 100644 (file)
index 0000000..cc028a5
--- /dev/null
@@ -0,0 +1,91 @@
+/* libltt header file
+ *
+ * Copyright 2005-
+ *     Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
+ *
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ *
+ * Inspired from iptables, by James Morris <jmorris@intercode.com.au>.
+ * 
+ */
+
+#ifndef _LIBLTT_H
+#define _LIBLTT_H
+
+#include <linux/limits.h>
+#include <asm/types.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+
+#ifndef NETLINK_LTT
+#define NETLINK_LTT 31
+#endif
+
+
+enum trace_op {
+       OP_CREATE,
+       OP_DESTROY,
+       OP_START,
+       OP_STOP,
+       OP_NONE
+};
+
+enum trace_mode {
+       LTT_TRACE_NORMAL,
+       LTT_TRACE_FLIGHT
+};
+
+typedef struct lttctl_peer_msg {
+       char trace_name[NAME_MAX];
+       enum trace_op op;
+       union {
+    struct {
+      enum trace_mode mode;
+      unsigned subbuf_size;
+      unsigned n_subbufs;
+    } new_trace;
+       } args;
+} lttctl_peer_msg_t;
+
+
+struct lttctl_handle
+{
+  int fd;
+  //u_int8_t blocking;
+  struct sockaddr_nl local;
+  struct sockaddr_nl peer;
+};
+
+typedef struct lttctl_resp_msg {
+       int err;
+} lttctl_resp_msg_t;
+
+struct lttctl_handle *lttctl_create_handle(void);
+
+int lttctl_destroy_handle(struct lttctl_handle *h);
+
+
+int lttctl_create_trace(const struct lttctl_handle *h,
+               char *name, enum trace_mode mode, unsigned subbuf_size, unsigned n_subbufs);
+
+int lttctl_destroy_trace(const struct lttctl_handle *handle, char *name);
+
+int lttctl_start(const struct lttctl_handle *handle, char *name);
+
+int lttctl_stop(const struct lttctl_handle *handle, char *name);
+
+#define LTTCTLM_BASE   0x10
+#define LTTCTLM_CONTROL        (LTTCTLM_BASE + 1)      /* LTT control message */
+
+
+#endif //_LIBLTT_H
diff --git a/ltt-control/lttctl/Makefile.am b/ltt-control/lttctl/Makefile.am
new file mode 100644 (file)
index 0000000..6a5180d
--- /dev/null
@@ -0,0 +1,11 @@
+## Process this file with automake to produce Makefile.in
+
+AM_CFLAGS = -DPACKAGE_DATA_DIR=\""$(datadir)"\" -DPACKAGE_BIN_DIR=\""$(bindir)"\"
+
+bin_PROGRAMS = lttctl
+
+lttctl_SOURCES = \
+       lttctl.c
+lttctl_DEPENDENCIES = ../liblttctl/liblttctl.la
+lttctl_LDADD = $(lttctl_DEPENDENCIES)
+
diff --git a/ltt-control/lttctl/lttctl.c b/ltt-control/lttctl/lttctl.c
new file mode 100644 (file)
index 0000000..11483c9
--- /dev/null
@@ -0,0 +1,505 @@
+/* lttctl
+ *
+ * Linux Trace Toolkit Control
+ *
+ * Small program that controls LTT through libltt.
+ *
+ * Copyright 2005 -
+ *     Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <liblttctl/lttctl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <signal.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+
+/* Buffer for file copy : 4k seems optimal. */
+#define BUF_SIZE 4096
+
+enum trace_ctl_op {
+  CTL_OP_CREATE_START,
+       CTL_OP_CREATE,
+       CTL_OP_DESTROY,
+  CTL_OP_STOP_DESTROY,
+       CTL_OP_START,
+       CTL_OP_STOP,
+       CTL_OP_DAEMON,
+       CTL_OP_DESCRIPTION,
+       CTL_OP_NONE
+};
+
+static char *trace_name = NULL;
+static char *mode_name = NULL;
+static unsigned subbuf_size = 0;
+static unsigned n_subbufs = 0;
+static unsigned append_trace = 0;
+static enum trace_mode mode = LTT_TRACE_NORMAL;
+static enum trace_ctl_op op = CTL_OP_NONE;
+static char *channel_root = NULL;
+static char *trace_root = NULL;
+static char *num_threads = "1";
+
+static int sigchld_received = 0;
+
+void sigchld_handler(int signo)
+{
+       printf("signal %d received\n", signo);
+       sigchld_received = 1;
+}
+
+
+/* Args :
+ *
+ */
+void show_arguments(void)
+{
+       printf("Please use the following arguments :\n");
+       printf("\n");
+       printf("-n name       Name of the trace.\n");
+       printf("-b            Create trace channels and start tracing (no daemon).\n");
+       printf("-c            Create trace channels.\n");
+       printf("-m mode       Normal or flight recorder mode.\n");
+       printf("              Mode values : normal (default) or flight.\n");
+       printf("-r            Destroy trace channels.\n");
+       printf("-R            Stop tracing and destroy trace channels.\n");
+       printf("-s            Start tracing.\n");
+       //printf("              Note : will automatically create a normal trace if "
+       //                                                                                      "none exists.\n");
+       printf("-q            Stop tracing.\n");
+       printf("-d            Create trace, spawn a lttd daemon, start tracing.\n");
+       printf("              (optionnaly, you can set LTT_DAEMON\n");
+       printf("              and the LTT_FACILITIES env. vars.)\n");
+       printf("-t            Trace root path. (ex. /root/traces/example_trace)\n");
+       printf("-l            LTT channels root path. (ex. /mnt/relayfs/ltt)\n");
+       printf("-z            Size of the subbuffers (will be rounded to next page size)\n");
+       printf("-x            Number of subbuffers\n");
+       printf("-e            Get XML facilities description\n");
+       printf("-a            Append to trace\n");
+       printf("-N            Number of lttd threads\n");
+       printf("\n");
+}
+
+
+/* parse_arguments
+ *
+ * Parses the command line arguments.
+ *
+ * Returns -1 if the arguments were correct, but doesn't ask for program
+ * continuation. Returns EINVAL if the arguments are incorrect, or 0 if OK.
+ */
+int parse_arguments(int argc, char **argv)
+{
+       int ret = 0;
+       int argn = 1;
+       
+       if(argc == 2) {
+               if(strcmp(argv[1], "-h") == 0) {
+                       return -1;
+               }
+       }
+
+       while(argn < argc) {
+
+               switch(argv[argn][0]) {
+                       case '-':
+                               switch(argv[argn][1]) {
+                                       case 'n':
+                                               if(argn+1 < argc) {
+                                                       trace_name = argv[argn+1];
+                                                       argn++;
+                                               } else {
+                                                       printf("Specify a trace name after -n.\n");
+                                                       printf("\n");
+                                                       ret = EINVAL;
+                                               }
+
+                                               break;
+          case 'b':
+            op = CTL_OP_CREATE_START;
+                                               break;
+                                       case 'c':
+                                               op = CTL_OP_CREATE;
+            break;
+                                       case 'm':
+                                               if(argn+1 < argc) {
+                                                       mode_name = argv[argn+1];
+                                                       argn++;
+                                                       if(strcmp(mode_name, "normal") == 0)
+                                                               mode = LTT_TRACE_NORMAL;
+                                                       else if(strcmp(mode_name, "flight") == 0)
+                                                               mode = LTT_TRACE_FLIGHT;
+                                                       else {
+                                                               printf("Invalid mode '%s'.\n", argv[argn]);
+                                                               printf("\n");
+                                                               ret = EINVAL;
+                                                       }
+                                               } else {
+                                                               printf("Specify a mode after -m.\n");
+                                                               printf("\n");
+                                                               ret = EINVAL;
+                                               }
+                                               break;
+                                       case 'r':
+                                               op = CTL_OP_DESTROY;
+                                               break;
+                                       case 'R':
+                                               op = CTL_OP_STOP_DESTROY;
+                                               break;
+                                       case 's':
+                                               op = CTL_OP_START;
+                                               break;
+                                       case 'q':
+                                               op = CTL_OP_STOP;
+                                               break;
+                                       case 'z':
+                                               if(argn+1 < argc) {
+                                                       subbuf_size = (unsigned)atoi(argv[argn+1]);
+                                                       argn++;
+                                               } else {
+                                                       printf("Specify a number of subbuffers after -z.\n");
+                                                       printf("\n");
+                                                       ret = EINVAL;
+                                               }
+                                               break;
+                                       case 'x':
+                                               if(argn+1 < argc) {
+                                                       n_subbufs = (unsigned)atoi(argv[argn+1]);
+                                                       argn++;
+                                               } else {
+                                                       printf("Specify a subbuffer size after -x.\n");
+                                                       printf("\n");
+                                                       ret = EINVAL;
+                                               }
+                                               break;
+                                       case 'd':
+                                               op = CTL_OP_DAEMON;
+                                               break;
+          case 'e':
+            op = CTL_OP_DESCRIPTION;
+            break;
+                                       case 't':
+                                               if(argn+1 < argc) {
+                                                       trace_root = argv[argn+1];
+                                                       argn++;
+                                               } else {
+                                                       printf("Specify a trace root path after -t.\n");
+                                                       printf("\n");
+                                                       ret = EINVAL;
+                                               }
+                                               break;
+                                       case 'l':
+                                               if(argn+1 < argc) {
+                                                       channel_root = argv[argn+1];
+                                                       argn++;
+                                               } else {
+                                                       printf("Specify a channel root path after -l.\n");
+                                                       printf("\n");
+                                                       ret = EINVAL;
+                                               }
+                                               break;
+          case 'a':
+            append_trace = 1;
+            break;
+          case 'N':
+                                               if(argn+1 < argc) {
+                                                       num_threads = argv[argn+1];
+                                                       argn++;
+                                               }
+                                               break;
+                                       default:
+                                               printf("Invalid argument '%s'.\n", argv[argn]);
+                                               printf("\n");
+                                               ret = EINVAL;
+                               }
+                               break;
+                       default:
+                               printf("Invalid argument '%s'.\n", argv[argn]);
+                               printf("\n");
+                               ret = EINVAL;
+               }
+               argn++;
+       }
+       
+       if(op != CTL_OP_DESCRIPTION && trace_name == NULL) {
+               printf("Please specify a trace name.\n");
+               printf("\n");
+               ret = EINVAL;
+       }
+
+       if(op == CTL_OP_NONE) {
+               printf("Please specify an operation.\n");
+               printf("\n");
+               ret = EINVAL;
+       }
+
+       if(op == CTL_OP_DAEMON) {
+               if(trace_root == NULL) {
+                       printf("Please specify -t trace_root_path with the -d option.\n");
+                       printf("\n");
+                       ret = EINVAL;
+               }
+               if(channel_root == NULL) {
+                       printf("Please specify -l ltt_root_path with the -d option.\n");
+                       printf("\n");
+                       ret = EINVAL;
+               }
+       }
+
+  if(op == CTL_OP_DESCRIPTION) {
+    if(trace_root == NULL) {
+                       printf("Please specify -t trace_root_path with the -e option.\n");
+                       printf("\n");
+                       ret = EINVAL;
+    }
+  }
+
+       return ret;
+}
+
+void show_info(void)
+{
+       printf("Linux Trace Toolkit Trace Control\n");
+       printf("\n");
+  if(trace_name != NULL) {
+       printf("Controlling trace : %s\n", trace_name);
+       printf("\n");
+  }
+}
+
+int create_eventdefs(void)
+{
+  int ret = 0;
+  char eventdefs_path[PATH_MAX];
+  char eventdefs_file[PATH_MAX];
+  char facilities_file[PATH_MAX];
+  char read_buf[BUF_SIZE];
+  struct dirent *entry;
+       char *facilities_path = getenv("LTT_FACILITIES");
+       if(facilities_path == NULL) facilities_path =
+          PACKAGE_DATA_DIR "/" PACKAGE "/facilities";
+
+  ret = mkdir(trace_root, S_IRWXU|S_IRWXG|S_IRWXO);
+  if(ret == -1 && errno != EEXIST) {
+    ret = errno;
+    perror("Cannot create trace_root directory");
+    printf("trace_root is %s\n", trace_root);
+    goto error;
+  }
+  ret = 0;
+  
+  size_t trace_root_len = strlen(trace_root);
+  strncpy(eventdefs_path, trace_root, PATH_MAX);
+  strncat(eventdefs_path, "/eventdefs/", PATH_MAX - trace_root_len);
+  size_t eventdefs_path_len = strlen(eventdefs_path);
+  ret = mkdir(eventdefs_path, S_IRWXU|S_IRWXG|S_IRWXO);
+  if(ret == -1 && (!append_trace || errno != EEXIST)) {
+    ret = errno;
+    perror("Cannot create eventdefs directory");
+    goto error;
+  }
+  ret = 0;
+  
+  DIR *facilities_dir = opendir(facilities_path);
+  
+  if(facilities_dir == NULL) {
+    perror("Cannot open facilities directory");
+    ret = EEXIST;
+    goto error;
+  }
+
+  while((entry = readdir(facilities_dir)) != NULL) {
+    if(entry->d_name[0] == '.') continue;
+    
+    printf("Appending facility file %s\n", entry->d_name);
+    strncpy(eventdefs_file, eventdefs_path, PATH_MAX);
+    strncat(eventdefs_file, entry->d_name, PATH_MAX - eventdefs_path_len);
+    /* Append to the file */
+    FILE *dest = fopen(eventdefs_file, "a");
+    if(!dest) {
+      perror("Cannot create eventdefs file");
+      continue;
+    }
+    strncpy(facilities_file, facilities_path, PATH_MAX);
+    size_t facilities_dir_len = strlen(facilities_path);
+    strncat(facilities_file, "/", PATH_MAX - facilities_dir_len);
+    strncat(facilities_file, entry->d_name, PATH_MAX - facilities_dir_len-1);
+    FILE *src = fopen(facilities_file, "r");
+    if(!src) {
+      ret = errno;
+      perror("Cannot open eventdefs file for reading");
+      goto close_dest;
+    }
+
+    do {
+      size_t read_size, write_size;
+      read_size = fread(read_buf, sizeof(char), BUF_SIZE, src);
+      if(ferror(src)) {
+        ret = errno;
+        perror("Cannot read eventdefs file");
+        goto close_src;
+      }
+      write_size = fwrite(read_buf, sizeof(char), read_size, dest);
+      if(ferror(dest)) {
+        ret = errno;
+        perror("Cannot write eventdefs file");
+        goto close_src;
+      }
+    } while(!feof(src));
+
+    /* Add spacing between facilities */
+    fwrite("\n", 1, 1, dest);
+    
+close_src:
+    fclose(src);
+close_dest:
+    fclose(dest);
+  }
+
+  closedir(facilities_dir);
+
+error:
+  return ret;
+
+}
+
+
+int lttctl_daemon(struct lttctl_handle *handle, char *trace_name)
+{
+       char channel_path[PATH_MAX] = "";
+       pid_t pid;
+       int ret;
+       char *lttd_path = getenv("LTT_DAEMON");
+       struct sigaction act;
+
+       if(lttd_path == NULL) lttd_path = 
+    PACKAGE_BIN_DIR "/lttd";
+       
+       strcat(channel_path, channel_root);
+       strcat(channel_path, "/");
+       strcat(channel_path, trace_name);
+
+       
+       ret = lttctl_create_trace(handle, trace_name, mode, subbuf_size, n_subbufs);
+       if(ret != 0) goto create_error;
+
+       act.sa_handler = sigchld_handler;
+       sigemptyset(&(act.sa_mask));
+       sigaddset(&(act.sa_mask), SIGCHLD);
+       sigaction(SIGCHLD, &act, NULL);
+       
+       pid = fork();
+
+       if(pid > 0) {
+    int status;
+               /* parent */
+               while(!(sigchld_received)) pause();
+
+    waitpid(pid, &status, 0);
+    ret = 0;
+    if(WIFEXITED(status))
+      ret = WEXITSTATUS(status);
+    if(ret) goto start_error;
+
+               printf("Creating supplementary trace files\n");
+    ret = create_eventdefs();
+    if(ret) goto start_error;
+
+       } else if(pid == 0) {
+               /* child */
+    int ret;
+    if(append_trace) 
+               ret =   execlp(lttd_path, lttd_path, "-t", trace_root, "-c",
+                       channel_path, "-d", "-a", "-N", num_threads, NULL);
+    else
+               ret =   execlp(lttd_path, lttd_path, "-t", trace_root, "-c",
+                       channel_path, "-d", "-N", num_threads, NULL);
+               if(ret) {
+      ret = errno;
+                       perror("Error in executing the lttd daemon");
+                       exit(ret);
+               }
+       } else {
+               /* error */
+               perror("Error in forking for lttd daemon");
+       }
+
+       ret = lttctl_start(handle, trace_name);
+       if(ret != 0) goto start_error;
+
+       return 0;
+
+       /* error handling */
+start_error:
+  printf("Trace start error\n");
+       ret |= lttctl_destroy_trace(handle, trace_name);
+create_error:
+       return ret;
+}
+
+int main(int argc, char ** argv)
+{
+       int ret;
+       struct lttctl_handle *handle;
+       
+       ret = parse_arguments(argc, argv);
+
+       if(ret != 0) show_arguments();
+       if(ret == EINVAL) return EINVAL;
+       if(ret == -1) return 0;
+
+       show_info();
+       
+       handle = lttctl_create_handle();
+       
+       if(handle == NULL) return -1;
+       
+       switch(op) {
+    case CTL_OP_CREATE_START:
+                       ret = lttctl_create_trace(handle, trace_name, mode, subbuf_size,
+                                                                                                                               n_subbufs);
+      if(!ret)
+        ret = lttctl_start(handle, trace_name);
+      break;
+       case CTL_OP_CREATE:
+                       ret = lttctl_create_trace(handle, trace_name, mode, subbuf_size,
+                                                                                                                               n_subbufs);
+      break;
+               case CTL_OP_DESTROY:
+                       ret = lttctl_destroy_trace(handle, trace_name);
+                       break;
+               case CTL_OP_STOP_DESTROY:
+                       ret = lttctl_stop(handle, trace_name);
+      if(!ret)
+                       ret = lttctl_destroy_trace(handle, trace_name);
+                       break;
+               case CTL_OP_START:
+                       ret = lttctl_start(handle, trace_name);
+                       break;
+               case CTL_OP_STOP:
+                       ret = lttctl_stop(handle, trace_name);
+                       break;
+               case CTL_OP_DAEMON:
+                       ret = lttctl_daemon(handle, trace_name);
+                       break;
+    case CTL_OP_DESCRIPTION:
+      ret = create_eventdefs();
+      break;
+               case CTL_OP_NONE:
+                       break;
+       }
+
+       ret |= lttctl_destroy_handle(handle);
+       
+       return ret;
+}
diff --git a/ltt-control/lttd/Makefile.am b/ltt-control/lttd/Makefile.am
new file mode 100644 (file)
index 0000000..bb860bc
--- /dev/null
@@ -0,0 +1,8 @@
+# Empty TraceDaemon Makefile.am. Insert a real one here.
+
+LIBS += $(THREAD_LIBS)
+
+bin_PROGRAMS = lttd
+
+lttd_SOURCES = lttd.c
+
diff --git a/ltt-control/lttd/lttd.c b/ltt-control/lttd/lttd.c
new file mode 100644 (file)
index 0000000..2601d80
--- /dev/null
@@ -0,0 +1,665 @@
+/* lttd
+ *
+ * Linux Trace Toolkit Daemon
+ *
+ * This is a simple daemon that reads a few relayfs channels and save them in a
+ * trace.
+ *
+ *
+ * Copyright 2005 -
+ *     Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _REENTRANT
+#define _GNU_SOURCE
+#include <features.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/poll.h>
+#include <sys/mman.h>
+#include <signal.h>
+#include <pthread.h>
+
+/* Relayfs IOCTL */
+#include <asm/ioctl.h>
+#include <asm/types.h>
+
+/* Get the next sub buffer that can be read. */
+#define RELAYFS_GET_SUBBUF        _IOR(0xF4, 0x00,__u32)
+/* Release the oldest reserved (by "get") sub buffer. */
+#define RELAYFS_PUT_SUBBUF        _IOW(0xF4, 0x01,__u32)
+/* returns the number of sub buffers in the per cpu channel. */
+#define RELAYFS_GET_N_SUBBUFS     _IOR(0xF4, 0x02,__u32)
+/* returns the size of the sub buffers. */
+#define RELAYFS_GET_SUBBUF_SIZE   _IOR(0xF4, 0x03,__u32)
+
+
+
+enum {
+       GET_SUBBUF,
+       PUT_SUBBUF,
+       GET_N_BUBBUFS,
+       GET_SUBBUF_SIZE
+};
+
+struct fd_pair {
+       int channel;
+       int trace;
+       unsigned int n_subbufs;
+       unsigned int subbuf_size;
+       void *mmap;
+       pthread_mutex_t mutex;
+};
+
+struct channel_trace_fd {
+       struct fd_pair *pair;
+       int num_pairs;
+};
+
+static char *trace_name = NULL;
+static char *channel_name = NULL;
+static int     daemon_mode = 0;
+static int     append_mode = 0;
+static unsigned long num_threads = 1;
+volatile static int    quit_program = 0;       /* For signal handler */
+
+/* Args :
+ *
+ * -t directory                Directory name of the trace to write to. Will be created.
+ * -c directory                Root directory of the relayfs trace channels.
+ * -d                          Run in background (daemon).
+ * -a                                                  Trace append mode.
+ * -s                                                  Send SIGUSR1 to parent when ready for IO.
+ */
+void show_arguments(void)
+{
+       printf("Please use the following arguments :\n");
+       printf("\n");
+       printf("-t directory  Directory name of the trace to write to.\n"
+                                "              It will be created.\n");
+       printf("-c directory  Root directory of the relayfs trace channels.\n");
+       printf("-d            Run in background (daemon).\n");
+       printf("-a            Append to an possibly existing trace.\n");
+       printf("-N            Number of threads to start.\n");
+       printf("\n");
+}
+
+
+/* parse_arguments
+ *
+ * Parses the command line arguments.
+ *
+ * Returns 1 if the arguments were correct, but doesn't ask for program
+ * continuation. Returns -1 if the arguments are incorrect, or 0 if OK.
+ */
+int parse_arguments(int argc, char **argv)
+{
+       int ret = 0;
+       int argn = 1;
+       
+       if(argc == 2) {
+               if(strcmp(argv[1], "-h") == 0) {
+                       return 1;
+               }
+       }
+
+       while(argn < argc) {
+
+               switch(argv[argn][0]) {
+                       case '-':
+                               switch(argv[argn][1]) {
+                                       case 't':
+                                               if(argn+1 < argc) {
+                                                       trace_name = argv[argn+1];
+                                                       argn++;
+                                               }
+                                               break;
+                                       case 'c':
+                                               if(argn+1 < argc) {
+                                                       channel_name = argv[argn+1];
+                                                       argn++;
+                                               }
+                                               break;
+                                       case 'd':
+                                               daemon_mode = 1;
+                                               break;
+                                       case 'a':
+                                               append_mode = 1;
+                                               break;
+                                       case 'N':
+                                               if(argn+1 < argc) {
+                                                       num_threads = strtoul(argv[argn+1], NULL, 0);
+                                                       argn++;
+                                               }
+                                               break;
+                                       default:
+                                               printf("Invalid argument '%s'.\n", argv[argn]);
+                                               printf("\n");
+                                               ret = -1;
+                               }
+                               break;
+                       default:
+                               printf("Invalid argument '%s'.\n", argv[argn]);
+                               printf("\n");
+                               ret = -1;
+               }
+               argn++;
+       }
+       
+       if(trace_name == NULL) {
+               printf("Please specify a trace name.\n");
+               printf("\n");
+               ret = -1;
+       }
+       
+       if(channel_name == NULL) {
+               printf("Please specify a channel name.\n");
+               printf("\n");
+               ret = -1;
+       }
+       
+       return ret;
+}
+
+void show_info(void)
+{
+       printf("Linux Trace Toolkit Trace Daemon\n");
+       printf("\n");
+       printf("Reading from relayfs directory : %s\n", channel_name);
+       printf("Writing to trace directory : %s\n", trace_name);
+       printf("\n");
+}
+
+
+/* signal handling */
+
+static void handler(int signo)
+{
+       printf("Signal %d received : exiting cleanly\n", signo);
+       quit_program = 1;
+}
+
+
+
+int open_channel_trace_pairs(char *subchannel_name, char *subtrace_name,
+               struct channel_trace_fd *fd_pairs)
+{
+       DIR *channel_dir = opendir(subchannel_name);
+       struct dirent *entry;
+       struct stat stat_buf;
+       int ret;
+       char path_channel[PATH_MAX];
+       int path_channel_len;
+       char *path_channel_ptr;
+       char path_trace[PATH_MAX];
+       int path_trace_len;
+       char *path_trace_ptr;
+  int open_ret = 0;
+
+       if(channel_dir == NULL) {
+               perror(subchannel_name);
+               open_ret = ENOENT;
+    goto end;
+       }
+
+       printf("Creating trace subdirectory %s\n", subtrace_name);
+       ret = mkdir(subtrace_name, S_IRWXU|S_IRWXG|S_IRWXO);
+       if(ret == -1) {
+               if(errno != EEXIST) {
+                       perror(subtrace_name);
+      open_ret = -1;
+                       goto end;
+               }
+       }
+
+       strncpy(path_channel, subchannel_name, PATH_MAX-1);
+       path_channel_len = strlen(path_channel);
+       path_channel[path_channel_len] = '/';
+       path_channel_len++;
+       path_channel_ptr = path_channel + path_channel_len;
+
+       strncpy(path_trace, subtrace_name, PATH_MAX-1);
+       path_trace_len = strlen(path_trace);
+       path_trace[path_trace_len] = '/';
+       path_trace_len++;
+       path_trace_ptr = path_trace + path_trace_len;
+       
+       while((entry = readdir(channel_dir)) != NULL) {
+
+               if(entry->d_name[0] == '.') continue;
+               
+               strncpy(path_channel_ptr, entry->d_name, PATH_MAX - path_channel_len);
+               strncpy(path_trace_ptr, entry->d_name, PATH_MAX - path_trace_len);
+               
+               ret = stat(path_channel, &stat_buf);
+               if(ret == -1) {
+                       perror(path_channel);
+                       continue;
+               }
+               
+               printf("Channel file : %s\n", path_channel);
+               
+               if(S_ISDIR(stat_buf.st_mode)) {
+
+                       printf("Entering channel subdirectory...\n");
+                       ret = open_channel_trace_pairs(path_channel, path_trace, fd_pairs);
+                       if(ret < 0) continue;
+               } else if(S_ISREG(stat_buf.st_mode)) {
+                       printf("Opening file.\n");
+                       
+                       fd_pairs->pair = realloc(fd_pairs->pair,
+                                       ++fd_pairs->num_pairs * sizeof(struct fd_pair));
+
+                       /* Open the channel in read mode */
+                       fd_pairs->pair[fd_pairs->num_pairs-1].channel = 
+                               open(path_channel, O_RDONLY | O_NONBLOCK);
+                       if(fd_pairs->pair[fd_pairs->num_pairs-1].channel == -1) {
+                               perror(path_channel);
+                               fd_pairs->num_pairs--;
+                               continue;
+                       }
+                       /* Open the trace in write mode, only append if append_mode */
+                       ret = stat(path_trace, &stat_buf);
+                       if(ret == 0) {
+                               if(append_mode) {
+                                       printf("Appending to file %s as requested\n", path_trace);
+
+                                       fd_pairs->pair[fd_pairs->num_pairs-1].trace = 
+                                               open(path_trace, O_WRONLY|O_APPEND,
+                                                               S_IRWXU|S_IRWXG|S_IRWXO);
+
+                                       if(fd_pairs->pair[fd_pairs->num_pairs-1].trace == -1) {
+                                               perror(path_trace);
+                                       }
+                               } else {
+                                       printf("File %s exists, cannot open. Try append mode.\n", path_trace);
+                                       open_ret = -1;
+          goto end;
+                               }
+                       } else {
+                               if(errno == ENOENT) {
+                                       fd_pairs->pair[fd_pairs->num_pairs-1].trace = 
+                                               open(path_trace, O_WRONLY|O_CREAT|O_EXCL,
+                                                               S_IRWXU|S_IRWXG|S_IRWXO);
+                                       if(fd_pairs->pair[fd_pairs->num_pairs-1].trace == -1) {
+                                               perror(path_trace);
+                                       }
+                               }
+                       }
+               }
+       }
+       
+end:
+       closedir(channel_dir);
+
+       return open_ret;
+}
+
+
+int read_subbuffer(struct fd_pair *pair)
+{
+       unsigned int    consumed_old;
+       int err, ret=0;
+
+
+       err = ioctl(pair->channel, RELAYFS_GET_SUBBUF, 
+                                                               &consumed_old);
+       printf("cookie : %u\n", consumed_old);
+       if(err != 0) {
+               ret = errno;
+               perror("Reserving sub buffer failed (everything is normal)");
+               goto get_error;
+       }
+       
+       err = TEMP_FAILURE_RETRY(write(pair->trace,
+                               pair->mmap 
+                                       + (consumed_old & ((pair->n_subbufs * pair->subbuf_size)-1)),
+                               pair->subbuf_size));
+
+       if(err < 0) {
+               ret = errno;
+               perror("Error in writing to file");
+               goto write_error;
+       }
+#if 0
+       err = fsync(pair->trace);
+       if(err < 0) {
+               ret = errno;
+               perror("Error in writing to file");
+               goto write_error;
+       }
+#endif //0
+write_error:
+       err = ioctl(pair->channel, RELAYFS_PUT_SUBBUF, &consumed_old);
+       if(err != 0) {
+               ret = errno;
+               if(errno == -EFAULT) {
+                       perror("Error in unreserving sub buffer\n");
+               } else if(errno == -EIO) {
+                       perror("Reader has been pushed by the writer, last subbuffer corrupted.");
+                       /* FIXME : we may delete the last written buffer if we wish. */
+               }
+               goto get_error;
+       }
+
+get_error:
+       return ret;
+}
+
+
+
+int map_channels(struct channel_trace_fd *fd_pairs)
+{
+       int i,j;
+       int ret=0;
+
+       if(fd_pairs->num_pairs <= 0) {
+               printf("No channel to read\n");
+               goto end;
+       }
+       
+       /* Get the subbuf sizes and number */
+
+       for(i=0;i<fd_pairs->num_pairs;i++) {
+               struct fd_pair *pair = &fd_pairs->pair[i];
+
+               ret = ioctl(pair->channel, RELAYFS_GET_N_SUBBUFS, 
+                                                       &pair->n_subbufs);
+               if(ret != 0) {
+                       perror("Error in getting the number of subbuffers");
+                       goto end;
+               }
+               ret = ioctl(pair->channel, RELAYFS_GET_SUBBUF_SIZE, 
+                                                       &pair->subbuf_size);
+               if(ret != 0) {
+                       perror("Error in getting the size of the subbuffers");
+                       goto end;
+               }
+               ret = pthread_mutex_init(&pair->mutex, NULL);   /* Fast mutex */
+               if(ret != 0) {
+                       perror("Error in mutex init");
+                       goto end;
+               }
+       }
+
+       /* Mmap each FD */
+       for(i=0;i<fd_pairs->num_pairs;i++) {
+               struct fd_pair *pair = &fd_pairs->pair[i];
+
+               pair->mmap = mmap(0, pair->subbuf_size * pair->n_subbufs, PROT_READ,
+                               MAP_SHARED, pair->channel, 0);
+               if(pair->mmap == MAP_FAILED) {
+                       perror("Mmap error");
+                       goto munmap;
+               }
+       }
+
+       goto end; /* success */
+
+       /* Error handling */
+       /* munmap only the successfully mmapped indexes */
+munmap:
+               /* Munmap each FD */
+       for(j=0;j<i;j++) {
+               struct fd_pair *pair = &fd_pairs->pair[j];
+               int err_ret;
+
+               err_ret = munmap(pair->mmap, pair->subbuf_size * pair->n_subbufs);
+               if(err_ret != 0) {
+                       perror("Error in munmap");
+               }
+               ret |= err_ret;
+       }
+
+end:
+       return ret;
+
+
+}
+
+
+int unmap_channels(struct channel_trace_fd *fd_pairs)
+{
+       int j;
+       int ret=0;
+
+       /* Munmap each FD */
+       for(j=0;j<fd_pairs->num_pairs;j++) {
+               struct fd_pair *pair = &fd_pairs->pair[j];
+               int err_ret;
+
+               err_ret = munmap(pair->mmap, pair->subbuf_size * pair->n_subbufs);
+               if(err_ret != 0) {
+                       perror("Error in munmap");
+               }
+               ret |= err_ret;
+               err_ret = pthread_mutex_destroy(&pair->mutex);
+               if(err_ret != 0) {
+                       perror("Error in mutex destroy");
+               }
+               ret |= err_ret;
+       }
+
+       return ret;
+}
+
+
+/* read_channels
+ *
+ * Thread worker.
+ *
+ * Read the relayfs channels and write them in the paired tracefiles.
+ *
+ * @fd_pairs : paired channels and trace files.
+ *
+ * returns (void*)0 on success, (void*)-1 on error.
+ *
+ * Note that the high priority polled channels are consumed first. We then poll
+ * again to see if these channels are still in priority. Only when no
+ * high priority channel is left, we start reading low priority channels.
+ *
+ * Note that a channel is considered high priority when the buffer is almost
+ * full.
+ */
+
+void * read_channels(void *arg)
+{
+       struct pollfd *pollfd;
+       int i,j;
+       int num_rdy, num_hup;
+       int high_prio;
+       int ret = 0;
+       struct channel_trace_fd *fd_pairs = (struct channel_trace_fd *)arg;
+
+       /* Start polling the FD */
+       
+       pollfd = malloc(fd_pairs->num_pairs * sizeof(struct pollfd));
+
+       /* Note : index in pollfd is the same index as fd_pair->pair */
+       for(i=0;i<fd_pairs->num_pairs;i++) {
+               pollfd[i].fd = fd_pairs->pair[i].channel;
+               pollfd[i].events = POLLIN|POLLPRI;
+       }
+
+       while(1) {
+               high_prio = 0;
+               num_hup = 0; 
+#ifdef DEBUG
+               printf("Press a key for next poll...\n");
+               char buf[1];
+               read(STDIN_FILENO, &buf, 1);
+               printf("Next poll (polling %d fd) :\n", fd_pairs->num_pairs);
+#endif //DEBUG
+               
+               /* Have we received a signal ? */
+               if(quit_program) break;
+               
+               num_rdy = poll(pollfd, fd_pairs->num_pairs, -1);
+               if(num_rdy == -1) {
+                       perror("Poll error");
+                       goto free_fd;
+               }
+
+               printf("Data received\n");
+
+               for(i=0;i<fd_pairs->num_pairs;i++) {
+                       switch(pollfd[i].revents) {
+                               case POLLERR:
+                                       printf("Error returned in polling fd %d.\n", pollfd[i].fd);
+                                       num_hup++;
+                                       break;
+                               case POLLHUP:
+                                       printf("Polling fd %d tells it has hung up.\n", pollfd[i].fd);
+                                       num_hup++;
+                                       break;
+                               case POLLNVAL:
+                                       printf("Polling fd %d tells fd is not open.\n", pollfd[i].fd);
+                                       num_hup++;
+                                       break;
+                               case POLLPRI:
+                                       if(pthread_mutex_trylock(&fd_pairs->pair[i].mutex) == 0) {
+                                               printf("Urgent read on fd %d\n", pollfd[i].fd);
+                                               /* Take care of high priority channels first. */
+                                               high_prio = 1;
+                                               /* it's ok to have an unavailable subbuffer */
+                                               ret = read_subbuffer(&fd_pairs->pair[i]);
+                                               if(ret == -EAGAIN) ret = 0;
+
+                                               ret = pthread_mutex_unlock(&fd_pairs->pair[i].mutex);
+                                               if(ret)
+                                                       printf("Error in mutex unlock : %s\n", strerror(ret));
+                                       }
+                                       break;
+                       }
+               }
+               /* If every FD has hung up, we end the read loop here */
+               if(num_hup == fd_pairs->num_pairs) break;
+
+               if(!high_prio) {
+                       for(i=0;i<fd_pairs->num_pairs;i++) {
+                               switch(pollfd[i].revents) {
+                                       case POLLIN:
+                                               if(pthread_mutex_trylock(&fd_pairs->pair[i].mutex) == 0) {
+                                                       /* Take care of low priority channels. */
+                                                       printf("Normal read on fd %d\n", pollfd[i].fd);
+                                                       /* it's ok to have an unavailable subbuffer */
+                                                       ret = read_subbuffer(&fd_pairs->pair[i]);
+                                                       if(ret == -EAGAIN) ret = 0;
+
+                                                       ret = pthread_mutex_unlock(&fd_pairs->pair[i].mutex);
+                                                       if(ret)
+                                                               printf("Error in mutex unlock : %s\n", strerror(ret));
+                                               }
+                                               break;
+                               }
+                       }
+               }
+
+       }
+
+free_fd:
+       free(pollfd);
+
+end:
+       return (void*)ret;
+}
+
+
+void close_channel_trace_pairs(struct channel_trace_fd *fd_pairs)
+{
+       int i;
+       int ret;
+
+       for(i=0;i<fd_pairs->num_pairs;i++) {
+               ret = close(fd_pairs->pair[i].channel);
+               if(ret == -1) perror("Close error on channel");
+               ret = close(fd_pairs->pair[i].trace);
+               if(ret == -1) perror("Close error on trace");
+       }
+       free(fd_pairs->pair);
+}
+
+int main(int argc, char ** argv)
+{
+       int ret = 0;
+       struct channel_trace_fd fd_pairs = { NULL, 0 };
+       struct sigaction act;
+       pthread_t *tids;
+       unsigned int i;
+       void *tret;
+       
+       ret = parse_arguments(argc, argv);
+
+       if(ret != 0) show_arguments();
+       if(ret < 0) return EINVAL;
+       if(ret > 0) return 0;
+
+       show_info();
+
+       if(daemon_mode) {
+               ret = daemon(0, 0);
+    
+    if(ret == -1) {
+      perror("An error occured while daemonizing.");
+      exit(-1);
+    }
+  }
+
+       /* Connect the signal handlers */
+       act.sa_handler = handler;
+       act.sa_flags = 0;
+       sigemptyset(&(act.sa_mask));
+       sigaddset(&(act.sa_mask), SIGTERM);
+       sigaddset(&(act.sa_mask), SIGQUIT);
+       sigaddset(&(act.sa_mask), SIGINT);
+       sigaction(SIGTERM, &act, NULL);
+       sigaction(SIGQUIT, &act, NULL);
+       sigaction(SIGINT, &act, NULL);
+
+
+       if(ret = open_channel_trace_pairs(channel_name, trace_name, &fd_pairs))
+               goto close_channel;
+
+       if(ret = map_channels(&fd_pairs))
+               goto close_channel;
+       
+       tids = malloc(sizeof(pthread_t) * num_threads);
+       for(i=0; i<num_threads; i++) {
+               ret = pthread_create(&tids[i], NULL, read_channels, &fd_pairs);
+               if(ret) {
+                       perror("Error creating thread");
+                       break;
+               }
+       }
+
+       for(i=0; i<num_threads; i++) {
+               ret = pthread_join(tids[i], &tret);
+               if(ret) {
+                       perror("Error joining thread");
+                       break;
+               }
+               if((int)tret != 0) {
+                       printf("Error %s occured in thread %u\n", strerror((int)tret), i);
+               }
+       }
+
+       free(tids);
+                       
+       ret |= unmap_channels(&fd_pairs);
+
+close_channel:
+       close_channel_trace_pairs(&fd_pairs);
+
+       return ret;
+}
diff --git a/ltt/branches/poly/lttd/Makefile.am b/ltt/branches/poly/lttd/Makefile.am
deleted file mode 100644 (file)
index bb860bc..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# Empty TraceDaemon Makefile.am. Insert a real one here.
-
-LIBS += $(THREAD_LIBS)
-
-bin_PROGRAMS = lttd
-
-lttd_SOURCES = lttd.c
-
diff --git a/ltt/branches/poly/lttd/lttd.c b/ltt/branches/poly/lttd/lttd.c
deleted file mode 100644 (file)
index 2601d80..0000000
+++ /dev/null
@@ -1,665 +0,0 @@
-/* lttd
- *
- * Linux Trace Toolkit Daemon
- *
- * This is a simple daemon that reads a few relayfs channels and save them in a
- * trace.
- *
- *
- * Copyright 2005 -
- *     Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#define _REENTRANT
-#define _GNU_SOURCE
-#include <features.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <dirent.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/poll.h>
-#include <sys/mman.h>
-#include <signal.h>
-#include <pthread.h>
-
-/* Relayfs IOCTL */
-#include <asm/ioctl.h>
-#include <asm/types.h>
-
-/* Get the next sub buffer that can be read. */
-#define RELAYFS_GET_SUBBUF        _IOR(0xF4, 0x00,__u32)
-/* Release the oldest reserved (by "get") sub buffer. */
-#define RELAYFS_PUT_SUBBUF        _IOW(0xF4, 0x01,__u32)
-/* returns the number of sub buffers in the per cpu channel. */
-#define RELAYFS_GET_N_SUBBUFS     _IOR(0xF4, 0x02,__u32)
-/* returns the size of the sub buffers. */
-#define RELAYFS_GET_SUBBUF_SIZE   _IOR(0xF4, 0x03,__u32)
-
-
-
-enum {
-       GET_SUBBUF,
-       PUT_SUBBUF,
-       GET_N_BUBBUFS,
-       GET_SUBBUF_SIZE
-};
-
-struct fd_pair {
-       int channel;
-       int trace;
-       unsigned int n_subbufs;
-       unsigned int subbuf_size;
-       void *mmap;
-       pthread_mutex_t mutex;
-};
-
-struct channel_trace_fd {
-       struct fd_pair *pair;
-       int num_pairs;
-};
-
-static char *trace_name = NULL;
-static char *channel_name = NULL;
-static int     daemon_mode = 0;
-static int     append_mode = 0;
-static unsigned long num_threads = 1;
-volatile static int    quit_program = 0;       /* For signal handler */
-
-/* Args :
- *
- * -t directory                Directory name of the trace to write to. Will be created.
- * -c directory                Root directory of the relayfs trace channels.
- * -d                          Run in background (daemon).
- * -a                                                  Trace append mode.
- * -s                                                  Send SIGUSR1 to parent when ready for IO.
- */
-void show_arguments(void)
-{
-       printf("Please use the following arguments :\n");
-       printf("\n");
-       printf("-t directory  Directory name of the trace to write to.\n"
-                                "              It will be created.\n");
-       printf("-c directory  Root directory of the relayfs trace channels.\n");
-       printf("-d            Run in background (daemon).\n");
-       printf("-a            Append to an possibly existing trace.\n");
-       printf("-N            Number of threads to start.\n");
-       printf("\n");
-}
-
-
-/* parse_arguments
- *
- * Parses the command line arguments.
- *
- * Returns 1 if the arguments were correct, but doesn't ask for program
- * continuation. Returns -1 if the arguments are incorrect, or 0 if OK.
- */
-int parse_arguments(int argc, char **argv)
-{
-       int ret = 0;
-       int argn = 1;
-       
-       if(argc == 2) {
-               if(strcmp(argv[1], "-h") == 0) {
-                       return 1;
-               }
-       }
-
-       while(argn < argc) {
-
-               switch(argv[argn][0]) {
-                       case '-':
-                               switch(argv[argn][1]) {
-                                       case 't':
-                                               if(argn+1 < argc) {
-                                                       trace_name = argv[argn+1];
-                                                       argn++;
-                                               }
-                                               break;
-                                       case 'c':
-                                               if(argn+1 < argc) {
-                                                       channel_name = argv[argn+1];
-                                                       argn++;
-                                               }
-                                               break;
-                                       case 'd':
-                                               daemon_mode = 1;
-                                               break;
-                                       case 'a':
-                                               append_mode = 1;
-                                               break;
-                                       case 'N':
-                                               if(argn+1 < argc) {
-                                                       num_threads = strtoul(argv[argn+1], NULL, 0);
-                                                       argn++;
-                                               }
-                                               break;
-                                       default:
-                                               printf("Invalid argument '%s'.\n", argv[argn]);
-                                               printf("\n");
-                                               ret = -1;
-                               }
-                               break;
-                       default:
-                               printf("Invalid argument '%s'.\n", argv[argn]);
-                               printf("\n");
-                               ret = -1;
-               }
-               argn++;
-       }
-       
-       if(trace_name == NULL) {
-               printf("Please specify a trace name.\n");
-               printf("\n");
-               ret = -1;
-       }
-       
-       if(channel_name == NULL) {
-               printf("Please specify a channel name.\n");
-               printf("\n");
-               ret = -1;
-       }
-       
-       return ret;
-}
-
-void show_info(void)
-{
-       printf("Linux Trace Toolkit Trace Daemon\n");
-       printf("\n");
-       printf("Reading from relayfs directory : %s\n", channel_name);
-       printf("Writing to trace directory : %s\n", trace_name);
-       printf("\n");
-}
-
-
-/* signal handling */
-
-static void handler(int signo)
-{
-       printf("Signal %d received : exiting cleanly\n", signo);
-       quit_program = 1;
-}
-
-
-
-int open_channel_trace_pairs(char *subchannel_name, char *subtrace_name,
-               struct channel_trace_fd *fd_pairs)
-{
-       DIR *channel_dir = opendir(subchannel_name);
-       struct dirent *entry;
-       struct stat stat_buf;
-       int ret;
-       char path_channel[PATH_MAX];
-       int path_channel_len;
-       char *path_channel_ptr;
-       char path_trace[PATH_MAX];
-       int path_trace_len;
-       char *path_trace_ptr;
-  int open_ret = 0;
-
-       if(channel_dir == NULL) {
-               perror(subchannel_name);
-               open_ret = ENOENT;
-    goto end;
-       }
-
-       printf("Creating trace subdirectory %s\n", subtrace_name);
-       ret = mkdir(subtrace_name, S_IRWXU|S_IRWXG|S_IRWXO);
-       if(ret == -1) {
-               if(errno != EEXIST) {
-                       perror(subtrace_name);
-      open_ret = -1;
-                       goto end;
-               }
-       }
-
-       strncpy(path_channel, subchannel_name, PATH_MAX-1);
-       path_channel_len = strlen(path_channel);
-       path_channel[path_channel_len] = '/';
-       path_channel_len++;
-       path_channel_ptr = path_channel + path_channel_len;
-
-       strncpy(path_trace, subtrace_name, PATH_MAX-1);
-       path_trace_len = strlen(path_trace);
-       path_trace[path_trace_len] = '/';
-       path_trace_len++;
-       path_trace_ptr = path_trace + path_trace_len;
-       
-       while((entry = readdir(channel_dir)) != NULL) {
-
-               if(entry->d_name[0] == '.') continue;
-               
-               strncpy(path_channel_ptr, entry->d_name, PATH_MAX - path_channel_len);
-               strncpy(path_trace_ptr, entry->d_name, PATH_MAX - path_trace_len);
-               
-               ret = stat(path_channel, &stat_buf);
-               if(ret == -1) {
-                       perror(path_channel);
-                       continue;
-               }
-               
-               printf("Channel file : %s\n", path_channel);
-               
-               if(S_ISDIR(stat_buf.st_mode)) {
-
-                       printf("Entering channel subdirectory...\n");
-                       ret = open_channel_trace_pairs(path_channel, path_trace, fd_pairs);
-                       if(ret < 0) continue;
-               } else if(S_ISREG(stat_buf.st_mode)) {
-                       printf("Opening file.\n");
-                       
-                       fd_pairs->pair = realloc(fd_pairs->pair,
-                                       ++fd_pairs->num_pairs * sizeof(struct fd_pair));
-
-                       /* Open the channel in read mode */
-                       fd_pairs->pair[fd_pairs->num_pairs-1].channel = 
-                               open(path_channel, O_RDONLY | O_NONBLOCK);
-                       if(fd_pairs->pair[fd_pairs->num_pairs-1].channel == -1) {
-                               perror(path_channel);
-                               fd_pairs->num_pairs--;
-                               continue;
-                       }
-                       /* Open the trace in write mode, only append if append_mode */
-                       ret = stat(path_trace, &stat_buf);
-                       if(ret == 0) {
-                               if(append_mode) {
-                                       printf("Appending to file %s as requested\n", path_trace);
-
-                                       fd_pairs->pair[fd_pairs->num_pairs-1].trace = 
-                                               open(path_trace, O_WRONLY|O_APPEND,
-                                                               S_IRWXU|S_IRWXG|S_IRWXO);
-
-                                       if(fd_pairs->pair[fd_pairs->num_pairs-1].trace == -1) {
-                                               perror(path_trace);
-                                       }
-                               } else {
-                                       printf("File %s exists, cannot open. Try append mode.\n", path_trace);
-                                       open_ret = -1;
-          goto end;
-                               }
-                       } else {
-                               if(errno == ENOENT) {
-                                       fd_pairs->pair[fd_pairs->num_pairs-1].trace = 
-                                               open(path_trace, O_WRONLY|O_CREAT|O_EXCL,
-                                                               S_IRWXU|S_IRWXG|S_IRWXO);
-                                       if(fd_pairs->pair[fd_pairs->num_pairs-1].trace == -1) {
-                                               perror(path_trace);
-                                       }
-                               }
-                       }
-               }
-       }
-       
-end:
-       closedir(channel_dir);
-
-       return open_ret;
-}
-
-
-int read_subbuffer(struct fd_pair *pair)
-{
-       unsigned int    consumed_old;
-       int err, ret=0;
-
-
-       err = ioctl(pair->channel, RELAYFS_GET_SUBBUF, 
-                                                               &consumed_old);
-       printf("cookie : %u\n", consumed_old);
-       if(err != 0) {
-               ret = errno;
-               perror("Reserving sub buffer failed (everything is normal)");
-               goto get_error;
-       }
-       
-       err = TEMP_FAILURE_RETRY(write(pair->trace,
-                               pair->mmap 
-                                       + (consumed_old & ((pair->n_subbufs * pair->subbuf_size)-1)),
-                               pair->subbuf_size));
-
-       if(err < 0) {
-               ret = errno;
-               perror("Error in writing to file");
-               goto write_error;
-       }
-#if 0
-       err = fsync(pair->trace);
-       if(err < 0) {
-               ret = errno;
-               perror("Error in writing to file");
-               goto write_error;
-       }
-#endif //0
-write_error:
-       err = ioctl(pair->channel, RELAYFS_PUT_SUBBUF, &consumed_old);
-       if(err != 0) {
-               ret = errno;
-               if(errno == -EFAULT) {
-                       perror("Error in unreserving sub buffer\n");
-               } else if(errno == -EIO) {
-                       perror("Reader has been pushed by the writer, last subbuffer corrupted.");
-                       /* FIXME : we may delete the last written buffer if we wish. */
-               }
-               goto get_error;
-       }
-
-get_error:
-       return ret;
-}
-
-
-
-int map_channels(struct channel_trace_fd *fd_pairs)
-{
-       int i,j;
-       int ret=0;
-
-       if(fd_pairs->num_pairs <= 0) {
-               printf("No channel to read\n");
-               goto end;
-       }
-       
-       /* Get the subbuf sizes and number */
-
-       for(i=0;i<fd_pairs->num_pairs;i++) {
-               struct fd_pair *pair = &fd_pairs->pair[i];
-
-               ret = ioctl(pair->channel, RELAYFS_GET_N_SUBBUFS, 
-                                                       &pair->n_subbufs);
-               if(ret != 0) {
-                       perror("Error in getting the number of subbuffers");
-                       goto end;
-               }
-               ret = ioctl(pair->channel, RELAYFS_GET_SUBBUF_SIZE, 
-                                                       &pair->subbuf_size);
-               if(ret != 0) {
-                       perror("Error in getting the size of the subbuffers");
-                       goto end;
-               }
-               ret = pthread_mutex_init(&pair->mutex, NULL);   /* Fast mutex */
-               if(ret != 0) {
-                       perror("Error in mutex init");
-                       goto end;
-               }
-       }
-
-       /* Mmap each FD */
-       for(i=0;i<fd_pairs->num_pairs;i++) {
-               struct fd_pair *pair = &fd_pairs->pair[i];
-
-               pair->mmap = mmap(0, pair->subbuf_size * pair->n_subbufs, PROT_READ,
-                               MAP_SHARED, pair->channel, 0);
-               if(pair->mmap == MAP_FAILED) {
-                       perror("Mmap error");
-                       goto munmap;
-               }
-       }
-
-       goto end; /* success */
-
-       /* Error handling */
-       /* munmap only the successfully mmapped indexes */
-munmap:
-               /* Munmap each FD */
-       for(j=0;j<i;j++) {
-               struct fd_pair *pair = &fd_pairs->pair[j];
-               int err_ret;
-
-               err_ret = munmap(pair->mmap, pair->subbuf_size * pair->n_subbufs);
-               if(err_ret != 0) {
-                       perror("Error in munmap");
-               }
-               ret |= err_ret;
-       }
-
-end:
-       return ret;
-
-
-}
-
-
-int unmap_channels(struct channel_trace_fd *fd_pairs)
-{
-       int j;
-       int ret=0;
-
-       /* Munmap each FD */
-       for(j=0;j<fd_pairs->num_pairs;j++) {
-               struct fd_pair *pair = &fd_pairs->pair[j];
-               int err_ret;
-
-               err_ret = munmap(pair->mmap, pair->subbuf_size * pair->n_subbufs);
-               if(err_ret != 0) {
-                       perror("Error in munmap");
-               }
-               ret |= err_ret;
-               err_ret = pthread_mutex_destroy(&pair->mutex);
-               if(err_ret != 0) {
-                       perror("Error in mutex destroy");
-               }
-               ret |= err_ret;
-       }
-
-       return ret;
-}
-
-
-/* read_channels
- *
- * Thread worker.
- *
- * Read the relayfs channels and write them in the paired tracefiles.
- *
- * @fd_pairs : paired channels and trace files.
- *
- * returns (void*)0 on success, (void*)-1 on error.
- *
- * Note that the high priority polled channels are consumed first. We then poll
- * again to see if these channels are still in priority. Only when no
- * high priority channel is left, we start reading low priority channels.
- *
- * Note that a channel is considered high priority when the buffer is almost
- * full.
- */
-
-void * read_channels(void *arg)
-{
-       struct pollfd *pollfd;
-       int i,j;
-       int num_rdy, num_hup;
-       int high_prio;
-       int ret = 0;
-       struct channel_trace_fd *fd_pairs = (struct channel_trace_fd *)arg;
-
-       /* Start polling the FD */
-       
-       pollfd = malloc(fd_pairs->num_pairs * sizeof(struct pollfd));
-
-       /* Note : index in pollfd is the same index as fd_pair->pair */
-       for(i=0;i<fd_pairs->num_pairs;i++) {
-               pollfd[i].fd = fd_pairs->pair[i].channel;
-               pollfd[i].events = POLLIN|POLLPRI;
-       }
-
-       while(1) {
-               high_prio = 0;
-               num_hup = 0; 
-#ifdef DEBUG
-               printf("Press a key for next poll...\n");
-               char buf[1];
-               read(STDIN_FILENO, &buf, 1);
-               printf("Next poll (polling %d fd) :\n", fd_pairs->num_pairs);
-#endif //DEBUG
-               
-               /* Have we received a signal ? */
-               if(quit_program) break;
-               
-               num_rdy = poll(pollfd, fd_pairs->num_pairs, -1);
-               if(num_rdy == -1) {
-                       perror("Poll error");
-                       goto free_fd;
-               }
-
-               printf("Data received\n");
-
-               for(i=0;i<fd_pairs->num_pairs;i++) {
-                       switch(pollfd[i].revents) {
-                               case POLLERR:
-                                       printf("Error returned in polling fd %d.\n", pollfd[i].fd);
-                                       num_hup++;
-                                       break;
-                               case POLLHUP:
-                                       printf("Polling fd %d tells it has hung up.\n", pollfd[i].fd);
-                                       num_hup++;
-                                       break;
-                               case POLLNVAL:
-                                       printf("Polling fd %d tells fd is not open.\n", pollfd[i].fd);
-                                       num_hup++;
-                                       break;
-                               case POLLPRI:
-                                       if(pthread_mutex_trylock(&fd_pairs->pair[i].mutex) == 0) {
-                                               printf("Urgent read on fd %d\n", pollfd[i].fd);
-                                               /* Take care of high priority channels first. */
-                                               high_prio = 1;
-                                               /* it's ok to have an unavailable subbuffer */
-                                               ret = read_subbuffer(&fd_pairs->pair[i]);
-                                               if(ret == -EAGAIN) ret = 0;
-
-                                               ret = pthread_mutex_unlock(&fd_pairs->pair[i].mutex);
-                                               if(ret)
-                                                       printf("Error in mutex unlock : %s\n", strerror(ret));
-                                       }
-                                       break;
-                       }
-               }
-               /* If every FD has hung up, we end the read loop here */
-               if(num_hup == fd_pairs->num_pairs) break;
-
-               if(!high_prio) {
-                       for(i=0;i<fd_pairs->num_pairs;i++) {
-                               switch(pollfd[i].revents) {
-                                       case POLLIN:
-                                               if(pthread_mutex_trylock(&fd_pairs->pair[i].mutex) == 0) {
-                                                       /* Take care of low priority channels. */
-                                                       printf("Normal read on fd %d\n", pollfd[i].fd);
-                                                       /* it's ok to have an unavailable subbuffer */
-                                                       ret = read_subbuffer(&fd_pairs->pair[i]);
-                                                       if(ret == -EAGAIN) ret = 0;
-
-                                                       ret = pthread_mutex_unlock(&fd_pairs->pair[i].mutex);
-                                                       if(ret)
-                                                               printf("Error in mutex unlock : %s\n", strerror(ret));
-                                               }
-                                               break;
-                               }
-                       }
-               }
-
-       }
-
-free_fd:
-       free(pollfd);
-
-end:
-       return (void*)ret;
-}
-
-
-void close_channel_trace_pairs(struct channel_trace_fd *fd_pairs)
-{
-       int i;
-       int ret;
-
-       for(i=0;i<fd_pairs->num_pairs;i++) {
-               ret = close(fd_pairs->pair[i].channel);
-               if(ret == -1) perror("Close error on channel");
-               ret = close(fd_pairs->pair[i].trace);
-               if(ret == -1) perror("Close error on trace");
-       }
-       free(fd_pairs->pair);
-}
-
-int main(int argc, char ** argv)
-{
-       int ret = 0;
-       struct channel_trace_fd fd_pairs = { NULL, 0 };
-       struct sigaction act;
-       pthread_t *tids;
-       unsigned int i;
-       void *tret;
-       
-       ret = parse_arguments(argc, argv);
-
-       if(ret != 0) show_arguments();
-       if(ret < 0) return EINVAL;
-       if(ret > 0) return 0;
-
-       show_info();
-
-       if(daemon_mode) {
-               ret = daemon(0, 0);
-    
-    if(ret == -1) {
-      perror("An error occured while daemonizing.");
-      exit(-1);
-    }
-  }
-
-       /* Connect the signal handlers */
-       act.sa_handler = handler;
-       act.sa_flags = 0;
-       sigemptyset(&(act.sa_mask));
-       sigaddset(&(act.sa_mask), SIGTERM);
-       sigaddset(&(act.sa_mask), SIGQUIT);
-       sigaddset(&(act.sa_mask), SIGINT);
-       sigaction(SIGTERM, &act, NULL);
-       sigaction(SIGQUIT, &act, NULL);
-       sigaction(SIGINT, &act, NULL);
-
-
-       if(ret = open_channel_trace_pairs(channel_name, trace_name, &fd_pairs))
-               goto close_channel;
-
-       if(ret = map_channels(&fd_pairs))
-               goto close_channel;
-       
-       tids = malloc(sizeof(pthread_t) * num_threads);
-       for(i=0; i<num_threads; i++) {
-               ret = pthread_create(&tids[i], NULL, read_channels, &fd_pairs);
-               if(ret) {
-                       perror("Error creating thread");
-                       break;
-               }
-       }
-
-       for(i=0; i<num_threads; i++) {
-               ret = pthread_join(tids[i], &tret);
-               if(ret) {
-                       perror("Error joining thread");
-                       break;
-               }
-               if((int)tret != 0) {
-                       printf("Error %s occured in thread %u\n", strerror((int)tret), i);
-               }
-       }
-
-       free(tids);
-                       
-       ret |= unmap_channels(&fd_pairs);
-
-close_channel:
-       close_channel_trace_pairs(&fd_pairs);
-
-       return ret;
-}
This page took 0.080264 seconds and 4 git commands to generate.