-#ifndef TRACEFILE_H
-#define TRACEFILE_H
+/* This file is part of the Linux Trace Toolkit trace reading library
+ * Copyright (C) 2003-2004 Michel Dagenais
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License Version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef TRACE_H
+#define TRACE_H
#include <ltt/ltt.h>
/* A trace is specified as a pathname to the directory containing all the
- associated data (control tracefile, per cpu tracefiles, event
+ associated data (control tracefiles, per cpu tracefiles, event
descriptions...).
When a trace is closed, all the associated facilities, types and fields
are released as well. */
-ltt_trace *ltt_trace_open(char *pathname);
+LttTrace *ltt_trace_open(const char *pathname);
-void ltt_trace_close(ltt_trace *t);
+/* copy reopens a trace */
+LttTrace *ltt_trace_copy(LttTrace *self);
+char * ltt_trace_name(LttTrace *t);
-/* A trace may be queried for its architecture type (e.g., "i386",
- "powerpc", "powerpcle", "s390", "s390x"), its architecture variant
- (e.g., "att" versus "sun" for m68k), its operating system (e.g., "linux",
- "bsd"), its generic architecture, and the machine identity (e.g., system
- host name). All character strings belong to the associated tracefile
- and are freed when it is closed. */
+void ltt_trace_close(LttTrace *t);
-char *ltt_tracefile_arch_type(ltt_trace *t);
+LttSystemDescription *ltt_trace_system_description(LttTrace *t);
-char *ltt_tracefile_arch_variant(ltt_trace *t);
-char *ltt_tracefile_system_type(ltt_trace *t);
+/* Functions to discover the facilities in the trace. Once the number
+ of facilities is known, they may be accessed by position. Multiple
+ versions of a facility (same name, different checksum) have consecutive
+ positions. */
-ltt_arch_size ltt_tracefile_arch_size(ltt_trace *t);
+unsigned ltt_trace_facility_number(LttTrace *t);
-ltt_arch_endian ltt_tracefile_arch_endian(ltt_trace *t);
+LttFacility *ltt_trace_facility_get(LttTrace *t, unsigned i);
+LttFacility * ltt_trace_facility_by_id(LttTrace * trace, unsigned id);
-/* Hostname of the system where the trace was recorded */
+/* Look for a facility by name. It returns the number of facilities found
+ and sets the position argument to the first found. Returning 0, the named
+ facility is unknown, returning 1, the named facility is at the specified
+ position, returning n, the facilities are from position to
+ position + n - 1. */
-char *ltt_trace_system_name(ltt_tracefile *t);
+unsigned ltt_trace_facility_find(LttTrace *t, char *name, unsigned *position);
-/* SMP multi-processors have 2 or more CPUs */
+/* Functions to discover all the event types in the trace */
-unsigned ltt_trace_cpu_number(ltt_trace *t);
+unsigned ltt_trace_eventtype_number(LttTrace *t);
+LttEventType *ltt_trace_eventtype_get(LttTrace *t, unsigned i);
-/* Start and end time of the trace and its duration */
-ltt_time ltt_tracefile_time_start(ltt_trace *t);
+/* There is one "per cpu" tracefile for each CPU, numbered from 0 to
+ the maximum number of CPU in the system. When the number of CPU installed
+ is less than the maximum, some positions are unused. There are also a
+ number of "control" tracefiles (facilities, interrupts...). */
-ltt_time ltt_tracefile_time_end(ltt_trace *t);
+unsigned ltt_trace_control_tracefile_number(LttTrace *t);
-ltt_time ltt_tracefile_duration(ltt_tracefile *t);
+unsigned ltt_trace_per_cpu_tracefile_number(LttTrace *t);
-/* Functions to discover the facilities in the trace */
+/* It is possible to search for the tracefiles by name or by CPU position.
+ The index within the tracefiles of the same type is returned if found
+ and a negative value otherwise. */
-unsigned ltt_trace_facility_number(ltt_trace *t);
+int ltt_trace_control_tracefile_find(LttTrace *t, char *name);
-ltt_facility *ltt_trace_facility_get(ltt_trace *t, unsigned i);
+int ltt_trace_per_cpu_tracefile_find(LttTrace *t, unsigned i);
-ltt_facility *ltt_trace_facility_get_by_name(ltt_trace *t, char *name);
+/* Get a specific tracefile */
-/* Functions to discover all the event types in the trace */
+LttTracefile *ltt_trace_control_tracefile_get(LttTrace *t, unsigned i);
-unsigned ltt_trace_eventtype_number(ltt_tracefile *t);
+LttTracefile *ltt_trace_per_cpu_tracefile_get(LttTrace *t, unsigned i);
-ltt_eventtype *ltt_trace_eventtype_get(ltt_tracefile *t, unsigned i);
+/* Get the start time and end time of the trace */
-/* A trace typically contains one "control" tracefile with important events
- (for all CPUs), and one tracefile with ordinary events per cpu.
- The tracefiles in a trace may be enumerated for each category
- (all cpu and per cpu). The total number of tracefiles and of CPUs
- may also be obtained. */
+void ltt_trace_time_span_get(LttTrace *t, LttTime *start, LttTime *end);
-unsigned int ltt_trace_tracefile_number(ltt_trace *t);
-unsigned int ltt_trace_tracefile_number_per_cpu(ltt_trace *t);
+/* Get the name of a tracefile */
-unsigned int ltt_trace_tracefile_number_all_cpu(ltt_trace *t);
+char *ltt_tracefile_name(LttTracefile *tf);
-ltt_tracefile *ltt_trace_tracefile_get_per_cpu(ltt_trace *t, unsigned i);
-ltt_tracefile *ltt_trace_tracefile_get_all_cpu(ltt_trace *t, unsigned i);
+/* Get the number of blocks in the tracefile */
-char *ltt_tracefile_name(ltt_tracefile *tf);
+unsigned ltt_tracefile_block_number(LttTracefile *tf);
/* Seek to the first event of the trace with time larger or equal to time */
-int ltt_tracefile_seek_time(ltt_tracefile *t, ltt_time time);
+void ltt_tracefile_seek_time(LttTracefile *t, LttTime time);
+/* Seek to the first event with position equal or larger to ep */
+
+void ltt_tracefile_seek_position(LttTracefile *t,
+ LttEventPosition *ep);
/* Read the next event */
-ltt_event *ltt_tracefile_read(ltt_tracefile *t);
+LttEvent *ltt_tracefile_read(LttTracefile *t);
+
+/* open tracefile */
+
+LttTracefile * ltt_tracefile_open(LttTrace *t, char * tracefile_name);
+
+void ltt_tracefile_open_cpu(LttTrace *t, char * tracefile_name);
+
+void ltt_tracefile_open_control(LttTrace *t, char * control_name);
+
+
+/* obtain the time of an event */
+
+LttTime getEventTime(LttTracefile * tf);
+
+
+/* get the data type size and endian type of the local machine */
+
+void getDataEndianType(LttArchSize * size, LttArchEndian * endian);
+
+/* get an integer number */
+
+int getIntNumber(int size1, void *evD);
+
+
+/* get the node name of the system */
+
+char * ltt_trace_system_description_node_name (LttSystemDescription * s);
+
+
+/* get the domain name of the system */
+
+char * ltt_trace_system_description_domain_name (LttSystemDescription * s);
+
+
+/* get the description of the system */
+
+char * ltt_trace_system_description_description (LttSystemDescription * s);
+
+
+/* get the start time of the trace */
+
+LttTime ltt_trace_system_description_trace_start_time(LttSystemDescription *s);
#endif // TRACE_H