# WARNING : ltt must come before lttv, so that the traceread library is
# up to date
-SUBDIRS = libltt ltt lttctl lttv lttd doc facilities
+SUBDIRS = liblttctl ltt lttctl lttv lttd doc facilities
EXTRA_DIST = QUICKSTART
AC_SUBST(lttvwindowincludedir)
AC_CONFIG_FILES([Makefile
- libltt/Makefile
+ liblttctl/Makefile
lttctl/Makefile
lttv/Makefile
lttv/lttv/Makefile
lttv/modules/gui/tracecontrol/Makefile
lttd/Makefile
ltt/Makefile
- ltt/convert/Makefile
doc/Makefile
doc/developer/Makefile
doc/developer/developer_guide/Makefile
+++ /dev/null
-
-lib_LTLIBRARIES = libltt.la
-libltt_la_SOURCES = libltt.c
-
-lttinclude_HEADERS = \
- libltt.h
+++ /dev/null
-/* 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 <libltt/libltt.h>
-#include <errno.h>
-#include <stdio.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;
-}
-
+++ /dev/null
-/* 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 12
-#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
--- /dev/null
+
+lib_LTLIBRARIES = libltt.la
+libltt_la_SOURCES = libltt.c
+
+lttinclude_HEADERS = \
+ libltt.h
--- /dev/null
+/* 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 <libltt/libltt.h>
+#include <errno.h>
+#include <stdio.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;
+}
+
--- /dev/null
+/* 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 12
+#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
# Created by Mathieu Desnoyers on May 6, 2003
#
-SUBDIRS = convert
-
libdir = ${lttlibdir}
AM_CFLAGS = $(GLIB_CFLAGS)
--- /dev/null
+/*
+ * LTTTypes.h
+ *
+ * Copyright (C) 2000 Karim Yaghmour (karym@opersys.com).
+ *
+ * This is distributed under GPL.
+ *
+ * Header for LTT-secific types.
+ *
+ * History :
+ * K.Y. 07/09/2001, Added David Schleef's architecture independent ltt_set_bit/ltt_clear_bit/ltt_test_bit
+ * JAL, 05/01/2001, Modified PPC bit manipulation functions for x86 compatibility.
+ * (andy_lowe@mvista.com)
+ * K.Y., 31/05/2000, Initial typing.
+ */
+
+#ifndef __TRACE_TOOLKIT_TYPES_HEADER__
+#define __TRACE_TOOLKIT_TYPES_HEADER__
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#if defined(sun)
+
+typedef unsigned char u_int8_t;
+typedef unsigned short u_int16_t;
+typedef unsigned int u_int32_t;
+#ifdef _LP64
+typedef unsigned long u_int64_t;
+#else /* _ILP32 */
+#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
+typedef unsigned long long u_int64_t;
+#endif /* __STDC__ - 0 == 0 && !defined(_NO_LONGLONG) */
+#endif /* _LP64 */
+
+#endif /* defined(sun) */
+
+extern __inline__ int ltt_set_bit(int nr, void * addr)
+{
+ unsigned char *p = addr;
+ unsigned char mask = 1 << (nr&7);
+ unsigned char old;
+
+ p += nr>>3;
+ old = *p;
+ *p |= mask;
+
+ return ((old & mask) != 0);
+}
+
+extern __inline__ int ltt_clear_bit(int nr, void * addr)
+{
+ unsigned char *p = addr;
+ unsigned char mask = 1 << (nr&7);
+ unsigned char old;
+
+ p += nr>>3;
+ old = *p;
+ *p &= ~mask;
+
+ return ((old & mask) != 0);
+}
+
+extern __inline__ int ltt_test_bit(int nr,void *addr)
+{
+ unsigned char *p = addr;
+ unsigned char mask = 1 << (nr&7);
+
+ p += nr>>3;
+
+ return ((*p & mask) != 0);
+}
+
+/* Big-endian/little-endian conversion macros for cross-development. */
+#if TARGET_NATIVE
+/* For native development, these conversion macros aren't needed. */
+#define BREV16(x) (x)
+#define BREV32(x) (x)
+#define BREV64(x) (x)
+#define RFT8(db,x) (x)
+#define RFT16(db,x) (x)
+#define RFT32(db,x) (x)
+#define RFT64(db,x) (x)
+
+/* Non-native development */
+#else
+ /* BREV16: byte-reverse a 16-bit integer */
+#define BREV16(x) ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8))
+ /* BREV32: byte-reverse a 32-bit integer */
+#define BREV32(x) ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \
+ | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+ /* BREV64: byte-reverse a 64-bit integer */
+#define BREV64(x) ((((x) & 0xff00000000000000) >> 56) \
+ | (((x) & 0x00ff000000000000) >> 40) \
+ | (((x) & 0x0000ff0000000000) >> 24) \
+ | (((x) & 0x000000ff00000000) >> 8) \
+ | (((x) & 0x00000000ff000000) << 8) \
+ | (((x) & 0x0000000000ff0000) << 24) \
+ | (((x) & 0x000000000000ff00) << 40) \
+ | (((x) & 0x00000000000000ff) << 56))
+ /* RFTn: Read From Trace
+ * Conditionally byte-reverse an 8-, 16-, 32-, or 64-bit integer
+ * based on the value of the ByteRev member of the trace database
+ * structure pointer passed as the first argument..
+ */
+#define RFT8(db,x) (x)
+#define RFT16(db,x) ((db)->ByteRev ? BREV16(x) : (x))
+#define RFT32(db,x) ((db)->ByteRev ? BREV32(x) : (x))
+#define RFT64(db,x) ((db)->ByteRev ? BREV64(x) : (x))
+#endif /* TRACE_TARGET_NATIVE */
+
+#if !defined(sun)
+/* Some type corrections, just in case */
+#ifndef uint8_t
+#define uint8_t u_int8_t
+#endif
+#ifndef uint16_t
+#define uint16_t u_int16_t
+#endif
+#ifndef uint32_t
+#define uint32_t u_int32_t
+#endif
+#ifndef uint64_t
+#define uint64_t u_int64_t
+#endif
+#endif /* !defined(sun) */
+
+/* Structure packing */
+#if LTT_UNPACKED_STRUCTS
+#define LTT_PACKED_STRUCT
+#else
+#define LTT_PACKED_STRUCT __attribute__ ((packed))
+#endif /* UNPACKED_STRUCTS */
+
+/* Trace mask */
+typedef uint64_t trace_event_mask;
+
+/* Boolean stuff */
+//#define TRUE 1
+//#define FALSE 0
+
+#endif /* __TRACE_TOOLKIT_TYPES_HEADER__ */
--- /dev/null
+/*
+ * LinuxEvents.h
+ *
+ * Copyright (C) 2000, 2001, 2002 Karim Yaghmour (karym@opersys.com).
+ *
+ * This header is distributed under GPL.
+ *
+ * Linux events being traced.
+ *
+ * History :
+ * K.Y., 31/05/1999, Initial typing.
+ *
+ */
+
+#ifndef __TRACE_TOOLKIT_LINUX_HEADER__
+#define __TRACE_TOOLKIT_LINUX_HEADER__
+
+#include "LTTTypes.h"
+
+/* Traced events */
+#define TRACE_START 0 /* This is to mark the trace's start */
+#define TRACE_SYSCALL_ENTRY 1 /* Entry in a given system call */
+#define TRACE_SYSCALL_EXIT 2 /* Exit from a given system call */
+#define TRACE_TRAP_ENTRY 3 /* Entry in a trap */
+#define TRACE_TRAP_EXIT 4 /* Exit from a trap */
+#define TRACE_IRQ_ENTRY 5 /* Entry in an irq */
+#define TRACE_IRQ_EXIT 6 /* Exit from an irq */
+#define TRACE_SCHEDCHANGE 7 /* Scheduling change */
+#define TRACE_KERNEL_TIMER 8 /* The kernel timer routine has been called */
+#define TRACE_SOFT_IRQ 9 /* Hit key part of soft-irq management */
+#define TRACE_PROCESS 10 /* Hit key part of process management */
+#define TRACE_FILE_SYSTEM 11 /* Hit key part of file system */
+#define TRACE_TIMER 12 /* Hit key part of timer management */
+#define TRACE_MEMORY 13 /* Hit key part of memory management */
+#define TRACE_SOCKET 14 /* Hit key part of socket communication */
+#define TRACE_IPC 15 /* Hit key part of inter-process communication */
+#define TRACE_NETWORK 16 /* Hit key part of network communication */
+
+#define TRACE_BUFFER_START 17 /* Mark the begining of a trace buffer */
+#define TRACE_BUFFER_END 18 /* Mark the ending of a trace buffer */
+#define TRACE_NEW_EVENT 19 /* New event type */
+#define TRACE_CUSTOM 20 /* Custom event */
+
+#define TRACE_CHANGE_MASK 21 /* Change in event mask */
+#define TRACE_HEARTBEAT 22 /* Heartbeat event */
+
+/* Number of traced events */
+#define TRACE_MAX TRACE_HEARTBEAT
+
+/* Architecture types */
+#define TRACE_ARCH_TYPE_I386 1 /* i386 system */
+#define TRACE_ARCH_TYPE_PPC 2 /* PPC system */
+#define TRACE_ARCH_TYPE_SH 3 /* SH system */
+#define TRACE_ARCH_TYPE_S390 4 /* S/390 system */
+#define TRACE_ARCH_TYPE_MIPS 5 /* MIPS system */
+#define TRACE_ARCH_TYPE_ARM 6 /* ARM system */
+
+/* Standard definitions for variants */
+#define TRACE_ARCH_VARIANT_NONE 0 /* Main architecture implementation */
+
+/* PowerPC variants */
+#define TRACE_ARCH_VARIANT_PPC_4xx 1 /* 4xx systems (IBM embedded series) */
+#define TRACE_ARCH_VARIANT_PPC_6xx 2 /* 6xx/7xx/74xx/8260/POWER3 systems (desktop flavor) */
+#define TRACE_ARCH_VARIANT_PPC_8xx 3 /* 8xx system (Motoral embedded series) */
+#define TRACE_ARCH_VARIANT_PPC_ISERIES 4 /* 8xx system (iSeries) */
+
+/* System types */
+#define TRACE_SYS_TYPE_VANILLA_LINUX 1 /* Vanilla linux kernel */
+#define TRACE_SYS_TYPE_RTAI_LINUX 2 /* RTAI patched linux kernel */
+
+/* The information logged when the tracing is started */
+#define TRACER_MAGIC_NUMBER 0x00D6B7ED /* That day marks an important historical event ... */
+#define TRACER_SUP_VERSION_MAJOR 2 /* Major version number */
+
+/* Minimum information contained in any trace start event */
+typedef struct _trace_start_any
+{
+ uint32_t MagicNumber; /* Magic number to identify a trace */
+ uint32_t ArchType; /* Type of architecture */
+ uint32_t ArchVariant; /* Variant of the given type of architecture */
+ uint32_t SystemType; /* Operating system type */
+ uint8_t MajorVersion; /* Major version of trace */
+ uint8_t MinorVersion; /* Minor version of trace */
+
+} LTT_PACKED_STRUCT trace_start_any;
+
+typedef struct _trace_start_2_2
+{
+ uint32_t MagicNumber; /* Magic number to identify a trace */
+ uint32_t ArchType; /* Type of architecture */
+ uint32_t ArchVariant; /* Variant of the given type of architecture */
+ uint32_t SystemType; /* Operating system type */
+ uint8_t MajorVersion; /* Major version of trace */
+ uint8_t MinorVersion; /* Minor version of trace */
+
+ uint32_t BufferSize; /* Size of buffers */
+ trace_event_mask EventMask; /* The event mask */
+ trace_event_mask DetailsMask; /* Are the event details logged */
+ uint8_t LogCPUID; /* Is the CPUID logged */
+ uint8_t UseTSC; /* Are we using TSCs or time deltas */
+
+} LTT_PACKED_STRUCT trace_start_2_2;
+
+typedef struct _trace_start_2_3
+{
+ uint32_t MagicNumber; /* Magic number to identify a trace */
+ uint32_t ArchType; /* Type of architecture */
+ uint32_t ArchVariant; /* Variant of the given type of architecture */
+ uint32_t SystemType; /* Operating system type */
+ uint8_t MajorVersion; /* Major version of trace */
+ uint8_t MinorVersion; /* Minor version of trace */
+
+ uint32_t BufferSize; /* Size of buffers */
+ trace_event_mask EventMask; /* The event mask */
+ trace_event_mask DetailsMask; /* Are the event details logged */
+ uint8_t LogCPUID; /* Is the CPUID logged */
+ uint8_t UseTSC; /* Are we using TSCs or time deltas */
+
+ uint8_t FlightRecorder; /* Is this a flight recorder trace ? */
+} LTT_PACKED_STRUCT trace_start_2_3;
+
+/* TRACE_SYSCALL_ENTRY */
+typedef struct _trace_syscall_entry
+{
+ uint8_t syscall_id; /* Syscall entry number in entry.S */
+ uint32_t address; /* Address from which call was made */
+} LTT_PACKED_STRUCT trace_syscall_entry;
+#define SYSCALL_EVENT(X) ((trace_syscall_entry*)X)
+
+/* TRACE_TRAP_ENTRY */
+typedef struct _trace_trap_entry
+{
+ uint16_t trap_id; /* Trap number */
+ uint32_t address; /* Address where trap occured */
+} LTT_PACKED_STRUCT trace_trap_entry;
+typedef struct _trace_trap_entry_s390
+{
+ uint64_t trap_id; /* Trap number */
+ uint32_t address; /* Address where trap occured */
+} LTT_PACKED_STRUCT trace_trap_entry_s390;
+#define TRAP_EVENT(X) ((trace_trap_entry*)X)
+#define TRAP_EVENT_S390(X) ((trace_trap_entry_s390*)X)
+
+/* TRACE_IRQ_ENTRY */
+typedef struct _trace_irq_entry
+{
+ uint8_t irq_id; /* IRQ number */
+ uint8_t kernel; /* Are we executing kernel code */
+} LTT_PACKED_STRUCT trace_irq_entry;
+#define IRQ_EVENT(X) ((trace_irq_entry*)X)
+
+/* TRACE_SCHEDCHANGE */
+typedef struct _trace_schedchange
+{
+ uint32_t out; /* Outgoing process */
+ uint32_t in; /* Incoming process */
+ uint32_t out_state; /* Outgoing process' state */
+} LTT_PACKED_STRUCT trace_schedchange;
+#define SCHED_EVENT(X) ((trace_schedchange*)X)
+
+/* TRACE_SOFT_IRQ */
+#define TRACE_SOFT_IRQ_BOTTOM_HALF 1 /* Conventional bottom-half */
+#define TRACE_SOFT_IRQ_SOFT_IRQ 2 /* Real soft-irq */
+#define TRACE_SOFT_IRQ_TASKLET_ACTION 3 /* Tasklet action */
+#define TRACE_SOFT_IRQ_TASKLET_HI_ACTION 4 /* Tasklet hi-action */
+typedef struct _trace_soft_irq
+{
+ uint8_t event_sub_id; /* Soft-irq event Id */
+ uint32_t event_data; /* Data associated with event */
+} LTT_PACKED_STRUCT trace_soft_irq;
+#define SOFT_IRQ_EVENT(X) ((trace_soft_irq*)X)
+
+/* TRACE_PROCESS */
+#define TRACE_PROCESS_KTHREAD 1 /* Creation of a kernel thread */
+#define TRACE_PROCESS_FORK 2 /* A fork or clone occured */
+#define TRACE_PROCESS_EXIT 3 /* An exit occured */
+#define TRACE_PROCESS_WAIT 4 /* A wait occured */
+#define TRACE_PROCESS_SIGNAL 5 /* A signal has been sent */
+#define TRACE_PROCESS_WAKEUP 6 /* Wake up a process */
+#define TRACE_PROCESS_RELEASE 7 /* A task struct has been released */
+
+typedef struct _trace_process
+{
+ uint8_t event_sub_id; /* Process event ID */
+ uint32_t event_data1; /* Data associated with event */
+ uint32_t event_data2;
+} LTT_PACKED_STRUCT trace_process;
+#define PROC_EVENT(X) ((trace_process*)X)
+
+/* TRACE_FILE_SYSTEM */
+#define TRACE_FILE_SYSTEM_BUF_WAIT_START 1 /* Starting to wait for a data buffer */
+#define TRACE_FILE_SYSTEM_BUF_WAIT_END 2 /* End to wait for a data buffer */
+#define TRACE_FILE_SYSTEM_EXEC 3 /* An exec occured */
+#define TRACE_FILE_SYSTEM_OPEN 4 /* An open occured */
+#define TRACE_FILE_SYSTEM_CLOSE 5 /* A close occured */
+#define TRACE_FILE_SYSTEM_READ 6 /* A read occured */
+#define TRACE_FILE_SYSTEM_WRITE 7 /* A write occured */
+#define TRACE_FILE_SYSTEM_SEEK 8 /* A seek occured */
+#define TRACE_FILE_SYSTEM_IOCTL 9 /* An ioctl occured */
+#define TRACE_FILE_SYSTEM_SELECT 10 /* A select occured */
+#define TRACE_FILE_SYSTEM_POLL 11 /* A poll occured */
+typedef struct _trace_file_system
+{
+ uint8_t event_sub_id; /* File system event ID */
+ uint32_t event_data1; /* Event data */
+ uint32_t event_data2; /* Event data 2 */
+ char* file_name; /* Name of file operated on */
+} LTT_PACKED_STRUCT trace_file_system;
+#define FS_EVENT(X) ((trace_file_system*)X)
+#define FS_EVENT_FILENAME(X) ((char*) ((X) + sizeof(trace_file_system)))
+
+/* TRACE_TIMER */
+#define TRACE_TIMER_EXPIRED 1 /* Timer expired */
+#define TRACE_TIMER_SETITIMER 2 /* Setting itimer occurred */
+#define TRACE_TIMER_SETTIMEOUT 3 /* Setting sched timeout occurred */
+typedef struct _trace_timer
+{
+ uint8_t event_sub_id; /* Timer event ID */
+ uint8_t event_sdata; /* Short data */
+ uint32_t event_data1; /* Data associated with event */
+ uint32_t event_data2;
+} LTT_PACKED_STRUCT trace_timer;
+#define TIMER_EVENT(X) ((trace_timer*)X)
+
+/* TRACE_MEMORY */
+#define TRACE_MEMORY_PAGE_ALLOC 1 /* Allocating pages */
+#define TRACE_MEMORY_PAGE_FREE 2 /* Freing pages */
+#define TRACE_MEMORY_SWAP_IN 3 /* Swaping pages in */
+#define TRACE_MEMORY_SWAP_OUT 4 /* Swaping pages out */
+#define TRACE_MEMORY_PAGE_WAIT_START 5 /* Start to wait for page */
+#define TRACE_MEMORY_PAGE_WAIT_END 6 /* End to wait for page */
+typedef struct _trace_memory
+{
+ uint8_t event_sub_id; /* Memory event ID */
+ unsigned long event_data; /* Data associated with event */
+} LTT_PACKED_STRUCT trace_memory;
+#define MEM_EVENT(X) ((trace_memory*)X)
+
+/* TRACE_SOCKET */
+#define TRACE_SOCKET_CALL 1 /* A socket call occured */
+#define TRACE_SOCKET_CREATE 2 /* A socket has been created */
+#define TRACE_SOCKET_SEND 3 /* Data was sent to a socket */
+#define TRACE_SOCKET_RECEIVE 4 /* Data was read from a socket */
+typedef struct _trace_socket
+{
+ uint8_t event_sub_id; /* Socket event ID */
+ uint32_t event_data1; /* Data associated with event */
+ uint32_t event_data2; /* Data associated with event */
+} LTT_PACKED_STRUCT trace_socket;
+#define SOCKET_EVENT(X) ((trace_socket*)X)
+
+/* TRACE_IPC */
+#define TRACE_IPC_CALL 1 /* A System V IPC call occured */
+#define TRACE_IPC_MSG_CREATE 2 /* A message queue has been created */
+#define TRACE_IPC_SEM_CREATE 3 /* A semaphore was created */
+#define TRACE_IPC_SHM_CREATE 4 /* A shared memory segment has been created */
+typedef struct _trace_ipc
+{
+ uint8_t event_sub_id; /* IPC event ID */
+ uint32_t event_data1; /* Data associated with event */
+ uint32_t event_data2; /* Data associated with event */
+} LTT_PACKED_STRUCT trace_ipc;
+#define IPC_EVENT(X) ((trace_ipc*)X)
+
+/* TRACE_NETWORK */
+#define TRACE_NETWORK_PACKET_IN 1 /* A packet came in */
+#define TRACE_NETWORK_PACKET_OUT 2 /* A packet was sent */
+typedef struct _trace_network
+{
+ uint8_t event_sub_id; /* Network event ID */
+ uint32_t event_data; /* Event data */
+} LTT_PACKED_STRUCT trace_network;
+#define NET_EVENT(X) ((trace_network*)X)
+
+/* Start of trace buffer information */
+typedef struct _trace_buffer_start
+{
+ struct timeval Time; /* Time stamp of this buffer */
+ uint32_t TSC; /* TSC of this buffer, if applicable */
+ uint32_t ID; /* Unique buffer ID */
+} LTT_PACKED_STRUCT trace_buffer_start;
+
+/* End of trace buffer information */
+typedef struct _trace_buffer_end
+{
+ struct timeval Time; /* Time stamp of this buffer */
+ uint32_t TSC; /* TSC of this buffer, if applicable */
+} LTT_PACKED_STRUCT trace_buffer_end;
+
+/* Maximal size a custom event can have */
+#define CUSTOM_EVENT_MAX_SIZE 8192
+
+/* String length limits for custom events creation */
+#define CUSTOM_EVENT_TYPE_STR_LEN 20
+#define CUSTOM_EVENT_DESC_STR_LEN 100
+#define CUSTOM_EVENT_FORM_STR_LEN 256
+
+/* Type of custom event formats */
+#define CUSTOM_EVENT_FORMAT_TYPE_NONE 0
+#define CUSTOM_EVENT_FORMAT_TYPE_STR 1
+#define CUSTOM_EVENT_FORMAT_TYPE_HEX 2
+#define CUSTOM_EVENT_FORMAT_TYPE_XML 3
+#define CUSTOM_EVENT_FORMAT_TYPE_IBM 4
+
+typedef struct _trace_new_event
+{
+ /* Basics */
+ uint32_t id; /* Custom event ID */
+ char type[CUSTOM_EVENT_TYPE_STR_LEN]; /* Event type description */
+ char desc[CUSTOM_EVENT_DESC_STR_LEN]; /* Detailed event description */
+
+ /* Custom formatting */
+ uint32_t format_type; /* Type of formatting */
+ char form[CUSTOM_EVENT_FORM_STR_LEN]; /* Data specific to format */
+} LTT_PACKED_STRUCT trace_new_event;
+#define NEW_EVENT(X) ((trace_new_event*) X)
+
+typedef struct _trace_custom
+{
+ uint32_t id; /* Event ID */
+ uint32_t data_size; /* Size of data recorded by event */
+ void* data; /* Data recorded by event */
+} LTT_PACKED_STRUCT trace_custom;
+#define CUSTOM_EVENT(X) ((trace_custom*) X)
+
+/* TRACE_CHANGE_MASK */
+typedef struct _trace_change_mask
+{
+ trace_event_mask mask; /* Event mask */
+} LTT_PACKED_STRUCT trace_change_mask;
+#define CHMASK_EVENT(X) ((trace_change_mask*) X)
+
+#endif /* __TRACE_TOOLKIT_LINUX_HEADER__ */
--- /dev/null
+AM_CFLAGS = $(GLIB_CFLAGS)
+LIBS += $(GLIB_LIBS) $(M_LIBS)
+
+bin_PROGRAMS = convert
+
+convert_SOURCES = convert.c
+
+noinst_HEADERS = LTTTypes.h LinuxEvents.h
+
+EXTRA_DIST = core.xml sysInfo README
+convertdir = $(pkgdatadir)/convert
+convert_DATA = core.xml sysInfo README
--- /dev/null
+The application 'convert' is used to convert an old format tracefile into a new
+format tracefile. It has several commandline parameters, the first is process file
+name, the second is a number (the number of cpu in the machine), the third is
+the first tracefile name(corresponding to the first cpu), the fourth is the
+second tracefile name(corresponding to the second cpu), the fifth is ...,
+the last one is root directory for the new trace (this can be omitted,
+by default it is 'foo')
+
+The command line looks like this:
+ ./convert processfile_name the_number_of_cpu first_tracefile_name, ..., foo_dir
+
+There is also a script file 'sysInfo' which is used to get system information
+from your local machine, the information is saved in 'sysInfo.out' which will
+be read by 'convert' later. If the old tracefile is generated by other machine,
+then the 'sysInfo.out' should be gotten from that machine.
+
+'core.xml' is a facility file, after run 'convert', it needs to be copied to
+'foo_dir/eventdefs' directory
+
--- /dev/null
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+#include "LTTTypes.h"
+#include "LinuxEvents.h"
+
+#define TRACE_HEARTBEAT_ID 19
+#define PROCESS_FORK_ID 20
+#define PROCESS_EXIT_ID 21
+
+#define INFO_ENTRY 9
+#define OVERFLOW_FIGURE 0x100000000ULL
+
+typedef struct _new_process
+{
+ uint32_t event_data1; /* Data associated with event */
+ uint32_t event_data2;
+} LTT_PACKED_STRUCT new_process;
+
+#define write_to_buffer(DEST, SRC, SIZE) \
+do\
+{\
+ memcpy(DEST, SRC, SIZE);\
+ DEST += SIZE;\
+} while(0);
+
+int readFile(int fd, void * buf, size_t size, char * mesg)
+{
+ ssize_t nbBytes = read(fd, buf, size);
+
+ if((size_t)nbBytes != size) {
+ if(nbBytes < 0) {
+ perror("Error in readFile : ");
+ } else {
+ printf("%s\n",mesg);
+ }
+ exit(1);
+ }
+ return 0;
+}
+
+void getDataEndianType(char * size, char * endian)
+{
+ int i = 1;
+ char c = (char) i;
+ int sizeInt=sizeof(int), sizeLong=sizeof(long), sizePointer=sizeof(void *);
+
+ if(c == 1) strcpy(endian,"LITTLE_ENDIAN");
+ else strcpy(endian, "BIG_ENDIAN");
+
+ if(sizeInt == 2 && sizeLong == 4 && sizePointer == 4)
+ strcpy(size,"LP32");
+ else if(sizeInt == 4 && sizeLong == 4 && sizePointer == 4)
+ strcpy(size,"ILP32");
+ else if(sizeInt == 4 && sizeLong == 8 && sizePointer == 8)
+ strcpy(size,"LP64");
+ else if(sizeInt == 8 && sizeLong == 8 && sizePointer == 8)
+ strcpy(size,"ILP64");
+ else strcpy(size,"UNKNOWN");
+}
+
+#define BUFFER_SIZE 80
+
+typedef struct _buffer_start{
+ uint32_t seconds;
+ uint32_t nanoseconds;
+ uint64_t cycle_count;
+ uint32_t block_id;
+} __attribute__ ((packed)) buffer_start;
+
+typedef struct _buffer_end{
+ uint32_t seconds;
+ uint32_t nanoseconds;
+ uint64_t cycle_count;
+ uint32_t block_id;
+} __attribute__ ((packed)) buffer_end;
+
+
+typedef struct _heartbeat{
+ uint32_t seconds;
+ uint32_t nanoseconds;
+ uint64_t cycle_count;
+} __attribute__ ((packed)) heartbeat;
+
+
+int main(int argc, char ** argv){
+
+ int fd, fdCpu;
+ FILE * fp;
+ int fdFac, fdIntr, fdProc;
+ char arch_size[BUFFER_SIZE];
+ char endian[BUFFER_SIZE];
+ char node_name[BUFFER_SIZE];
+ char domainname[BUFFER_SIZE];
+ char kernel_name[BUFFER_SIZE];
+ char kernel_release[BUFFER_SIZE];
+ char kernel_version[BUFFER_SIZE];
+ char machine[BUFFER_SIZE];
+ char processor[BUFFER_SIZE];
+ char hardware_platform[BUFFER_SIZE];
+ char operating_system[BUFFER_SIZE];
+ int cpu;
+ int ltt_block_size=0;
+ int ltt_major_version=0;
+ int ltt_minor_version=0;
+ int ltt_log_cpu;
+ guint ltt_trace_start_size = 0;
+ char buf[BUFFER_SIZE];
+ int i, k;
+
+ uint8_t cpu_id;
+
+ char foo[4*BUFFER_SIZE];
+ char foo_eventdefs[4*BUFFER_SIZE];
+ char foo_control[4*BUFFER_SIZE];
+ char foo_cpu[4*BUFFER_SIZE];
+ char foo_info[4*BUFFER_SIZE];
+
+ char foo_control_facilities[4*BUFFER_SIZE];
+ char foo_control_processes[4*BUFFER_SIZE];
+ char foo_control_interrupts[4*BUFFER_SIZE];
+ char foo_info_system[4*BUFFER_SIZE];
+
+ struct stat lTDFStat;
+ off_t file_size;
+ int block_number, block_size;
+ char * buffer, *buf_out, cpuStr[4*BUFFER_SIZE];
+ char * buf_fac, * buf_intr, * buf_proc;
+ void * write_pos, *write_pos_fac, * write_pos_intr, *write_pos_proc;
+ trace_start_any *tStart;
+ trace_buffer_start *tBufStart;
+ trace_buffer_end *tBufEnd;
+ trace_file_system * tFileSys;
+ uint16_t newId, startId, tmpId;
+ uint8_t evId;
+ uint32_t time_delta, startTimeDelta;
+ void * cur_pos, *end_pos;
+ buffer_start start, start_proc, start_intr;
+ buffer_end end, end_proc, end_intr;
+ heartbeat beat;
+ uint64_t adaptation_tsc; // (Mathieu)
+ uint32_t size_lost;
+ int nb_para;
+
+ new_process process;
+
+ if(argc < 4){
+ printf("Usage : ./convert processfile_name number_of_cpu tracefile1 tracefile2 ... trace_creation_directory\n");
+ printf("For more details, see README.\n");
+ exit(1);
+ }
+
+ cpu = atoi(argv[2]);
+ printf("cpu number = %d\n", cpu);
+ nb_para = 3 + cpu;
+
+ if(argc != nb_para && argc != nb_para+1){
+ printf("need trace files and cpu number or root directory for the new tracefile\n");
+ exit(1);
+ }
+
+ if(argc == nb_para){
+ strcpy(foo, "foo");
+ strcpy(foo_eventdefs, "foo/eventdefs");
+ strcpy(foo_control, "foo/control");
+ strcpy(foo_cpu, "foo/cpu");
+ strcpy(foo_info, "foo/info");
+ }else{
+ strcpy(foo, argv[nb_para]);
+ strcpy(foo_eventdefs, argv[nb_para]);
+ strcat(foo_eventdefs,"/eventdefs");
+ strcpy(foo_control, argv[nb_para]);
+ strcat(foo_control,"/control");
+ strcpy(foo_cpu, argv[nb_para]);
+ strcat(foo_cpu,"/cpu");
+ strcpy(foo_info, argv[nb_para]);
+ strcat(foo_info,"/info");
+ }
+ strcpy(foo_control_facilities, foo_control);
+ strcat(foo_control_facilities,"/facilities");
+ strcpy(foo_control_processes, foo_control);
+ strcat(foo_control_processes, "/processes");
+ strcpy(foo_control_interrupts, foo_control);
+ strcat(foo_control_interrupts, "/interrupts");
+ strcpy(foo_info_system, foo_info);
+ strcat(foo_info_system, "/system.xml");
+
+
+ getDataEndianType(arch_size, endian);
+ printf("Arch_size: %s, Endian: %s\n", arch_size, endian);
+
+ fp = fopen("sysInfo.out","r");
+ if(!fp){
+ g_error("Unable to open file sysInfo.out\n");
+ }
+
+ for(i=0;i<INFO_ENTRY;i++){
+ if(!fgets(buf,BUFFER_SIZE-1,fp))
+ g_error("The format of sysInfo.out is not right\n");
+ if(strncmp(buf,"node_name=",10)==0){
+ strcpy(node_name,&buf[10]);
+ node_name[strlen(node_name)-1] = '\0';
+ }else if(strncmp(buf,"domainname=",11)==0){
+ strcpy(domainname,&buf[11]);
+ domainname[strlen(domainname)-1] = '\0';
+ }else if(strncmp(buf,"kernel_name=",12)==0){
+ strcpy(kernel_name,&buf[12]);
+ kernel_name[strlen(kernel_name)-1] = '\0';
+ }else if(strncmp(buf,"kernel_release=",15)==0){
+ strcpy(kernel_release,&buf[15]);
+ kernel_release[strlen(kernel_release)-1] = '\0';
+ }else if(strncmp(buf,"kernel_version=",15)==0){
+ strcpy(kernel_version,&buf[15]);
+ kernel_version[strlen(kernel_version)-1] = '\0';
+ }else if(strncmp(buf,"machine=",8)==0){
+ strcpy(machine,&buf[8]);
+ machine[strlen(machine)-1] = '\0';
+ }else if(strncmp(buf,"processor=",10)==0){
+ strcpy(processor,&buf[10]);
+ processor[strlen(processor)-1] = '\0';
+ }else if(strncmp(buf,"hardware_platform=",18)==0){
+ strcpy(hardware_platform,&buf[18]);
+ hardware_platform[strlen(hardware_platform)-1] = '\0';
+ }else if(strncmp(buf,"operating_system=",17)==0){
+ strcpy(operating_system,&buf[17]);
+ operating_system[strlen(operating_system)-1] = '\0';
+ }
+ }
+ fclose(fp);
+
+ if(mkdir(foo, S_IFDIR | S_IRWXU | S_IRGRP | S_IROTH))
+ g_error("can not make %s directory", foo);
+ if(mkdir(foo_info, S_IFDIR | S_IRWXU | S_IRGRP | S_IROTH))
+ g_error("can not make %s directory", foo_info);
+ if(mkdir(foo_cpu, S_IFDIR | S_IRWXU | S_IRGRP | S_IROTH))
+ g_error("can not make %s directory", foo_cpu);
+ if(mkdir(foo_control, S_IFDIR | S_IRWXU | S_IRGRP | S_IROTH))
+ g_error("can not make %s directory", foo_control);
+ if(mkdir(foo_eventdefs, S_IFDIR | S_IRWXU | S_IRGRP | S_IROTH))
+ g_error("can not make %s directory", foo_eventdefs);
+
+ fp = fopen(foo_info_system,"w");
+ if(!fp){
+ g_error("Unable to open file system.xml\n");
+ }
+
+ fdFac = open(foo_control_facilities,O_CREAT | O_RDWR | O_TRUNC,S_IRUSR |S_IWUSR | S_IRGRP | S_IROTH);
+ if(fdFac < 0){
+ g_error("Unable to open file facilities\n");
+ }
+ fdIntr = open(foo_control_interrupts,O_CREAT | O_RDWR | O_TRUNC,S_IRUSR |S_IWUSR | S_IRGRP | S_IROTH);
+ if(fdIntr<0){
+ g_error("Unable to open file interrupts\n");
+ }
+ fdProc = open(foo_control_processes,O_CREAT | O_RDWR | O_TRUNC,S_IRUSR |S_IWUSR | S_IRGRP | S_IROTH);
+ if(fdProc<0){
+ g_error("Unable to open file process\n");
+ }
+
+
+ for(k=0;k<cpu;k++){
+ fd = open(argv[nb_para-cpu+k], O_RDONLY, 0);
+ if(fd < 0){
+ g_error("Unable to open input data file %s\n", argv[nb_para-cpu+k]);
+ }
+
+ if(fstat(fd, &lTDFStat) < 0){
+ g_error("Unable to get the status of the input data file\n");
+ }
+ file_size = lTDFStat.st_size;
+
+ buffer = g_new(char, 4000);
+ readFile(fd,(void*)buffer, 3500, "Unable to read block header");
+
+ cur_pos= buffer;
+ evId = *(uint8_t *)cur_pos;
+ cur_pos += sizeof(uint8_t);
+ newId = evId;
+ time_delta = *(uint32_t*)cur_pos;
+ cur_pos += sizeof(uint32_t);
+ tBufStart = (trace_buffer_start*)cur_pos;
+ cur_pos += sizeof(trace_buffer_start);
+ cur_pos += sizeof(uint16_t); //Skip event size
+
+ evId = *(uint8_t *)cur_pos;
+ g_assert(evId == TRACE_START);
+ cur_pos += sizeof(uint8_t); //skip EvId
+ cur_pos += sizeof(uint32_t); //skip time delta
+ tStart = (trace_start_any*)cur_pos;
+ if(tStart->MagicNumber != TRACER_MAGIC_NUMBER)
+ g_error("Trace magic number does not match : %x, should be %x",
+ tStart->MagicNumber, TRACER_MAGIC_NUMBER);
+ if(tStart->MajorVersion != TRACER_SUP_VERSION_MAJOR)
+ g_error("Trace Major number does match : %hu, should be %u",
+ tStart->MajorVersion, TRACER_SUP_VERSION_MAJOR);
+
+ startId = newId;
+ startTimeDelta = time_delta;
+ start.seconds = tBufStart->Time.tv_sec;
+ /* Fix (Mathieu) */
+ start.nanoseconds = tBufStart->Time.tv_usec * 1000;
+ start.cycle_count = tBufStart->TSC;
+ start.block_id = tBufStart->ID;
+ end.block_id = start.block_id;
+
+
+ g_message("Trace version %hu.%hu detected\n",
+ tStart->MajorVersion,
+ tStart->MinorVersion);
+ if(tStart->MinorVersion == 2) {
+ trace_start_2_2* tStart_2_2 = (trace_start_2_2*)tStart;
+ ltt_major_version = tStart_2_2->MajorVersion;
+ ltt_minor_version = tStart_2_2->MinorVersion;
+ ltt_block_size = tStart_2_2->BufferSize;
+ ltt_log_cpu = tStart_2_2->LogCPUID;
+ ltt_trace_start_size = sizeof(trace_start_2_2);
+ /* Verify if it's a broken 2.2 format */
+ if(*(uint8_t*)(cur_pos + sizeof(trace_start_2_2)) == 0) {
+ /* Cannot have two trace start events. We cannot detect the problem
+ * if the flight recording flag is set to 1, as it conflicts
+ * with TRACE_SYSCALL_ENTRY.
+ */
+ g_warning("This is a 2.3 trace format that has a 2.2 tag. Please upgrade your kernel");
+ g_message("Processing the trace as a 2.3 format\n");
+
+ tStart->MinorVersion = 3;
+ }
+ }
+
+ if(tStart->MinorVersion == 3) {
+ trace_start_2_3* tStart_2_3 = (trace_start_2_3*)tStart;
+ ltt_major_version = tStart_2_3->MajorVersion;
+ ltt_minor_version = tStart_2_3->MinorVersion;
+ ltt_block_size = tStart_2_3->BufferSize;
+ ltt_log_cpu = tStart_2_3->LogCPUID;
+ ltt_trace_start_size = sizeof(trace_start_2_3);
+ /* We do not use the flight recorder information for now, because we
+ * never use the .proc file anyway */
+ }
+
+ if(ltt_trace_start_size == 0)
+ g_error("Minor version unknown : %hu. Supported minors : 2, 3",
+ tStart->MinorVersion);
+
+ block_size = ltt_block_size;//FIXME
+ block_number = file_size/ltt_block_size;
+
+ g_free(buffer);
+ buffer = g_new(char, ltt_block_size);
+ buf_fac = g_new(char, block_size);
+ write_pos_fac = buf_fac;
+ buf_intr = g_new(char, block_size);
+ write_pos_intr = buf_intr;
+ buf_proc = g_new(char, block_size);
+ write_pos_proc = buf_proc;
+
+ buf_out = g_new(char, block_size);
+ write_pos = buf_out;
+ sprintf(cpuStr,"%s/%d",foo_cpu,k);
+ fdCpu = open(cpuStr, O_CREAT | O_RDWR | O_TRUNC,S_IRUSR |S_IWUSR | S_IRGRP | S_IROTH); //for cpu k
+ if(fdCpu < 0) g_error("Unable to open cpu file %d\n", k);
+ lseek(fd,0,SEEK_SET);
+
+ for(i=0;i<block_number;i++){
+ int event_count = 0;
+
+ memset((void*)buf_out, 0, block_size);
+ write_pos = buf_out;
+ memset((void*)buf_intr, 0, block_size);
+ memset((void*)buf_fac, 0, block_size);
+ memset((void*)buf_proc, 0, block_size);
+ write_pos_intr = buf_intr;
+ write_pos_fac = buf_fac;
+ write_pos_proc = buf_proc;
+
+ memset((void*)buffer,0,ltt_block_size);
+ readFile(fd,(void*)buffer, ltt_block_size, "Unable to read block header");
+
+ cur_pos= buffer;
+ evId = *(uint8_t *)cur_pos;
+ cur_pos += sizeof(uint8_t);
+ newId = evId;
+ time_delta = *(uint32_t*)cur_pos;
+ cur_pos += sizeof(uint32_t);
+ tBufStart = (trace_buffer_start*)cur_pos;
+ cur_pos += sizeof(trace_buffer_start);
+ cur_pos += sizeof(uint16_t); //Skip event size
+
+ startId = newId;
+ startTimeDelta = time_delta;
+ start.seconds = tBufStart->Time.tv_sec;
+ /* usec -> nsec (Mathieu) */
+ start.nanoseconds = tBufStart->Time.tv_usec * 1000;
+ start.block_id = tBufStart->ID;
+ end.block_id = start.block_id;
+
+ end_pos = buffer + ltt_block_size; //end of the buffer
+ size_lost = *(uint32_t*)(end_pos - sizeof(uint32_t));
+
+ end_pos = buffer + ltt_block_size - size_lost ; //buffer_end event
+ if(ltt_log_cpu){
+ tBufEnd = (trace_buffer_end*)(end_pos + 2 * sizeof(uint8_t)+sizeof(uint32_t));
+ }else{
+ tBufEnd = (trace_buffer_end*)(end_pos+sizeof(uint8_t)+sizeof(uint32_t));
+ }
+ end.seconds = tBufEnd->Time.tv_sec;
+ /* usec -> nsec (Mathieu) */
+ end.nanoseconds = tBufEnd->Time.tv_usec * 1000;
+ // only 32 bits :(
+ //end.cycle_count = tBufEnd->TSC;
+
+ //skip buffer start and trace start events
+ if(i==0) {
+ //the first block
+ adaptation_tsc = (uint64_t)tBufStart->TSC;
+ cur_pos = buffer + sizeof(trace_buffer_start)
+ + ltt_trace_start_size
+ + 2*(sizeof(uint8_t)
+ + sizeof(uint16_t)+sizeof(uint32_t));
+ } else {
+ //other blocks
+ cur_pos = buffer + sizeof(trace_buffer_start)
+ + sizeof(uint8_t)
+ + sizeof(uint16_t)+sizeof(uint32_t);
+
+ /* Fix (Mathieu) */
+ if(time_delta < (0xFFFFFFFFULL&adaptation_tsc)) {
+ /* Overflow */
+ adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL)
+ + 0x100000000ULL
+ + (uint64_t)time_delta;
+ } else {
+ /* No overflow */
+ adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + time_delta;
+ }
+
+ }
+ start.cycle_count = adaptation_tsc;
+
+ //write start block event
+ write_to_buffer(write_pos,(void*)&startId, sizeof(uint16_t));
+ write_to_buffer(write_pos,(void*)&startTimeDelta, sizeof(uint32_t));
+ write_to_buffer(write_pos,(void*)&start, sizeof(buffer_start));
+
+ //write start block event into processes and interrupts files
+ write_to_buffer(write_pos_intr,(void*)&startId, sizeof(uint16_t));
+ write_to_buffer(write_pos_intr,(void*)&startTimeDelta, sizeof(uint32_t));
+ start_intr = start;
+ start_intr.nanoseconds -= 20;
+ write_to_buffer(write_pos_intr,(void*)&start_intr, sizeof(buffer_start));
+
+ write_to_buffer(write_pos_proc,(void*)&startId, sizeof(uint16_t));
+ write_to_buffer(write_pos_proc,(void*)&startTimeDelta, sizeof(uint32_t));
+ start_proc = start;
+ start_proc.nanoseconds -= 40;
+ write_to_buffer(write_pos_proc,(void*)&start_proc, sizeof(buffer_start));
+
+ //parse *.proc file to get process and irq info
+ if(i == 0){
+ int lIntID; /* Interrupt ID */
+ int lPID, lPPID; /* Process PID and Parent PID */
+ char lName[256]; /* Process name */
+ FILE * fProc;
+ uint16_t defaultId;
+ trace_irq_entry irq;
+
+ fProc = fopen(argv[1],"r");
+ if(!fProc){
+ g_error("Unable to open file %s\n", argv[1]);
+ }
+
+ while(fscanf(fProc, "PID: %d; PPID: %d; NAME: %s\n", &lPID, &lPPID, lName) > 0){
+ defaultId = PROCESS_FORK_ID;
+ process.event_data1 = lPID;
+ process.event_data2 = lPPID;
+ write_to_buffer(write_pos_proc,(void*)&defaultId, sizeof(uint16_t));
+ write_to_buffer(write_pos_proc,(void*)&startTimeDelta, sizeof(uint32_t));
+ write_to_buffer(write_pos_proc,(void*)&process, sizeof(new_process));
+ }
+
+ while(fscanf(fProc, "IRQ: %d; NAME: ", &lIntID) > 0){
+ /* Read 'til the end of the line */
+ fgets(lName, 200, fProc);
+
+ defaultId = TRACE_IRQ_ENTRY;
+ irq.irq_id = lIntID;
+ irq.kernel = 1;
+ write_to_buffer(write_pos_intr,(void*)&defaultId, sizeof(uint16_t));
+ write_to_buffer(write_pos_intr,(void*)&startTimeDelta, sizeof(uint32_t));
+ write_to_buffer(write_pos_intr,(void*)&irq, sizeof(trace_irq_entry));
+ }
+ fclose(fProc);
+ }
+
+ while(1){
+ int event_size;
+ uint64_t timeDelta;
+ uint8_t subId;
+
+ if(ltt_log_cpu){
+ cpu_id = *(uint8_t*)cur_pos;
+ cur_pos += sizeof(uint8_t);
+ }
+ evId = *(uint8_t *)cur_pos;
+ newId = evId;
+ if(evId == TRACE_HEARTBEAT) {
+ newId = TRACE_HEARTBEAT_ID;
+ }
+ cur_pos += sizeof(uint8_t);
+ time_delta = *(uint32_t*)cur_pos;
+ cur_pos += sizeof(uint32_t);
+
+
+ //write event_id and time_delta
+ write_to_buffer(write_pos,(void*)&newId,sizeof(uint16_t));
+ write_to_buffer(write_pos,(void*)&time_delta, sizeof(uint32_t));
+
+ /* Fix (Mathieu) */
+ if(time_delta < (0xFFFFFFFFULL&adaptation_tsc)) {
+ /* Overflow */
+ adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + 0x100000000ULL
+ + (uint64_t)time_delta;
+ } else {
+ /* No overflow */
+ adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + time_delta;
+ }
+
+
+ if(evId == TRACE_BUFFER_END){
+#if 0
+ /* Fix (Mathieu) */
+ if(time_delta < (0xFFFFFFFFULL&adaptation_tsc)) {
+ /* Overflow */
+ adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + 0x100000000ULL
+ + (uint64_t)time_delta;
+ } else {
+ /* No overflow */
+ adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + time_delta;
+ }
+#endif //0
+ end.cycle_count = adaptation_tsc;
+ int size = (void*)buf_out + block_size - write_pos
+ - sizeof(buffer_end) - sizeof(uint32_t);
+
+ /* size _lost_ ? */
+ //int size = (void*)buf_out + block_size - write_pos
+ // + sizeof(uint16_t) + sizeof(uint32_t);
+ g_assert((void*)write_pos < (void*)buf_out + block_size);
+ write_to_buffer(write_pos,(void*)&end,sizeof(buffer_end));
+ write_pos = buf_out + block_size - sizeof(uint32_t);
+ write_to_buffer(write_pos,(void*)&size, sizeof(uint32_t));
+ write(fdCpu,(void*)buf_out, block_size);
+
+ //write out processes and intrrupts files
+ {
+ int size_intr = block_size + (void*)buf_intr - write_pos_intr
+ - sizeof(buffer_end) - sizeof(uint32_t);
+ int size_proc = block_size + (void*)buf_proc - write_pos_proc
+ - sizeof(buffer_end) - sizeof(uint32_t);
+ //int size_intr = block_size - (write_pos_intr - (void*)buf_intr);
+ //int size_proc = block_size - (write_pos_proc - (void*)buf_proc);
+ write_to_buffer(write_pos_intr,(void*)&newId,sizeof(uint16_t));
+ write_to_buffer(write_pos_intr,(void*)&time_delta, sizeof(uint32_t));
+ end_intr = end;
+ end_intr.nanoseconds -= 20;
+ write_to_buffer(write_pos_intr,(void*)&end_intr,sizeof(buffer_start));
+
+ write_to_buffer(write_pos_proc,(void*)&newId,sizeof(uint16_t));
+ write_to_buffer(write_pos_proc,(void*)&time_delta, sizeof(uint32_t));
+ end_proc = end;
+ end_proc.nanoseconds -= 40;
+ write_to_buffer(write_pos_proc,(void*)&end_proc,sizeof(buffer_start));
+
+ write_pos_intr = buf_intr + block_size - sizeof(uint32_t);
+ write_pos_proc = buf_proc + block_size - sizeof(uint32_t);
+ write_to_buffer(write_pos_intr,(void*)&size_intr, sizeof(uint32_t));
+ write_to_buffer(write_pos_proc,(void*)&size_proc, sizeof(uint32_t));
+ //for now don't output processes and interrupt information
+ // write(fdIntr,(void*)buf_intr,block_size);
+ // write(fdProc,(void*)buf_proc,block_size);
+ }
+ break;
+ }
+
+ event_count++;
+ switch(evId){
+ case TRACE_SYSCALL_ENTRY:
+ event_size = sizeof(trace_syscall_entry);
+ break;
+ case TRACE_SYSCALL_EXIT:
+ event_size = 0;
+ break;
+ case TRACE_TRAP_ENTRY:
+ event_size = sizeof(trace_trap_entry);
+ break;
+ case TRACE_TRAP_EXIT:
+ event_size = 0;
+ break;
+ case TRACE_IRQ_ENTRY:
+ event_size = sizeof(trace_irq_entry);
+ timeDelta = time_delta;
+ write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t));
+ write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint32_t));
+ write_to_buffer(write_pos_intr,cur_pos, event_size);
+ break;
+ case TRACE_IRQ_EXIT:
+ event_size = 0;
+ timeDelta = time_delta;
+ write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t));
+ write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint32_t));
+ break;
+ case TRACE_SCHEDCHANGE:
+ event_size = sizeof(trace_schedchange);
+ break;
+ case TRACE_KERNEL_TIMER:
+ event_size = 0;
+ break;
+ case TRACE_SOFT_IRQ:
+ event_size = sizeof(trace_soft_irq);
+ // timeDelta = time_delta;
+ // write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t));
+ // write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint32_t));
+ // write_to_buffer(write_pos_intr,cur_pos, event_size);
+ break;
+ case TRACE_PROCESS:
+ event_size = sizeof(trace_process);
+ timeDelta = time_delta;
+ subId = *(uint8_t*)cur_pos;
+ if(subId == TRACE_PROCESS_FORK || subId ==TRACE_PROCESS_EXIT){
+ if( subId == TRACE_PROCESS_FORK)tmpId = PROCESS_FORK_ID;
+ else tmpId = PROCESS_EXIT_ID;
+ write_to_buffer(write_pos_proc,(void*)&tmpId, sizeof(uint16_t));
+ write_to_buffer(write_pos_proc,(void*)&timeDelta, sizeof(uint32_t));
+
+ process = *(new_process*)(cur_pos + sizeof(uint8_t));
+ write_to_buffer(write_pos_proc,(void*)&process, sizeof(new_process));
+ }
+ break;
+ case TRACE_FILE_SYSTEM:
+ event_size = sizeof(trace_file_system)- sizeof(char*);
+ break;
+ case TRACE_TIMER:
+ event_size = sizeof(trace_timer);
+ break;
+ case TRACE_MEMORY:
+ event_size = sizeof(trace_memory);
+ break;
+ case TRACE_SOCKET:
+ event_size = sizeof(trace_socket);
+ break;
+ case TRACE_IPC:
+ event_size = sizeof(trace_ipc);
+ break;
+ case TRACE_NETWORK:
+ event_size = sizeof(trace_network);
+ break;
+ case TRACE_HEARTBEAT:
+ beat.seconds = 0;
+ beat.nanoseconds = 0;
+ beat.cycle_count = adaptation_tsc;
+ event_size = 0;
+
+ write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t));
+ write_to_buffer(write_pos_intr,(void*)&time_delta, sizeof(uint32_t));
+ write_to_buffer(write_pos_intr,(void*)&beat, sizeof(heartbeat));
+ write_to_buffer(write_pos_proc,(void*)&newId, sizeof(uint16_t));
+ write_to_buffer(write_pos_proc,(void*)&time_delta, sizeof(uint32_t));
+ write_to_buffer(write_pos_proc,(void*)&beat, sizeof(heartbeat));
+ break;
+ default:
+ event_size = -1;
+ break;
+ }
+ if(evId != TRACE_FILE_SYSTEM && event_size >=0){
+ write_to_buffer(write_pos, cur_pos, event_size);
+
+ if(evId == TRACE_HEARTBEAT){
+ write_to_buffer(write_pos, (void*)&beat, sizeof(heartbeat));
+ }
+
+ cur_pos += event_size + sizeof(uint16_t); //skip data_size
+ }else if(evId == TRACE_FILE_SYSTEM){
+ size_t nbBytes;
+ char c = '\0';
+ tFileSys = (trace_file_system*)cur_pos;
+ subId = tFileSys->event_sub_id;
+ if(subId == TRACE_FILE_SYSTEM_OPEN || subId == TRACE_FILE_SYSTEM_EXEC){
+ nbBytes = tFileSys->event_data2 +1;
+ }else nbBytes = 0;
+
+ write_to_buffer(write_pos, cur_pos, event_size);
+ cur_pos += event_size + sizeof(char*);
+ if(nbBytes){
+ write_to_buffer(write_pos, cur_pos, nbBytes);
+ }else{
+ write_to_buffer(write_pos, (void*)&c, 1);
+ }
+ cur_pos += nbBytes + sizeof(uint16_t); //skip data_size
+ }else if(event_size == -1){
+ printf("Unknown event: evId=%d, i=%d, event_count=%d\n", newId, i, event_count);
+ exit(1);
+ }
+ } //end while(1)
+ }
+ close(fd);
+ close(fdCpu);
+ g_free(buffer);
+ buffer = NULL;
+ g_free(buf_fac);
+ g_free(buf_intr);
+ g_free(buf_proc);
+ g_free(buf_out);
+ }
+
+
+
+
+
+ //write to system.xml
+ fprintf(fp,"<system \n");
+ fprintf(fp,"node_name=\"%s\" \n", node_name);
+ fprintf(fp,"domainname=\"%s\" \n", domainname);
+ fprintf(fp,"cpu=\"%d\" \n", cpu);
+ fprintf(fp,"arch_size=\"%s\" \n", arch_size);
+ fprintf(fp,"endian=\"%s\" \n",endian);
+ fprintf(fp,"kernel_name=\"%s\" \n",kernel_name);
+ fprintf(fp,"kernel_release=\"%s\" \n",kernel_release);
+ fprintf(fp,"kernel_version=\"%s\" \n",kernel_version);
+ fprintf(fp,"machine=\"%s\" \n",machine);
+ fprintf(fp,"processor=\"%s\" \n",processor);
+ fprintf(fp,"hardware_platform=\"%s\" \n",hardware_platform);
+ fprintf(fp,"operating_system=\"%s\" \n",operating_system);
+ fprintf(fp,"ltt_major_version=\"%d\" \n",ltt_major_version);
+ fprintf(fp,"ltt_minor_version=\"%d\" \n",ltt_minor_version);
+ fprintf(fp,"ltt_block_size=\"%d\" \n",ltt_block_size);
+ fprintf(fp,">\n");
+ fprintf(fp,"This is just a test\n");
+ fprintf(fp,"</system>\n");
+ fflush(fp);
+
+ close(fdFac);
+ close(fdIntr);
+ close(fdProc);
+ fclose(fp);
+
+ g_message("Conversion completed. Don't forget to copy core.xml to eventdefs directory\n");
+
+ return 0;
+}
+
--- /dev/null
+<facility name=core>
+ <description>The core facility contains the basic events</description>
+
+ <event name=facility_load>
+ <description>Facility used in the trace</description>
+ <struct>
+ <field name="name"><string/></field>
+ <field name="checksum"><uint size=4/></field>
+ <field name="base_code"><uint size=4/></field>
+ </struct>
+ </event>
+
+ <event name=syscall_entry>
+ <description>Entry in a given system call</description>
+ <struct>
+ <field name="syscall_id"> <description>Syscall entry number in entry.S</description> <uint size=1/> </field>
+ <field name="address"> <description>Address from which call was made</description> <uint size=4/> </field>
+ </struct>
+ </event>
+
+ <event name=syscall_exit>
+ <description>Exit from a given system call</description>
+ </event>
+
+ <event name=trap_entry>
+ <description>Entry in a trap</description>
+ <struct>
+ <field name="trap_id"> <description>Trap number</description> <uint size=2/> </field>
+ <field name="address"> <description>Address where trap occured</description> <uint size=4/> </field>
+ </struct>
+ </event>
+
+ <event name=trap_exit>
+ <description>Exit from a trap</description>
+ </event>
+
+ <event name=irq_entry>
+ <description>Entry in an irq</description>
+ <struct>
+ <field name="irq_id"> <description>IRQ number</description> <uint size=1/> </field>
+ <field name="kernel"> <description>Are we executing kernel code</description> <uint size=1/> </field>
+ </struct>
+ </event>
+
+ <event name=irq_exit>
+ <description>Exit from an IRQ</description>
+ </event>
+
+ <event name=schedchange>
+ <description>Scheduling change</description>
+ <struct>
+ <field name="out"> <description>Outgoing process</description> <uint size=4/> </field>
+ <field name="in"> <description>Incoming process</description> <uint size=4/> </field>
+ <field name="out_state"> <description>Outgoing process' state</description> <uint size=4/> </field>
+ </struct>
+ </event>
+
+ <event name=kernel_timer>
+ <description>The kernel timer routine has been called</description>
+ </event>
+
+ <event name=soft_irq>
+ <description>Hit key part of soft-irq management</description>
+ <struct>
+ <field name="event_sub_id"> <description>Soft-irq event Id</description>
+ <enum size=1>
+ <label name=TRACE_EV_SOFT_IRQ_BOTTOM_HALF value=1/>
+ <label name=TRACE_EV_SOFT_IRQ_SOFT_IRQ/>
+ <label name=TRACE_EV_SOFT_IRQ_TASKLET_ACTION/>
+ <label name=TRACE_EV_SOFT_IRQ_TASKLET_HI_ACTION/>
+ </enum>
+ </field>
+
+ <field name="event_data"> <description>Data associated with event</description> <uint size=4/> </field>
+ </struct>
+ </event>
+
+ <event name=process>
+ <description>Hit key part of process management</description>
+ <struct>
+ <field name="event_sub_id"> <description>Process event ID</description>
+ <enum size=1>
+ <label name=TRACE_EV_PROCESS_KTHREAD value=1/>
+ <label name=TRACE_EV_PROCESS_FORK/>
+ <label name=TRACE_EV_PROCESS_EXIT/>
+ <label name=TRACE_EV_PROCESS_WAIT/>
+ <label name=TRACE_EV_PROCESS_SIGNAL/>
+ <label name=TRACE_EV_PROCESS_WAKEUP/>
+ <label name=TRACE_EV_PROCESS_RELEASE/>
+ </enum>
+ </field>
+
+ <field name="event_data1"> <description>Data associated with event</description> <uint size=4/> </field>
+ <field name="event_data2"> <description>Data associated with event</description> <uint size=4/> </field>
+ </struct>
+ </event>
+
+ <event name=file_system>
+ <description>Hit key part of file system</description>
+ <struct>
+ <field name="event_sub_id"> <description>File system event ID</description>
+ <enum size=1>
+ <label name=TRACE_EV_FILE_SYSTEM_BUF_WAIT_START value=1/>
+ <label name=TRACE_EV_FILE_SYSTEM_BUF_WAIT_END/>
+ <label name=TRACE_EV_FILE_SYSTEM_EXEC/>
+ <label name=TRACE_EV_FILE_SYSTEM_OPEN/>
+ <label name=TRACE_EV_FILE_SYSTEM_CLOSE/>
+ <label name=TRACE_EV_FILE_SYSTEM_READ/>
+ <label name=TRACE_EV_FILE_SYSTEM_WRITE/>
+ <label name=TRACE_EV_FILE_SYSTEM_SEEK/>
+ <label name=TRACE_EV_FILE_SYSTEM_IOCTL/>
+ <label name=TRACE_EV_FILE_SYSTEM_SELECT/>
+ <label name=TRACE_EV_FILE_SYSTEM_POLL/>
+ </enum>
+ </field>
+
+ <field name="event_data1"> <description>Event data </description> <uint size=4/> </field>
+ <field name="event_data2"> <description>Event data 2</description> <uint size=4/> </field>
+ <field name="file_name"> <description>Name of file operated on </description> <string/> </field>
+ </struct>
+ </event>
+
+ <event name=timer>
+ <description>Hit key part of timer management</description>
+ <struct>
+ <field name="event_sub_id"> <description>Timer event ID</description>
+ <enum size=1>
+ <label name=TRACE_EV_TIMER_EXPIRED value=1/>
+ <label name=TRACE_EV_TIMER_SETITIMER/>
+ <label name=TRACE_EV_TIMER_SETTIMEOUT/>
+ </enum>
+ </field>
+
+ <field name="event_sdata"> <description>Short data</description> <uint size=1/> </field>
+ <field name="event_data1"> <description>Data associated with event</description> <uint size=4/> </field>
+ <field name="event_data2"> <description>Data associated with event</description> <uint size=4/> </field>
+ </struct>
+ </event>
+
+ <event name=memory>
+ <description>Hit key part of memory management</description>
+ <struct>
+ <field name="event_sub_id"> <description>Memory event ID</description>
+ <enum size=1>
+ <label name=TRACE_EV_MEMORY_PAGE_ALLOC value=1/>
+ <label name=TRACE_EV_MEMORY_PAGE_FREE/>
+ <label name=TRACE_EV_MEMORY_SWAP_IN/>
+ <label name=TRACE_EV_MEMORY_SWAP_OUT/>
+ <label name=TRACE_EV_MEMORY_PAGE_WAIT_START/>
+ <label name=TRACE_EV_MEMORY_PAGE_WAIT_END/>
+ </enum>
+ </field>
+
+ <field name="event_data"> <description>Data associated with event</description> <uint size=4/> </field>
+ </struct>
+ </event>
+
+ <event name=socket>
+ <description>Hit key part of socket communication</description>
+ <struct>
+ <field name="event_sub_id"> <description>Memory event ID</description>
+ <enum size=1>
+ <label name=TRACE_EV_SOCKET_CALL value=1/>
+ <label name=TRACE_EV_SOCKET_CREATE/>
+ <label name=TRACE_EV_SOCKET_SEND/>
+ <label name=TRACE_EV_SOCKET_RECEIVE/>
+ </enum>
+ </field>
+
+ <field name="event_data1"> <description>Data associated with event</description> <uint size=4/> </field>
+ <field name="event_data2"> <description>Data associated with event</description> <uint size=4/> </field>
+ </struct>
+ </event>
+
+ <event name=ipc>
+ <description>Hit key part of System V IPC</description>
+ <struct>
+ <field name="event_sub_id"> <description>Memory event ID</description>
+ <enum size=1>
+ <label name=TRACE_EV_IPC_CALL value=1/>
+ <label name=TRACE_EV_IPC_MSG_CREATE/>
+ <label name=TRACE_EV_IPC_SEM_CREATE/>
+ <label name=TRACE_EV_IPC_SHM_CREATE/>
+ </enum>
+ </field>
+
+ <field name="event_data1"> <description>Data associated with event</description> <uint size=4/> </field>
+ <field name="event_data2"> <description>Data associated with event</description> <uint size=4/> </field>
+ </struct>
+ </event>
+
+ <event name=network>
+ <description>Hit key part of network communication</description>
+ <struct>
+ <field name="event_sub_id"> <description>Memory event ID</description>
+ <enum size=1>
+ <label name=TRACE_EV_NETWORK_PACKET_IN value=1/>
+ <label name=TRACE_EV_NETWORK_PACKET_OUT/>
+ </enum>
+ </field>
+
+ <field name="event_data"> <description>Data associated with event</description> <uint size=4/> </field>
+ </struct>
+ </event>
+
+ <event name=block_start>
+ <description>Block start timestamp</description>
+ <typeref name=block_timestamp/>
+ </event>
+
+ <event name=block_end>
+ <description>Block end timestamp</description>
+ <typeref name=block_timestamp/>
+ </event>
+
+ <event name=time_heartbeat>
+ <description>System time values sent periodically to minimize cycle counter
+ drift with respect to real time clock and to detect cycle counter roolovers
+ </description>
+ <typeref name=timestamp/>
+ </event>
+
+ <type name=block_timestamp>
+ <struct>
+ <field name=timestamp><typeref name=timestamp/></field>
+ <field name=block_id><uint size=4/></field>
+ </struct>
+ </type>
+
+ <type name=timestamp>
+ <struct>
+ <field name=time><typeref name=timespec/></field>
+ <field name="cycle_count"><uint size=8/></field>
+ </struct>
+ </type>
+
+ <type name=timespec>
+ <struct>
+ <field name="seconds"><uint size=4/></field>
+ <field name="nanoseconds"><uint size=4/></field>
+ </struct>
+ </type>
+
+
+ <event name=process_fork>
+ <description>Fork a new process</description>
+ <struct>
+ <field name="child_pid"> <description>Data associated with event</description> <uint size=4/> </field>
+ <field name="event_data2"> <description>Data associated with event</description> <uint size=4/> </field>
+ </struct>
+ </event>
+
+ <event name=process_exit>
+ <description>Exit from a process</description>
+ <struct>
+ <field name="event_data1"> <description>Data associated with event</description> <uint size=4/> </field>
+ <field name="event_data2"> <description>Data associated with event</description> <uint size=4/> </field>
+ </struct>
+ </event>
+
+</facility>
+
+
--- /dev/null
+#!/bin/bash
+
+# DO NOT FORGET TO DISABLE ALL THE JAVA OPTIONS IN NETSCAPE
+# OTHERWISE IT WILL DIE ...
+
+outputFile=sysInfo.out
+
+NODE_NAME=`uname -n`
+echo "node_name="$NODE_NAME > $outputFile
+
+DOMAINNAME="`hostname --domain`"
+echo "domainname="$DOMAINNAME >> $outputFile
+
+KERNEL_NAME="`uname -s`"
+echo "kernel_name="$KERNEL_NAME >> $outputFile
+
+KERNEL_RELEASE="`uname -r`"
+echo "kernel_release="$KERNEL_RELEASE >> $outputFile
+
+KERNEL_VERSION="`uname -v`"
+echo "kernel_version="$KERNEL_VERSION >> $outputFile
+
+MACHINE="`uname -m`"
+echo "machine="$MACHINE >> $outputFile
+
+
+# not available anymore in uname version 5 and newer
+PROCESSOR="`uname -p`"
+echo "processor="$PROCESSOR >> $outputFile
+
+# not available anymore in uname version 5 and newer
+HARDWARE_PLATFORM="`uname -i`"
+echo "hardware_platform="$HARDWARE_PLATFORM >> $outputFile
+
+OPERATING_SYSTEM="`uname -o`"
+echo "operating_system="$OPERATING_SYSTEM >> $outputFile
+
+
+#export $NODE_NAME
+#export $NODE_NAME $DOMAINNAME $KERNEL_NAME $KERNEL_RELEASE $KERNEL_VERSION $MACHINE $PROCESSOR $HARDWARE_PLATFORM $OPERATING_SYSTEM
+
+
+
+#/sbin/lilo -C "$liloConf"
+
+++ /dev/null
-/*
- * LTTTypes.h
- *
- * Copyright (C) 2000 Karim Yaghmour (karym@opersys.com).
- *
- * This is distributed under GPL.
- *
- * Header for LTT-secific types.
- *
- * History :
- * K.Y. 07/09/2001, Added David Schleef's architecture independent ltt_set_bit/ltt_clear_bit/ltt_test_bit
- * JAL, 05/01/2001, Modified PPC bit manipulation functions for x86 compatibility.
- * (andy_lowe@mvista.com)
- * K.Y., 31/05/2000, Initial typing.
- */
-
-#ifndef __TRACE_TOOLKIT_TYPES_HEADER__
-#define __TRACE_TOOLKIT_TYPES_HEADER__
-
-#include <sys/types.h>
-#include <sys/time.h>
-
-#if defined(sun)
-
-typedef unsigned char u_int8_t;
-typedef unsigned short u_int16_t;
-typedef unsigned int u_int32_t;
-#ifdef _LP64
-typedef unsigned long u_int64_t;
-#else /* _ILP32 */
-#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
-typedef unsigned long long u_int64_t;
-#endif /* __STDC__ - 0 == 0 && !defined(_NO_LONGLONG) */
-#endif /* _LP64 */
-
-#endif /* defined(sun) */
-
-extern __inline__ int ltt_set_bit(int nr, void * addr)
-{
- unsigned char *p = addr;
- unsigned char mask = 1 << (nr&7);
- unsigned char old;
-
- p += nr>>3;
- old = *p;
- *p |= mask;
-
- return ((old & mask) != 0);
-}
-
-extern __inline__ int ltt_clear_bit(int nr, void * addr)
-{
- unsigned char *p = addr;
- unsigned char mask = 1 << (nr&7);
- unsigned char old;
-
- p += nr>>3;
- old = *p;
- *p &= ~mask;
-
- return ((old & mask) != 0);
-}
-
-extern __inline__ int ltt_test_bit(int nr,void *addr)
-{
- unsigned char *p = addr;
- unsigned char mask = 1 << (nr&7);
-
- p += nr>>3;
-
- return ((*p & mask) != 0);
-}
-
-/* Big-endian/little-endian conversion macros for cross-development. */
-#if TARGET_NATIVE
-/* For native development, these conversion macros aren't needed. */
-#define BREV16(x) (x)
-#define BREV32(x) (x)
-#define BREV64(x) (x)
-#define RFT8(db,x) (x)
-#define RFT16(db,x) (x)
-#define RFT32(db,x) (x)
-#define RFT64(db,x) (x)
-
-/* Non-native development */
-#else
- /* BREV16: byte-reverse a 16-bit integer */
-#define BREV16(x) ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8))
- /* BREV32: byte-reverse a 32-bit integer */
-#define BREV32(x) ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \
- | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
- /* BREV64: byte-reverse a 64-bit integer */
-#define BREV64(x) ((((x) & 0xff00000000000000) >> 56) \
- | (((x) & 0x00ff000000000000) >> 40) \
- | (((x) & 0x0000ff0000000000) >> 24) \
- | (((x) & 0x000000ff00000000) >> 8) \
- | (((x) & 0x00000000ff000000) << 8) \
- | (((x) & 0x0000000000ff0000) << 24) \
- | (((x) & 0x000000000000ff00) << 40) \
- | (((x) & 0x00000000000000ff) << 56))
- /* RFTn: Read From Trace
- * Conditionally byte-reverse an 8-, 16-, 32-, or 64-bit integer
- * based on the value of the ByteRev member of the trace database
- * structure pointer passed as the first argument..
- */
-#define RFT8(db,x) (x)
-#define RFT16(db,x) ((db)->ByteRev ? BREV16(x) : (x))
-#define RFT32(db,x) ((db)->ByteRev ? BREV32(x) : (x))
-#define RFT64(db,x) ((db)->ByteRev ? BREV64(x) : (x))
-#endif /* TRACE_TARGET_NATIVE */
-
-#if !defined(sun)
-/* Some type corrections, just in case */
-#ifndef uint8_t
-#define uint8_t u_int8_t
-#endif
-#ifndef uint16_t
-#define uint16_t u_int16_t
-#endif
-#ifndef uint32_t
-#define uint32_t u_int32_t
-#endif
-#ifndef uint64_t
-#define uint64_t u_int64_t
-#endif
-#endif /* !defined(sun) */
-
-/* Structure packing */
-#if LTT_UNPACKED_STRUCTS
-#define LTT_PACKED_STRUCT
-#else
-#define LTT_PACKED_STRUCT __attribute__ ((packed))
-#endif /* UNPACKED_STRUCTS */
-
-/* Trace mask */
-typedef uint64_t trace_event_mask;
-
-/* Boolean stuff */
-//#define TRUE 1
-//#define FALSE 0
-
-#endif /* __TRACE_TOOLKIT_TYPES_HEADER__ */
+++ /dev/null
-/*
- * LinuxEvents.h
- *
- * Copyright (C) 2000, 2001, 2002 Karim Yaghmour (karym@opersys.com).
- *
- * This header is distributed under GPL.
- *
- * Linux events being traced.
- *
- * History :
- * K.Y., 31/05/1999, Initial typing.
- *
- */
-
-#ifndef __TRACE_TOOLKIT_LINUX_HEADER__
-#define __TRACE_TOOLKIT_LINUX_HEADER__
-
-#include "LTTTypes.h"
-
-/* Traced events */
-#define TRACE_START 0 /* This is to mark the trace's start */
-#define TRACE_SYSCALL_ENTRY 1 /* Entry in a given system call */
-#define TRACE_SYSCALL_EXIT 2 /* Exit from a given system call */
-#define TRACE_TRAP_ENTRY 3 /* Entry in a trap */
-#define TRACE_TRAP_EXIT 4 /* Exit from a trap */
-#define TRACE_IRQ_ENTRY 5 /* Entry in an irq */
-#define TRACE_IRQ_EXIT 6 /* Exit from an irq */
-#define TRACE_SCHEDCHANGE 7 /* Scheduling change */
-#define TRACE_KERNEL_TIMER 8 /* The kernel timer routine has been called */
-#define TRACE_SOFT_IRQ 9 /* Hit key part of soft-irq management */
-#define TRACE_PROCESS 10 /* Hit key part of process management */
-#define TRACE_FILE_SYSTEM 11 /* Hit key part of file system */
-#define TRACE_TIMER 12 /* Hit key part of timer management */
-#define TRACE_MEMORY 13 /* Hit key part of memory management */
-#define TRACE_SOCKET 14 /* Hit key part of socket communication */
-#define TRACE_IPC 15 /* Hit key part of inter-process communication */
-#define TRACE_NETWORK 16 /* Hit key part of network communication */
-
-#define TRACE_BUFFER_START 17 /* Mark the begining of a trace buffer */
-#define TRACE_BUFFER_END 18 /* Mark the ending of a trace buffer */
-#define TRACE_NEW_EVENT 19 /* New event type */
-#define TRACE_CUSTOM 20 /* Custom event */
-
-#define TRACE_CHANGE_MASK 21 /* Change in event mask */
-#define TRACE_HEARTBEAT 22 /* Heartbeat event */
-
-/* Number of traced events */
-#define TRACE_MAX TRACE_HEARTBEAT
-
-/* Architecture types */
-#define TRACE_ARCH_TYPE_I386 1 /* i386 system */
-#define TRACE_ARCH_TYPE_PPC 2 /* PPC system */
-#define TRACE_ARCH_TYPE_SH 3 /* SH system */
-#define TRACE_ARCH_TYPE_S390 4 /* S/390 system */
-#define TRACE_ARCH_TYPE_MIPS 5 /* MIPS system */
-#define TRACE_ARCH_TYPE_ARM 6 /* ARM system */
-
-/* Standard definitions for variants */
-#define TRACE_ARCH_VARIANT_NONE 0 /* Main architecture implementation */
-
-/* PowerPC variants */
-#define TRACE_ARCH_VARIANT_PPC_4xx 1 /* 4xx systems (IBM embedded series) */
-#define TRACE_ARCH_VARIANT_PPC_6xx 2 /* 6xx/7xx/74xx/8260/POWER3 systems (desktop flavor) */
-#define TRACE_ARCH_VARIANT_PPC_8xx 3 /* 8xx system (Motoral embedded series) */
-#define TRACE_ARCH_VARIANT_PPC_ISERIES 4 /* 8xx system (iSeries) */
-
-/* System types */
-#define TRACE_SYS_TYPE_VANILLA_LINUX 1 /* Vanilla linux kernel */
-#define TRACE_SYS_TYPE_RTAI_LINUX 2 /* RTAI patched linux kernel */
-
-/* The information logged when the tracing is started */
-#define TRACER_MAGIC_NUMBER 0x00D6B7ED /* That day marks an important historical event ... */
-#define TRACER_SUP_VERSION_MAJOR 2 /* Major version number */
-
-/* Minimum information contained in any trace start event */
-typedef struct _trace_start_any
-{
- uint32_t MagicNumber; /* Magic number to identify a trace */
- uint32_t ArchType; /* Type of architecture */
- uint32_t ArchVariant; /* Variant of the given type of architecture */
- uint32_t SystemType; /* Operating system type */
- uint8_t MajorVersion; /* Major version of trace */
- uint8_t MinorVersion; /* Minor version of trace */
-
-} LTT_PACKED_STRUCT trace_start_any;
-
-typedef struct _trace_start_2_2
-{
- uint32_t MagicNumber; /* Magic number to identify a trace */
- uint32_t ArchType; /* Type of architecture */
- uint32_t ArchVariant; /* Variant of the given type of architecture */
- uint32_t SystemType; /* Operating system type */
- uint8_t MajorVersion; /* Major version of trace */
- uint8_t MinorVersion; /* Minor version of trace */
-
- uint32_t BufferSize; /* Size of buffers */
- trace_event_mask EventMask; /* The event mask */
- trace_event_mask DetailsMask; /* Are the event details logged */
- uint8_t LogCPUID; /* Is the CPUID logged */
- uint8_t UseTSC; /* Are we using TSCs or time deltas */
-
-} LTT_PACKED_STRUCT trace_start_2_2;
-
-typedef struct _trace_start_2_3
-{
- uint32_t MagicNumber; /* Magic number to identify a trace */
- uint32_t ArchType; /* Type of architecture */
- uint32_t ArchVariant; /* Variant of the given type of architecture */
- uint32_t SystemType; /* Operating system type */
- uint8_t MajorVersion; /* Major version of trace */
- uint8_t MinorVersion; /* Minor version of trace */
-
- uint32_t BufferSize; /* Size of buffers */
- trace_event_mask EventMask; /* The event mask */
- trace_event_mask DetailsMask; /* Are the event details logged */
- uint8_t LogCPUID; /* Is the CPUID logged */
- uint8_t UseTSC; /* Are we using TSCs or time deltas */
-
- uint8_t FlightRecorder; /* Is this a flight recorder trace ? */
-} LTT_PACKED_STRUCT trace_start_2_3;
-
-/* TRACE_SYSCALL_ENTRY */
-typedef struct _trace_syscall_entry
-{
- uint8_t syscall_id; /* Syscall entry number in entry.S */
- uint32_t address; /* Address from which call was made */
-} LTT_PACKED_STRUCT trace_syscall_entry;
-#define SYSCALL_EVENT(X) ((trace_syscall_entry*)X)
-
-/* TRACE_TRAP_ENTRY */
-typedef struct _trace_trap_entry
-{
- uint16_t trap_id; /* Trap number */
- uint32_t address; /* Address where trap occured */
-} LTT_PACKED_STRUCT trace_trap_entry;
-typedef struct _trace_trap_entry_s390
-{
- uint64_t trap_id; /* Trap number */
- uint32_t address; /* Address where trap occured */
-} LTT_PACKED_STRUCT trace_trap_entry_s390;
-#define TRAP_EVENT(X) ((trace_trap_entry*)X)
-#define TRAP_EVENT_S390(X) ((trace_trap_entry_s390*)X)
-
-/* TRACE_IRQ_ENTRY */
-typedef struct _trace_irq_entry
-{
- uint8_t irq_id; /* IRQ number */
- uint8_t kernel; /* Are we executing kernel code */
-} LTT_PACKED_STRUCT trace_irq_entry;
-#define IRQ_EVENT(X) ((trace_irq_entry*)X)
-
-/* TRACE_SCHEDCHANGE */
-typedef struct _trace_schedchange
-{
- uint32_t out; /* Outgoing process */
- uint32_t in; /* Incoming process */
- uint32_t out_state; /* Outgoing process' state */
-} LTT_PACKED_STRUCT trace_schedchange;
-#define SCHED_EVENT(X) ((trace_schedchange*)X)
-
-/* TRACE_SOFT_IRQ */
-#define TRACE_SOFT_IRQ_BOTTOM_HALF 1 /* Conventional bottom-half */
-#define TRACE_SOFT_IRQ_SOFT_IRQ 2 /* Real soft-irq */
-#define TRACE_SOFT_IRQ_TASKLET_ACTION 3 /* Tasklet action */
-#define TRACE_SOFT_IRQ_TASKLET_HI_ACTION 4 /* Tasklet hi-action */
-typedef struct _trace_soft_irq
-{
- uint8_t event_sub_id; /* Soft-irq event Id */
- uint32_t event_data; /* Data associated with event */
-} LTT_PACKED_STRUCT trace_soft_irq;
-#define SOFT_IRQ_EVENT(X) ((trace_soft_irq*)X)
-
-/* TRACE_PROCESS */
-#define TRACE_PROCESS_KTHREAD 1 /* Creation of a kernel thread */
-#define TRACE_PROCESS_FORK 2 /* A fork or clone occured */
-#define TRACE_PROCESS_EXIT 3 /* An exit occured */
-#define TRACE_PROCESS_WAIT 4 /* A wait occured */
-#define TRACE_PROCESS_SIGNAL 5 /* A signal has been sent */
-#define TRACE_PROCESS_WAKEUP 6 /* Wake up a process */
-#define TRACE_PROCESS_RELEASE 7 /* A task struct has been released */
-
-typedef struct _trace_process
-{
- uint8_t event_sub_id; /* Process event ID */
- uint32_t event_data1; /* Data associated with event */
- uint32_t event_data2;
-} LTT_PACKED_STRUCT trace_process;
-#define PROC_EVENT(X) ((trace_process*)X)
-
-/* TRACE_FILE_SYSTEM */
-#define TRACE_FILE_SYSTEM_BUF_WAIT_START 1 /* Starting to wait for a data buffer */
-#define TRACE_FILE_SYSTEM_BUF_WAIT_END 2 /* End to wait for a data buffer */
-#define TRACE_FILE_SYSTEM_EXEC 3 /* An exec occured */
-#define TRACE_FILE_SYSTEM_OPEN 4 /* An open occured */
-#define TRACE_FILE_SYSTEM_CLOSE 5 /* A close occured */
-#define TRACE_FILE_SYSTEM_READ 6 /* A read occured */
-#define TRACE_FILE_SYSTEM_WRITE 7 /* A write occured */
-#define TRACE_FILE_SYSTEM_SEEK 8 /* A seek occured */
-#define TRACE_FILE_SYSTEM_IOCTL 9 /* An ioctl occured */
-#define TRACE_FILE_SYSTEM_SELECT 10 /* A select occured */
-#define TRACE_FILE_SYSTEM_POLL 11 /* A poll occured */
-typedef struct _trace_file_system
-{
- uint8_t event_sub_id; /* File system event ID */
- uint32_t event_data1; /* Event data */
- uint32_t event_data2; /* Event data 2 */
- char* file_name; /* Name of file operated on */
-} LTT_PACKED_STRUCT trace_file_system;
-#define FS_EVENT(X) ((trace_file_system*)X)
-#define FS_EVENT_FILENAME(X) ((char*) ((X) + sizeof(trace_file_system)))
-
-/* TRACE_TIMER */
-#define TRACE_TIMER_EXPIRED 1 /* Timer expired */
-#define TRACE_TIMER_SETITIMER 2 /* Setting itimer occurred */
-#define TRACE_TIMER_SETTIMEOUT 3 /* Setting sched timeout occurred */
-typedef struct _trace_timer
-{
- uint8_t event_sub_id; /* Timer event ID */
- uint8_t event_sdata; /* Short data */
- uint32_t event_data1; /* Data associated with event */
- uint32_t event_data2;
-} LTT_PACKED_STRUCT trace_timer;
-#define TIMER_EVENT(X) ((trace_timer*)X)
-
-/* TRACE_MEMORY */
-#define TRACE_MEMORY_PAGE_ALLOC 1 /* Allocating pages */
-#define TRACE_MEMORY_PAGE_FREE 2 /* Freing pages */
-#define TRACE_MEMORY_SWAP_IN 3 /* Swaping pages in */
-#define TRACE_MEMORY_SWAP_OUT 4 /* Swaping pages out */
-#define TRACE_MEMORY_PAGE_WAIT_START 5 /* Start to wait for page */
-#define TRACE_MEMORY_PAGE_WAIT_END 6 /* End to wait for page */
-typedef struct _trace_memory
-{
- uint8_t event_sub_id; /* Memory event ID */
- unsigned long event_data; /* Data associated with event */
-} LTT_PACKED_STRUCT trace_memory;
-#define MEM_EVENT(X) ((trace_memory*)X)
-
-/* TRACE_SOCKET */
-#define TRACE_SOCKET_CALL 1 /* A socket call occured */
-#define TRACE_SOCKET_CREATE 2 /* A socket has been created */
-#define TRACE_SOCKET_SEND 3 /* Data was sent to a socket */
-#define TRACE_SOCKET_RECEIVE 4 /* Data was read from a socket */
-typedef struct _trace_socket
-{
- uint8_t event_sub_id; /* Socket event ID */
- uint32_t event_data1; /* Data associated with event */
- uint32_t event_data2; /* Data associated with event */
-} LTT_PACKED_STRUCT trace_socket;
-#define SOCKET_EVENT(X) ((trace_socket*)X)
-
-/* TRACE_IPC */
-#define TRACE_IPC_CALL 1 /* A System V IPC call occured */
-#define TRACE_IPC_MSG_CREATE 2 /* A message queue has been created */
-#define TRACE_IPC_SEM_CREATE 3 /* A semaphore was created */
-#define TRACE_IPC_SHM_CREATE 4 /* A shared memory segment has been created */
-typedef struct _trace_ipc
-{
- uint8_t event_sub_id; /* IPC event ID */
- uint32_t event_data1; /* Data associated with event */
- uint32_t event_data2; /* Data associated with event */
-} LTT_PACKED_STRUCT trace_ipc;
-#define IPC_EVENT(X) ((trace_ipc*)X)
-
-/* TRACE_NETWORK */
-#define TRACE_NETWORK_PACKET_IN 1 /* A packet came in */
-#define TRACE_NETWORK_PACKET_OUT 2 /* A packet was sent */
-typedef struct _trace_network
-{
- uint8_t event_sub_id; /* Network event ID */
- uint32_t event_data; /* Event data */
-} LTT_PACKED_STRUCT trace_network;
-#define NET_EVENT(X) ((trace_network*)X)
-
-/* Start of trace buffer information */
-typedef struct _trace_buffer_start
-{
- struct timeval Time; /* Time stamp of this buffer */
- uint32_t TSC; /* TSC of this buffer, if applicable */
- uint32_t ID; /* Unique buffer ID */
-} LTT_PACKED_STRUCT trace_buffer_start;
-
-/* End of trace buffer information */
-typedef struct _trace_buffer_end
-{
- struct timeval Time; /* Time stamp of this buffer */
- uint32_t TSC; /* TSC of this buffer, if applicable */
-} LTT_PACKED_STRUCT trace_buffer_end;
-
-/* Maximal size a custom event can have */
-#define CUSTOM_EVENT_MAX_SIZE 8192
-
-/* String length limits for custom events creation */
-#define CUSTOM_EVENT_TYPE_STR_LEN 20
-#define CUSTOM_EVENT_DESC_STR_LEN 100
-#define CUSTOM_EVENT_FORM_STR_LEN 256
-
-/* Type of custom event formats */
-#define CUSTOM_EVENT_FORMAT_TYPE_NONE 0
-#define CUSTOM_EVENT_FORMAT_TYPE_STR 1
-#define CUSTOM_EVENT_FORMAT_TYPE_HEX 2
-#define CUSTOM_EVENT_FORMAT_TYPE_XML 3
-#define CUSTOM_EVENT_FORMAT_TYPE_IBM 4
-
-typedef struct _trace_new_event
-{
- /* Basics */
- uint32_t id; /* Custom event ID */
- char type[CUSTOM_EVENT_TYPE_STR_LEN]; /* Event type description */
- char desc[CUSTOM_EVENT_DESC_STR_LEN]; /* Detailed event description */
-
- /* Custom formatting */
- uint32_t format_type; /* Type of formatting */
- char form[CUSTOM_EVENT_FORM_STR_LEN]; /* Data specific to format */
-} LTT_PACKED_STRUCT trace_new_event;
-#define NEW_EVENT(X) ((trace_new_event*) X)
-
-typedef struct _trace_custom
-{
- uint32_t id; /* Event ID */
- uint32_t data_size; /* Size of data recorded by event */
- void* data; /* Data recorded by event */
-} LTT_PACKED_STRUCT trace_custom;
-#define CUSTOM_EVENT(X) ((trace_custom*) X)
-
-/* TRACE_CHANGE_MASK */
-typedef struct _trace_change_mask
-{
- trace_event_mask mask; /* Event mask */
-} LTT_PACKED_STRUCT trace_change_mask;
-#define CHMASK_EVENT(X) ((trace_change_mask*) X)
-
-#endif /* __TRACE_TOOLKIT_LINUX_HEADER__ */
+++ /dev/null
-AM_CFLAGS = $(GLIB_CFLAGS)
-LIBS += $(GLIB_LIBS) $(M_LIBS)
-
-bin_PROGRAMS = convert
-
-convert_SOURCES = convert.c
-
-noinst_HEADERS = LTTTypes.h LinuxEvents.h
-
-EXTRA_DIST = core.xml sysInfo README
-convertdir = $(pkgdatadir)/convert
-convert_DATA = core.xml sysInfo README
+++ /dev/null
-The application 'convert' is used to convert an old format tracefile into a new
-format tracefile. It has several commandline parameters, the first is process file
-name, the second is a number (the number of cpu in the machine), the third is
-the first tracefile name(corresponding to the first cpu), the fourth is the
-second tracefile name(corresponding to the second cpu), the fifth is ...,
-the last one is root directory for the new trace (this can be omitted,
-by default it is 'foo')
-
-The command line looks like this:
- ./convert processfile_name the_number_of_cpu first_tracefile_name, ..., foo_dir
-
-There is also a script file 'sysInfo' which is used to get system information
-from your local machine, the information is saved in 'sysInfo.out' which will
-be read by 'convert' later. If the old tracefile is generated by other machine,
-then the 'sysInfo.out' should be gotten from that machine.
-
-'core.xml' is a facility file, after run 'convert', it needs to be copied to
-'foo_dir/eventdefs' directory
-
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-#include "LTTTypes.h"
-#include "LinuxEvents.h"
-
-#define TRACE_HEARTBEAT_ID 19
-#define PROCESS_FORK_ID 20
-#define PROCESS_EXIT_ID 21
-
-#define INFO_ENTRY 9
-#define OVERFLOW_FIGURE 0x100000000ULL
-
-typedef struct _new_process
-{
- uint32_t event_data1; /* Data associated with event */
- uint32_t event_data2;
-} LTT_PACKED_STRUCT new_process;
-
-#define write_to_buffer(DEST, SRC, SIZE) \
-do\
-{\
- memcpy(DEST, SRC, SIZE);\
- DEST += SIZE;\
-} while(0);
-
-int readFile(int fd, void * buf, size_t size, char * mesg)
-{
- ssize_t nbBytes = read(fd, buf, size);
-
- if((size_t)nbBytes != size) {
- if(nbBytes < 0) {
- perror("Error in readFile : ");
- } else {
- printf("%s\n",mesg);
- }
- exit(1);
- }
- return 0;
-}
-
-void getDataEndianType(char * size, char * endian)
-{
- int i = 1;
- char c = (char) i;
- int sizeInt=sizeof(int), sizeLong=sizeof(long), sizePointer=sizeof(void *);
-
- if(c == 1) strcpy(endian,"LITTLE_ENDIAN");
- else strcpy(endian, "BIG_ENDIAN");
-
- if(sizeInt == 2 && sizeLong == 4 && sizePointer == 4)
- strcpy(size,"LP32");
- else if(sizeInt == 4 && sizeLong == 4 && sizePointer == 4)
- strcpy(size,"ILP32");
- else if(sizeInt == 4 && sizeLong == 8 && sizePointer == 8)
- strcpy(size,"LP64");
- else if(sizeInt == 8 && sizeLong == 8 && sizePointer == 8)
- strcpy(size,"ILP64");
- else strcpy(size,"UNKNOWN");
-}
-
-#define BUFFER_SIZE 80
-
-typedef struct _buffer_start{
- uint32_t seconds;
- uint32_t nanoseconds;
- uint64_t cycle_count;
- uint32_t block_id;
-} __attribute__ ((packed)) buffer_start;
-
-typedef struct _buffer_end{
- uint32_t seconds;
- uint32_t nanoseconds;
- uint64_t cycle_count;
- uint32_t block_id;
-} __attribute__ ((packed)) buffer_end;
-
-
-typedef struct _heartbeat{
- uint32_t seconds;
- uint32_t nanoseconds;
- uint64_t cycle_count;
-} __attribute__ ((packed)) heartbeat;
-
-
-int main(int argc, char ** argv){
-
- int fd, fdCpu;
- FILE * fp;
- int fdFac, fdIntr, fdProc;
- char arch_size[BUFFER_SIZE];
- char endian[BUFFER_SIZE];
- char node_name[BUFFER_SIZE];
- char domainname[BUFFER_SIZE];
- char kernel_name[BUFFER_SIZE];
- char kernel_release[BUFFER_SIZE];
- char kernel_version[BUFFER_SIZE];
- char machine[BUFFER_SIZE];
- char processor[BUFFER_SIZE];
- char hardware_platform[BUFFER_SIZE];
- char operating_system[BUFFER_SIZE];
- int cpu;
- int ltt_block_size=0;
- int ltt_major_version=0;
- int ltt_minor_version=0;
- int ltt_log_cpu;
- guint ltt_trace_start_size = 0;
- char buf[BUFFER_SIZE];
- int i, k;
-
- uint8_t cpu_id;
-
- char foo[4*BUFFER_SIZE];
- char foo_eventdefs[4*BUFFER_SIZE];
- char foo_control[4*BUFFER_SIZE];
- char foo_cpu[4*BUFFER_SIZE];
- char foo_info[4*BUFFER_SIZE];
-
- char foo_control_facilities[4*BUFFER_SIZE];
- char foo_control_processes[4*BUFFER_SIZE];
- char foo_control_interrupts[4*BUFFER_SIZE];
- char foo_info_system[4*BUFFER_SIZE];
-
- struct stat lTDFStat;
- off_t file_size;
- int block_number, block_size;
- char * buffer, *buf_out, cpuStr[4*BUFFER_SIZE];
- char * buf_fac, * buf_intr, * buf_proc;
- void * write_pos, *write_pos_fac, * write_pos_intr, *write_pos_proc;
- trace_start_any *tStart;
- trace_buffer_start *tBufStart;
- trace_buffer_end *tBufEnd;
- trace_file_system * tFileSys;
- uint16_t newId, startId, tmpId;
- uint8_t evId;
- uint32_t time_delta, startTimeDelta;
- void * cur_pos, *end_pos;
- buffer_start start, start_proc, start_intr;
- buffer_end end, end_proc, end_intr;
- heartbeat beat;
- uint64_t adaptation_tsc; // (Mathieu)
- uint32_t size_lost;
- int nb_para;
-
- new_process process;
-
- if(argc < 4){
- printf("Usage : ./convert processfile_name number_of_cpu tracefile1 tracefile2 ... trace_creation_directory\n");
- printf("For more details, see README.\n");
- exit(1);
- }
-
- cpu = atoi(argv[2]);
- printf("cpu number = %d\n", cpu);
- nb_para = 3 + cpu;
-
- if(argc != nb_para && argc != nb_para+1){
- printf("need trace files and cpu number or root directory for the new tracefile\n");
- exit(1);
- }
-
- if(argc == nb_para){
- strcpy(foo, "foo");
- strcpy(foo_eventdefs, "foo/eventdefs");
- strcpy(foo_control, "foo/control");
- strcpy(foo_cpu, "foo/cpu");
- strcpy(foo_info, "foo/info");
- }else{
- strcpy(foo, argv[nb_para]);
- strcpy(foo_eventdefs, argv[nb_para]);
- strcat(foo_eventdefs,"/eventdefs");
- strcpy(foo_control, argv[nb_para]);
- strcat(foo_control,"/control");
- strcpy(foo_cpu, argv[nb_para]);
- strcat(foo_cpu,"/cpu");
- strcpy(foo_info, argv[nb_para]);
- strcat(foo_info,"/info");
- }
- strcpy(foo_control_facilities, foo_control);
- strcat(foo_control_facilities,"/facilities");
- strcpy(foo_control_processes, foo_control);
- strcat(foo_control_processes, "/processes");
- strcpy(foo_control_interrupts, foo_control);
- strcat(foo_control_interrupts, "/interrupts");
- strcpy(foo_info_system, foo_info);
- strcat(foo_info_system, "/system.xml");
-
-
- getDataEndianType(arch_size, endian);
- printf("Arch_size: %s, Endian: %s\n", arch_size, endian);
-
- fp = fopen("sysInfo.out","r");
- if(!fp){
- g_error("Unable to open file sysInfo.out\n");
- }
-
- for(i=0;i<INFO_ENTRY;i++){
- if(!fgets(buf,BUFFER_SIZE-1,fp))
- g_error("The format of sysInfo.out is not right\n");
- if(strncmp(buf,"node_name=",10)==0){
- strcpy(node_name,&buf[10]);
- node_name[strlen(node_name)-1] = '\0';
- }else if(strncmp(buf,"domainname=",11)==0){
- strcpy(domainname,&buf[11]);
- domainname[strlen(domainname)-1] = '\0';
- }else if(strncmp(buf,"kernel_name=",12)==0){
- strcpy(kernel_name,&buf[12]);
- kernel_name[strlen(kernel_name)-1] = '\0';
- }else if(strncmp(buf,"kernel_release=",15)==0){
- strcpy(kernel_release,&buf[15]);
- kernel_release[strlen(kernel_release)-1] = '\0';
- }else if(strncmp(buf,"kernel_version=",15)==0){
- strcpy(kernel_version,&buf[15]);
- kernel_version[strlen(kernel_version)-1] = '\0';
- }else if(strncmp(buf,"machine=",8)==0){
- strcpy(machine,&buf[8]);
- machine[strlen(machine)-1] = '\0';
- }else if(strncmp(buf,"processor=",10)==0){
- strcpy(processor,&buf[10]);
- processor[strlen(processor)-1] = '\0';
- }else if(strncmp(buf,"hardware_platform=",18)==0){
- strcpy(hardware_platform,&buf[18]);
- hardware_platform[strlen(hardware_platform)-1] = '\0';
- }else if(strncmp(buf,"operating_system=",17)==0){
- strcpy(operating_system,&buf[17]);
- operating_system[strlen(operating_system)-1] = '\0';
- }
- }
- fclose(fp);
-
- if(mkdir(foo, S_IFDIR | S_IRWXU | S_IRGRP | S_IROTH))
- g_error("can not make %s directory", foo);
- if(mkdir(foo_info, S_IFDIR | S_IRWXU | S_IRGRP | S_IROTH))
- g_error("can not make %s directory", foo_info);
- if(mkdir(foo_cpu, S_IFDIR | S_IRWXU | S_IRGRP | S_IROTH))
- g_error("can not make %s directory", foo_cpu);
- if(mkdir(foo_control, S_IFDIR | S_IRWXU | S_IRGRP | S_IROTH))
- g_error("can not make %s directory", foo_control);
- if(mkdir(foo_eventdefs, S_IFDIR | S_IRWXU | S_IRGRP | S_IROTH))
- g_error("can not make %s directory", foo_eventdefs);
-
- fp = fopen(foo_info_system,"w");
- if(!fp){
- g_error("Unable to open file system.xml\n");
- }
-
- fdFac = open(foo_control_facilities,O_CREAT | O_RDWR | O_TRUNC,S_IRUSR |S_IWUSR | S_IRGRP | S_IROTH);
- if(fdFac < 0){
- g_error("Unable to open file facilities\n");
- }
- fdIntr = open(foo_control_interrupts,O_CREAT | O_RDWR | O_TRUNC,S_IRUSR |S_IWUSR | S_IRGRP | S_IROTH);
- if(fdIntr<0){
- g_error("Unable to open file interrupts\n");
- }
- fdProc = open(foo_control_processes,O_CREAT | O_RDWR | O_TRUNC,S_IRUSR |S_IWUSR | S_IRGRP | S_IROTH);
- if(fdProc<0){
- g_error("Unable to open file process\n");
- }
-
-
- for(k=0;k<cpu;k++){
- fd = open(argv[nb_para-cpu+k], O_RDONLY, 0);
- if(fd < 0){
- g_error("Unable to open input data file %s\n", argv[nb_para-cpu+k]);
- }
-
- if(fstat(fd, &lTDFStat) < 0){
- g_error("Unable to get the status of the input data file\n");
- }
- file_size = lTDFStat.st_size;
-
- buffer = g_new(char, 4000);
- readFile(fd,(void*)buffer, 3500, "Unable to read block header");
-
- cur_pos= buffer;
- evId = *(uint8_t *)cur_pos;
- cur_pos += sizeof(uint8_t);
- newId = evId;
- time_delta = *(uint32_t*)cur_pos;
- cur_pos += sizeof(uint32_t);
- tBufStart = (trace_buffer_start*)cur_pos;
- cur_pos += sizeof(trace_buffer_start);
- cur_pos += sizeof(uint16_t); //Skip event size
-
- evId = *(uint8_t *)cur_pos;
- g_assert(evId == TRACE_START);
- cur_pos += sizeof(uint8_t); //skip EvId
- cur_pos += sizeof(uint32_t); //skip time delta
- tStart = (trace_start_any*)cur_pos;
- if(tStart->MagicNumber != TRACER_MAGIC_NUMBER)
- g_error("Trace magic number does not match : %x, should be %x",
- tStart->MagicNumber, TRACER_MAGIC_NUMBER);
- if(tStart->MajorVersion != TRACER_SUP_VERSION_MAJOR)
- g_error("Trace Major number does match : %hu, should be %u",
- tStart->MajorVersion, TRACER_SUP_VERSION_MAJOR);
-
- startId = newId;
- startTimeDelta = time_delta;
- start.seconds = tBufStart->Time.tv_sec;
- /* Fix (Mathieu) */
- start.nanoseconds = tBufStart->Time.tv_usec * 1000;
- start.cycle_count = tBufStart->TSC;
- start.block_id = tBufStart->ID;
- end.block_id = start.block_id;
-
-
- g_message("Trace version %hu.%hu detected\n",
- tStart->MajorVersion,
- tStart->MinorVersion);
- if(tStart->MinorVersion == 2) {
- trace_start_2_2* tStart_2_2 = (trace_start_2_2*)tStart;
- ltt_major_version = tStart_2_2->MajorVersion;
- ltt_minor_version = tStart_2_2->MinorVersion;
- ltt_block_size = tStart_2_2->BufferSize;
- ltt_log_cpu = tStart_2_2->LogCPUID;
- ltt_trace_start_size = sizeof(trace_start_2_2);
- /* Verify if it's a broken 2.2 format */
- if(*(uint8_t*)(cur_pos + sizeof(trace_start_2_2)) == 0) {
- /* Cannot have two trace start events. We cannot detect the problem
- * if the flight recording flag is set to 1, as it conflicts
- * with TRACE_SYSCALL_ENTRY.
- */
- g_warning("This is a 2.3 trace format that has a 2.2 tag. Please upgrade your kernel");
- g_message("Processing the trace as a 2.3 format\n");
-
- tStart->MinorVersion = 3;
- }
- }
-
- if(tStart->MinorVersion == 3) {
- trace_start_2_3* tStart_2_3 = (trace_start_2_3*)tStart;
- ltt_major_version = tStart_2_3->MajorVersion;
- ltt_minor_version = tStart_2_3->MinorVersion;
- ltt_block_size = tStart_2_3->BufferSize;
- ltt_log_cpu = tStart_2_3->LogCPUID;
- ltt_trace_start_size = sizeof(trace_start_2_3);
- /* We do not use the flight recorder information for now, because we
- * never use the .proc file anyway */
- }
-
- if(ltt_trace_start_size == 0)
- g_error("Minor version unknown : %hu. Supported minors : 2, 3",
- tStart->MinorVersion);
-
- block_size = ltt_block_size;//FIXME
- block_number = file_size/ltt_block_size;
-
- g_free(buffer);
- buffer = g_new(char, ltt_block_size);
- buf_fac = g_new(char, block_size);
- write_pos_fac = buf_fac;
- buf_intr = g_new(char, block_size);
- write_pos_intr = buf_intr;
- buf_proc = g_new(char, block_size);
- write_pos_proc = buf_proc;
-
- buf_out = g_new(char, block_size);
- write_pos = buf_out;
- sprintf(cpuStr,"%s/%d",foo_cpu,k);
- fdCpu = open(cpuStr, O_CREAT | O_RDWR | O_TRUNC,S_IRUSR |S_IWUSR | S_IRGRP | S_IROTH); //for cpu k
- if(fdCpu < 0) g_error("Unable to open cpu file %d\n", k);
- lseek(fd,0,SEEK_SET);
-
- for(i=0;i<block_number;i++){
- int event_count = 0;
-
- memset((void*)buf_out, 0, block_size);
- write_pos = buf_out;
- memset((void*)buf_intr, 0, block_size);
- memset((void*)buf_fac, 0, block_size);
- memset((void*)buf_proc, 0, block_size);
- write_pos_intr = buf_intr;
- write_pos_fac = buf_fac;
- write_pos_proc = buf_proc;
-
- memset((void*)buffer,0,ltt_block_size);
- readFile(fd,(void*)buffer, ltt_block_size, "Unable to read block header");
-
- cur_pos= buffer;
- evId = *(uint8_t *)cur_pos;
- cur_pos += sizeof(uint8_t);
- newId = evId;
- time_delta = *(uint32_t*)cur_pos;
- cur_pos += sizeof(uint32_t);
- tBufStart = (trace_buffer_start*)cur_pos;
- cur_pos += sizeof(trace_buffer_start);
- cur_pos += sizeof(uint16_t); //Skip event size
-
- startId = newId;
- startTimeDelta = time_delta;
- start.seconds = tBufStart->Time.tv_sec;
- /* usec -> nsec (Mathieu) */
- start.nanoseconds = tBufStart->Time.tv_usec * 1000;
- start.block_id = tBufStart->ID;
- end.block_id = start.block_id;
-
- end_pos = buffer + ltt_block_size; //end of the buffer
- size_lost = *(uint32_t*)(end_pos - sizeof(uint32_t));
-
- end_pos = buffer + ltt_block_size - size_lost ; //buffer_end event
- if(ltt_log_cpu){
- tBufEnd = (trace_buffer_end*)(end_pos + 2 * sizeof(uint8_t)+sizeof(uint32_t));
- }else{
- tBufEnd = (trace_buffer_end*)(end_pos+sizeof(uint8_t)+sizeof(uint32_t));
- }
- end.seconds = tBufEnd->Time.tv_sec;
- /* usec -> nsec (Mathieu) */
- end.nanoseconds = tBufEnd->Time.tv_usec * 1000;
- // only 32 bits :(
- //end.cycle_count = tBufEnd->TSC;
-
- //skip buffer start and trace start events
- if(i==0) {
- //the first block
- adaptation_tsc = (uint64_t)tBufStart->TSC;
- cur_pos = buffer + sizeof(trace_buffer_start)
- + ltt_trace_start_size
- + 2*(sizeof(uint8_t)
- + sizeof(uint16_t)+sizeof(uint32_t));
- } else {
- //other blocks
- cur_pos = buffer + sizeof(trace_buffer_start)
- + sizeof(uint8_t)
- + sizeof(uint16_t)+sizeof(uint32_t);
-
- /* Fix (Mathieu) */
- if(time_delta < (0xFFFFFFFFULL&adaptation_tsc)) {
- /* Overflow */
- adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL)
- + 0x100000000ULL
- + (uint64_t)time_delta;
- } else {
- /* No overflow */
- adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + time_delta;
- }
-
- }
- start.cycle_count = adaptation_tsc;
-
- //write start block event
- write_to_buffer(write_pos,(void*)&startId, sizeof(uint16_t));
- write_to_buffer(write_pos,(void*)&startTimeDelta, sizeof(uint32_t));
- write_to_buffer(write_pos,(void*)&start, sizeof(buffer_start));
-
- //write start block event into processes and interrupts files
- write_to_buffer(write_pos_intr,(void*)&startId, sizeof(uint16_t));
- write_to_buffer(write_pos_intr,(void*)&startTimeDelta, sizeof(uint32_t));
- start_intr = start;
- start_intr.nanoseconds -= 20;
- write_to_buffer(write_pos_intr,(void*)&start_intr, sizeof(buffer_start));
-
- write_to_buffer(write_pos_proc,(void*)&startId, sizeof(uint16_t));
- write_to_buffer(write_pos_proc,(void*)&startTimeDelta, sizeof(uint32_t));
- start_proc = start;
- start_proc.nanoseconds -= 40;
- write_to_buffer(write_pos_proc,(void*)&start_proc, sizeof(buffer_start));
-
- //parse *.proc file to get process and irq info
- if(i == 0){
- int lIntID; /* Interrupt ID */
- int lPID, lPPID; /* Process PID and Parent PID */
- char lName[256]; /* Process name */
- FILE * fProc;
- uint16_t defaultId;
- trace_irq_entry irq;
-
- fProc = fopen(argv[1],"r");
- if(!fProc){
- g_error("Unable to open file %s\n", argv[1]);
- }
-
- while(fscanf(fProc, "PID: %d; PPID: %d; NAME: %s\n", &lPID, &lPPID, lName) > 0){
- defaultId = PROCESS_FORK_ID;
- process.event_data1 = lPID;
- process.event_data2 = lPPID;
- write_to_buffer(write_pos_proc,(void*)&defaultId, sizeof(uint16_t));
- write_to_buffer(write_pos_proc,(void*)&startTimeDelta, sizeof(uint32_t));
- write_to_buffer(write_pos_proc,(void*)&process, sizeof(new_process));
- }
-
- while(fscanf(fProc, "IRQ: %d; NAME: ", &lIntID) > 0){
- /* Read 'til the end of the line */
- fgets(lName, 200, fProc);
-
- defaultId = TRACE_IRQ_ENTRY;
- irq.irq_id = lIntID;
- irq.kernel = 1;
- write_to_buffer(write_pos_intr,(void*)&defaultId, sizeof(uint16_t));
- write_to_buffer(write_pos_intr,(void*)&startTimeDelta, sizeof(uint32_t));
- write_to_buffer(write_pos_intr,(void*)&irq, sizeof(trace_irq_entry));
- }
- fclose(fProc);
- }
-
- while(1){
- int event_size;
- uint64_t timeDelta;
- uint8_t subId;
-
- if(ltt_log_cpu){
- cpu_id = *(uint8_t*)cur_pos;
- cur_pos += sizeof(uint8_t);
- }
- evId = *(uint8_t *)cur_pos;
- newId = evId;
- if(evId == TRACE_HEARTBEAT) {
- newId = TRACE_HEARTBEAT_ID;
- }
- cur_pos += sizeof(uint8_t);
- time_delta = *(uint32_t*)cur_pos;
- cur_pos += sizeof(uint32_t);
-
-
- //write event_id and time_delta
- write_to_buffer(write_pos,(void*)&newId,sizeof(uint16_t));
- write_to_buffer(write_pos,(void*)&time_delta, sizeof(uint32_t));
-
- /* Fix (Mathieu) */
- if(time_delta < (0xFFFFFFFFULL&adaptation_tsc)) {
- /* Overflow */
- adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + 0x100000000ULL
- + (uint64_t)time_delta;
- } else {
- /* No overflow */
- adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + time_delta;
- }
-
-
- if(evId == TRACE_BUFFER_END){
-#if 0
- /* Fix (Mathieu) */
- if(time_delta < (0xFFFFFFFFULL&adaptation_tsc)) {
- /* Overflow */
- adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + 0x100000000ULL
- + (uint64_t)time_delta;
- } else {
- /* No overflow */
- adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + time_delta;
- }
-#endif //0
- end.cycle_count = adaptation_tsc;
- int size = (void*)buf_out + block_size - write_pos
- - sizeof(buffer_end) - sizeof(uint32_t);
-
- /* size _lost_ ? */
- //int size = (void*)buf_out + block_size - write_pos
- // + sizeof(uint16_t) + sizeof(uint32_t);
- g_assert((void*)write_pos < (void*)buf_out + block_size);
- write_to_buffer(write_pos,(void*)&end,sizeof(buffer_end));
- write_pos = buf_out + block_size - sizeof(uint32_t);
- write_to_buffer(write_pos,(void*)&size, sizeof(uint32_t));
- write(fdCpu,(void*)buf_out, block_size);
-
- //write out processes and intrrupts files
- {
- int size_intr = block_size + (void*)buf_intr - write_pos_intr
- - sizeof(buffer_end) - sizeof(uint32_t);
- int size_proc = block_size + (void*)buf_proc - write_pos_proc
- - sizeof(buffer_end) - sizeof(uint32_t);
- //int size_intr = block_size - (write_pos_intr - (void*)buf_intr);
- //int size_proc = block_size - (write_pos_proc - (void*)buf_proc);
- write_to_buffer(write_pos_intr,(void*)&newId,sizeof(uint16_t));
- write_to_buffer(write_pos_intr,(void*)&time_delta, sizeof(uint32_t));
- end_intr = end;
- end_intr.nanoseconds -= 20;
- write_to_buffer(write_pos_intr,(void*)&end_intr,sizeof(buffer_start));
-
- write_to_buffer(write_pos_proc,(void*)&newId,sizeof(uint16_t));
- write_to_buffer(write_pos_proc,(void*)&time_delta, sizeof(uint32_t));
- end_proc = end;
- end_proc.nanoseconds -= 40;
- write_to_buffer(write_pos_proc,(void*)&end_proc,sizeof(buffer_start));
-
- write_pos_intr = buf_intr + block_size - sizeof(uint32_t);
- write_pos_proc = buf_proc + block_size - sizeof(uint32_t);
- write_to_buffer(write_pos_intr,(void*)&size_intr, sizeof(uint32_t));
- write_to_buffer(write_pos_proc,(void*)&size_proc, sizeof(uint32_t));
- //for now don't output processes and interrupt information
- // write(fdIntr,(void*)buf_intr,block_size);
- // write(fdProc,(void*)buf_proc,block_size);
- }
- break;
- }
-
- event_count++;
- switch(evId){
- case TRACE_SYSCALL_ENTRY:
- event_size = sizeof(trace_syscall_entry);
- break;
- case TRACE_SYSCALL_EXIT:
- event_size = 0;
- break;
- case TRACE_TRAP_ENTRY:
- event_size = sizeof(trace_trap_entry);
- break;
- case TRACE_TRAP_EXIT:
- event_size = 0;
- break;
- case TRACE_IRQ_ENTRY:
- event_size = sizeof(trace_irq_entry);
- timeDelta = time_delta;
- write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t));
- write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint32_t));
- write_to_buffer(write_pos_intr,cur_pos, event_size);
- break;
- case TRACE_IRQ_EXIT:
- event_size = 0;
- timeDelta = time_delta;
- write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t));
- write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint32_t));
- break;
- case TRACE_SCHEDCHANGE:
- event_size = sizeof(trace_schedchange);
- break;
- case TRACE_KERNEL_TIMER:
- event_size = 0;
- break;
- case TRACE_SOFT_IRQ:
- event_size = sizeof(trace_soft_irq);
- // timeDelta = time_delta;
- // write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t));
- // write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint32_t));
- // write_to_buffer(write_pos_intr,cur_pos, event_size);
- break;
- case TRACE_PROCESS:
- event_size = sizeof(trace_process);
- timeDelta = time_delta;
- subId = *(uint8_t*)cur_pos;
- if(subId == TRACE_PROCESS_FORK || subId ==TRACE_PROCESS_EXIT){
- if( subId == TRACE_PROCESS_FORK)tmpId = PROCESS_FORK_ID;
- else tmpId = PROCESS_EXIT_ID;
- write_to_buffer(write_pos_proc,(void*)&tmpId, sizeof(uint16_t));
- write_to_buffer(write_pos_proc,(void*)&timeDelta, sizeof(uint32_t));
-
- process = *(new_process*)(cur_pos + sizeof(uint8_t));
- write_to_buffer(write_pos_proc,(void*)&process, sizeof(new_process));
- }
- break;
- case TRACE_FILE_SYSTEM:
- event_size = sizeof(trace_file_system)- sizeof(char*);
- break;
- case TRACE_TIMER:
- event_size = sizeof(trace_timer);
- break;
- case TRACE_MEMORY:
- event_size = sizeof(trace_memory);
- break;
- case TRACE_SOCKET:
- event_size = sizeof(trace_socket);
- break;
- case TRACE_IPC:
- event_size = sizeof(trace_ipc);
- break;
- case TRACE_NETWORK:
- event_size = sizeof(trace_network);
- break;
- case TRACE_HEARTBEAT:
- beat.seconds = 0;
- beat.nanoseconds = 0;
- beat.cycle_count = adaptation_tsc;
- event_size = 0;
-
- write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t));
- write_to_buffer(write_pos_intr,(void*)&time_delta, sizeof(uint32_t));
- write_to_buffer(write_pos_intr,(void*)&beat, sizeof(heartbeat));
- write_to_buffer(write_pos_proc,(void*)&newId, sizeof(uint16_t));
- write_to_buffer(write_pos_proc,(void*)&time_delta, sizeof(uint32_t));
- write_to_buffer(write_pos_proc,(void*)&beat, sizeof(heartbeat));
- break;
- default:
- event_size = -1;
- break;
- }
- if(evId != TRACE_FILE_SYSTEM && event_size >=0){
- write_to_buffer(write_pos, cur_pos, event_size);
-
- if(evId == TRACE_HEARTBEAT){
- write_to_buffer(write_pos, (void*)&beat, sizeof(heartbeat));
- }
-
- cur_pos += event_size + sizeof(uint16_t); //skip data_size
- }else if(evId == TRACE_FILE_SYSTEM){
- size_t nbBytes;
- char c = '\0';
- tFileSys = (trace_file_system*)cur_pos;
- subId = tFileSys->event_sub_id;
- if(subId == TRACE_FILE_SYSTEM_OPEN || subId == TRACE_FILE_SYSTEM_EXEC){
- nbBytes = tFileSys->event_data2 +1;
- }else nbBytes = 0;
-
- write_to_buffer(write_pos, cur_pos, event_size);
- cur_pos += event_size + sizeof(char*);
- if(nbBytes){
- write_to_buffer(write_pos, cur_pos, nbBytes);
- }else{
- write_to_buffer(write_pos, (void*)&c, 1);
- }
- cur_pos += nbBytes + sizeof(uint16_t); //skip data_size
- }else if(event_size == -1){
- printf("Unknown event: evId=%d, i=%d, event_count=%d\n", newId, i, event_count);
- exit(1);
- }
- } //end while(1)
- }
- close(fd);
- close(fdCpu);
- g_free(buffer);
- buffer = NULL;
- g_free(buf_fac);
- g_free(buf_intr);
- g_free(buf_proc);
- g_free(buf_out);
- }
-
-
-
-
-
- //write to system.xml
- fprintf(fp,"<system \n");
- fprintf(fp,"node_name=\"%s\" \n", node_name);
- fprintf(fp,"domainname=\"%s\" \n", domainname);
- fprintf(fp,"cpu=\"%d\" \n", cpu);
- fprintf(fp,"arch_size=\"%s\" \n", arch_size);
- fprintf(fp,"endian=\"%s\" \n",endian);
- fprintf(fp,"kernel_name=\"%s\" \n",kernel_name);
- fprintf(fp,"kernel_release=\"%s\" \n",kernel_release);
- fprintf(fp,"kernel_version=\"%s\" \n",kernel_version);
- fprintf(fp,"machine=\"%s\" \n",machine);
- fprintf(fp,"processor=\"%s\" \n",processor);
- fprintf(fp,"hardware_platform=\"%s\" \n",hardware_platform);
- fprintf(fp,"operating_system=\"%s\" \n",operating_system);
- fprintf(fp,"ltt_major_version=\"%d\" \n",ltt_major_version);
- fprintf(fp,"ltt_minor_version=\"%d\" \n",ltt_minor_version);
- fprintf(fp,"ltt_block_size=\"%d\" \n",ltt_block_size);
- fprintf(fp,">\n");
- fprintf(fp,"This is just a test\n");
- fprintf(fp,"</system>\n");
- fflush(fp);
-
- close(fdFac);
- close(fdIntr);
- close(fdProc);
- fclose(fp);
-
- g_message("Conversion completed. Don't forget to copy core.xml to eventdefs directory\n");
-
- return 0;
-}
-
+++ /dev/null
-<facility name=core>
- <description>The core facility contains the basic events</description>
-
- <event name=facility_load>
- <description>Facility used in the trace</description>
- <struct>
- <field name="name"><string/></field>
- <field name="checksum"><uint size=4/></field>
- <field name="base_code"><uint size=4/></field>
- </struct>
- </event>
-
- <event name=syscall_entry>
- <description>Entry in a given system call</description>
- <struct>
- <field name="syscall_id"> <description>Syscall entry number in entry.S</description> <uint size=1/> </field>
- <field name="address"> <description>Address from which call was made</description> <uint size=4/> </field>
- </struct>
- </event>
-
- <event name=syscall_exit>
- <description>Exit from a given system call</description>
- </event>
-
- <event name=trap_entry>
- <description>Entry in a trap</description>
- <struct>
- <field name="trap_id"> <description>Trap number</description> <uint size=2/> </field>
- <field name="address"> <description>Address where trap occured</description> <uint size=4/> </field>
- </struct>
- </event>
-
- <event name=trap_exit>
- <description>Exit from a trap</description>
- </event>
-
- <event name=irq_entry>
- <description>Entry in an irq</description>
- <struct>
- <field name="irq_id"> <description>IRQ number</description> <uint size=1/> </field>
- <field name="kernel"> <description>Are we executing kernel code</description> <uint size=1/> </field>
- </struct>
- </event>
-
- <event name=irq_exit>
- <description>Exit from an IRQ</description>
- </event>
-
- <event name=schedchange>
- <description>Scheduling change</description>
- <struct>
- <field name="out"> <description>Outgoing process</description> <uint size=4/> </field>
- <field name="in"> <description>Incoming process</description> <uint size=4/> </field>
- <field name="out_state"> <description>Outgoing process' state</description> <uint size=4/> </field>
- </struct>
- </event>
-
- <event name=kernel_timer>
- <description>The kernel timer routine has been called</description>
- </event>
-
- <event name=soft_irq>
- <description>Hit key part of soft-irq management</description>
- <struct>
- <field name="event_sub_id"> <description>Soft-irq event Id</description>
- <enum size=1>
- <label name=TRACE_EV_SOFT_IRQ_BOTTOM_HALF value=1/>
- <label name=TRACE_EV_SOFT_IRQ_SOFT_IRQ/>
- <label name=TRACE_EV_SOFT_IRQ_TASKLET_ACTION/>
- <label name=TRACE_EV_SOFT_IRQ_TASKLET_HI_ACTION/>
- </enum>
- </field>
-
- <field name="event_data"> <description>Data associated with event</description> <uint size=4/> </field>
- </struct>
- </event>
-
- <event name=process>
- <description>Hit key part of process management</description>
- <struct>
- <field name="event_sub_id"> <description>Process event ID</description>
- <enum size=1>
- <label name=TRACE_EV_PROCESS_KTHREAD value=1/>
- <label name=TRACE_EV_PROCESS_FORK/>
- <label name=TRACE_EV_PROCESS_EXIT/>
- <label name=TRACE_EV_PROCESS_WAIT/>
- <label name=TRACE_EV_PROCESS_SIGNAL/>
- <label name=TRACE_EV_PROCESS_WAKEUP/>
- <label name=TRACE_EV_PROCESS_RELEASE/>
- </enum>
- </field>
-
- <field name="event_data1"> <description>Data associated with event</description> <uint size=4/> </field>
- <field name="event_data2"> <description>Data associated with event</description> <uint size=4/> </field>
- </struct>
- </event>
-
- <event name=file_system>
- <description>Hit key part of file system</description>
- <struct>
- <field name="event_sub_id"> <description>File system event ID</description>
- <enum size=1>
- <label name=TRACE_EV_FILE_SYSTEM_BUF_WAIT_START value=1/>
- <label name=TRACE_EV_FILE_SYSTEM_BUF_WAIT_END/>
- <label name=TRACE_EV_FILE_SYSTEM_EXEC/>
- <label name=TRACE_EV_FILE_SYSTEM_OPEN/>
- <label name=TRACE_EV_FILE_SYSTEM_CLOSE/>
- <label name=TRACE_EV_FILE_SYSTEM_READ/>
- <label name=TRACE_EV_FILE_SYSTEM_WRITE/>
- <label name=TRACE_EV_FILE_SYSTEM_SEEK/>
- <label name=TRACE_EV_FILE_SYSTEM_IOCTL/>
- <label name=TRACE_EV_FILE_SYSTEM_SELECT/>
- <label name=TRACE_EV_FILE_SYSTEM_POLL/>
- </enum>
- </field>
-
- <field name="event_data1"> <description>Event data </description> <uint size=4/> </field>
- <field name="event_data2"> <description>Event data 2</description> <uint size=4/> </field>
- <field name="file_name"> <description>Name of file operated on </description> <string/> </field>
- </struct>
- </event>
-
- <event name=timer>
- <description>Hit key part of timer management</description>
- <struct>
- <field name="event_sub_id"> <description>Timer event ID</description>
- <enum size=1>
- <label name=TRACE_EV_TIMER_EXPIRED value=1/>
- <label name=TRACE_EV_TIMER_SETITIMER/>
- <label name=TRACE_EV_TIMER_SETTIMEOUT/>
- </enum>
- </field>
-
- <field name="event_sdata"> <description>Short data</description> <uint size=1/> </field>
- <field name="event_data1"> <description>Data associated with event</description> <uint size=4/> </field>
- <field name="event_data2"> <description>Data associated with event</description> <uint size=4/> </field>
- </struct>
- </event>
-
- <event name=memory>
- <description>Hit key part of memory management</description>
- <struct>
- <field name="event_sub_id"> <description>Memory event ID</description>
- <enum size=1>
- <label name=TRACE_EV_MEMORY_PAGE_ALLOC value=1/>
- <label name=TRACE_EV_MEMORY_PAGE_FREE/>
- <label name=TRACE_EV_MEMORY_SWAP_IN/>
- <label name=TRACE_EV_MEMORY_SWAP_OUT/>
- <label name=TRACE_EV_MEMORY_PAGE_WAIT_START/>
- <label name=TRACE_EV_MEMORY_PAGE_WAIT_END/>
- </enum>
- </field>
-
- <field name="event_data"> <description>Data associated with event</description> <uint size=4/> </field>
- </struct>
- </event>
-
- <event name=socket>
- <description>Hit key part of socket communication</description>
- <struct>
- <field name="event_sub_id"> <description>Memory event ID</description>
- <enum size=1>
- <label name=TRACE_EV_SOCKET_CALL value=1/>
- <label name=TRACE_EV_SOCKET_CREATE/>
- <label name=TRACE_EV_SOCKET_SEND/>
- <label name=TRACE_EV_SOCKET_RECEIVE/>
- </enum>
- </field>
-
- <field name="event_data1"> <description>Data associated with event</description> <uint size=4/> </field>
- <field name="event_data2"> <description>Data associated with event</description> <uint size=4/> </field>
- </struct>
- </event>
-
- <event name=ipc>
- <description>Hit key part of System V IPC</description>
- <struct>
- <field name="event_sub_id"> <description>Memory event ID</description>
- <enum size=1>
- <label name=TRACE_EV_IPC_CALL value=1/>
- <label name=TRACE_EV_IPC_MSG_CREATE/>
- <label name=TRACE_EV_IPC_SEM_CREATE/>
- <label name=TRACE_EV_IPC_SHM_CREATE/>
- </enum>
- </field>
-
- <field name="event_data1"> <description>Data associated with event</description> <uint size=4/> </field>
- <field name="event_data2"> <description>Data associated with event</description> <uint size=4/> </field>
- </struct>
- </event>
-
- <event name=network>
- <description>Hit key part of network communication</description>
- <struct>
- <field name="event_sub_id"> <description>Memory event ID</description>
- <enum size=1>
- <label name=TRACE_EV_NETWORK_PACKET_IN value=1/>
- <label name=TRACE_EV_NETWORK_PACKET_OUT/>
- </enum>
- </field>
-
- <field name="event_data"> <description>Data associated with event</description> <uint size=4/> </field>
- </struct>
- </event>
-
- <event name=block_start>
- <description>Block start timestamp</description>
- <typeref name=block_timestamp/>
- </event>
-
- <event name=block_end>
- <description>Block end timestamp</description>
- <typeref name=block_timestamp/>
- </event>
-
- <event name=time_heartbeat>
- <description>System time values sent periodically to minimize cycle counter
- drift with respect to real time clock and to detect cycle counter roolovers
- </description>
- <typeref name=timestamp/>
- </event>
-
- <type name=block_timestamp>
- <struct>
- <field name=timestamp><typeref name=timestamp/></field>
- <field name=block_id><uint size=4/></field>
- </struct>
- </type>
-
- <type name=timestamp>
- <struct>
- <field name=time><typeref name=timespec/></field>
- <field name="cycle_count"><uint size=8/></field>
- </struct>
- </type>
-
- <type name=timespec>
- <struct>
- <field name="seconds"><uint size=4/></field>
- <field name="nanoseconds"><uint size=4/></field>
- </struct>
- </type>
-
-
- <event name=process_fork>
- <description>Fork a new process</description>
- <struct>
- <field name="child_pid"> <description>Data associated with event</description> <uint size=4/> </field>
- <field name="event_data2"> <description>Data associated with event</description> <uint size=4/> </field>
- </struct>
- </event>
-
- <event name=process_exit>
- <description>Exit from a process</description>
- <struct>
- <field name="event_data1"> <description>Data associated with event</description> <uint size=4/> </field>
- <field name="event_data2"> <description>Data associated with event</description> <uint size=4/> </field>
- </struct>
- </event>
-
-</facility>
-
-
+++ /dev/null
-#!/bin/bash
-
-# DO NOT FORGET TO DISABLE ALL THE JAVA OPTIONS IN NETSCAPE
-# OTHERWISE IT WILL DIE ...
-
-outputFile=sysInfo.out
-
-NODE_NAME=`uname -n`
-echo "node_name="$NODE_NAME > $outputFile
-
-DOMAINNAME="`hostname --domain`"
-echo "domainname="$DOMAINNAME >> $outputFile
-
-KERNEL_NAME="`uname -s`"
-echo "kernel_name="$KERNEL_NAME >> $outputFile
-
-KERNEL_RELEASE="`uname -r`"
-echo "kernel_release="$KERNEL_RELEASE >> $outputFile
-
-KERNEL_VERSION="`uname -v`"
-echo "kernel_version="$KERNEL_VERSION >> $outputFile
-
-MACHINE="`uname -m`"
-echo "machine="$MACHINE >> $outputFile
-
-
-# not available anymore in uname version 5 and newer
-PROCESSOR="`uname -p`"
-echo "processor="$PROCESSOR >> $outputFile
-
-# not available anymore in uname version 5 and newer
-HARDWARE_PLATFORM="`uname -i`"
-echo "hardware_platform="$HARDWARE_PLATFORM >> $outputFile
-
-OPERATING_SYSTEM="`uname -o`"
-echo "operating_system="$OPERATING_SYSTEM >> $outputFile
-
-
-#export $NODE_NAME
-#export $NODE_NAME $DOMAINNAME $KERNEL_NAME $KERNEL_RELEASE $KERNEL_VERSION $MACHINE $PROCESSOR $HARDWARE_PLATFORM $OPERATING_SYSTEM
-
-
-
-#/sbin/lilo -C "$liloConf"
-