@@ -4,7 +4,7 @@ libtracefs(3)
NAME
----
tracefs_local_events, tracefs_local_events_system, tracefs_fill_local_events,
-tracefs_load_cmdlines -
+tracefs_load_cmdlines, tracefs_load_headers -
Initialize a tep handler with trace events from the local system.
SYNOPSIS
@@ -17,6 +17,7 @@ struct tep_handle pass:[*]*tracefs_local_events*(const char pass:[*]_tracing_dir
struct tep_handle pass:[*]*tracefs_local_events_system*(const char pass:[*]_tracing_dir_, const char pass:[*] const pass:[*]_sys_names_);
int *tracefs_fill_local_events*(const char pass:[*]_tracing_dir_, struct tep_handle pass:[*]_tep_, int pass:[*]_parsing_failures_);
int *tracefs_load_cmdlines*(const char pass:[*]_tracing_dir_, struct tep_handle pass:[*]_tep_);
+int *tracefs_load_headers*(const char pass:[*]_tracing_dir_, struct tep_handle pass:[*]_tep_);
--
DESCRIPTION
@@ -55,6 +56,10 @@ The *tracefs_load_cmdlines()* does just that. The _tracing_dir_ is
the directory of the mount point to load from, or NULL to use the
mount point of the tracefs file system.
+The *tracefs_load_headers()* will reade the "header_page" of the events
+directory that will update the _tep_ handle with information on how to parse the
+tracing ring buffer sub-buffer.
+
RETURN VALUE
------------
The *tracefs_local_events()* and *tracefs_local_events_system()* functions
@@ -80,6 +80,7 @@ Trace events:
struct tep_handle pass:[*]*tracefs_local_events_system*(const char pass:[*]_tracing_dir_, const char pass:[*] const pass:[*]_sys_names_);
int *tracefs_fill_local_events*(const char pass:[*]_tracing_dir_, struct tep_handle pass:[*]_tep_, int pass:[*]_parsing_failures_);
int *tracefs_load_cmdlines*(const char pass:[*]_tracing_dir_, struct tep_handle pass:[*]_tep_);
+ int *tracefs_load_headers*(const char pass:[*]_tracing_dir_, struct tep_handle pass:[*]_tep_);
char pass:[*]*tracefs_event_get_file*(struct tracefs_instance pass:[*]_instance_, const char pass:[*]_system_, const char pass:[*]_event_,
const char pass:[*]_file_);
char pass:[*]*tracefs_event_file_read*(struct tracefs_instance pass:[*]_instance_, const char pass:[*]_system_, const char pass:[*]_event_,
@@ -180,6 +180,8 @@ int tracefs_fill_local_events(const char *tracing_dir,
int tracefs_load_cmdlines(const char *tracing_dir, struct tep_handle *tep);
+int tracefs_load_headers(const char *tracing_dir, struct tep_handle *tep);
+
char *tracefs_get_clock(struct tracefs_instance *instance);
enum tracefs_option_id {
@@ -1216,6 +1216,28 @@ int tracefs_load_cmdlines(const char *tracing_dir, struct tep_handle *tep)
return load_saved_cmdlines(tracing_dir, tep, true);
}
+/**
+ * tracefs_load_headers - load just the headers into a tep handle
+ * @tracing_dir: The directory to load from (NULL to figure it out)
+ * @tep: The tep handle to load the headers into.
+ *
+ * Updates the @tep handle with the event and sub-buffer header
+ * information.
+ *
+ * Returns 0 on success and -1 on error.
+ */
+int tracefs_load_headers(const char *tracing_dir, struct tep_handle *tep)
+{
+ int ret;
+
+ if (!tracing_dir)
+ tracing_dir = tracefs_tracing_dir();
+
+ ret = read_header(tep, tracing_dir);
+
+ return ret < 0 ? -1 : 0;
+}
+
static int fill_local_events_system(const char *tracing_dir,
struct tep_handle *tep,
const char * const *sys_names,
@@ -110,10 +110,8 @@ tracefs_cpu_open(struct tracefs_instance *instance, int cpu, bool nonblock)
struct tep_handle *tep;
struct kbuffer *kbuf;
char path[128];
- char *buf;
int mode = O_RDONLY;
int subbuf_size;
- int len;
int ret;
int fd;
@@ -131,12 +129,7 @@ tracefs_cpu_open(struct tracefs_instance *instance, int cpu, bool nonblock)
goto fail;
/* Get the size of the page */
- buf = tracefs_instance_file_read(NULL, "events/header_page", &len);
- if (!buf)
- goto fail;
-
- ret = tep_parse_header_page(tep, buf, len, sizeof(long));
- free(buf);
+ ret = tracefs_load_headers(NULL, tep);
if (ret < 0)
goto fail;