@@ -3,7 +3,8 @@ libtracefs(3)
NAME
----
-tracefs_local_events, tracefs_local_events_system, tracefs_fill_local_events -
+tracefs_local_events, tracefs_local_events_system, tracefs_fill_local_events,
+tracefs_load_cmdlines -
Initialize a tep handler with trace events from the local system.
SYNOPSIS
@@ -15,7 +16,7 @@ SYNOPSIS
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_);
--
DESCRIPTION
@@ -46,6 +47,14 @@ a pointer to already allocated tep handler, that is going to be initialized.
The _parsing_failures_ argument could be NULL or a pointer to an integer,
where the number of failures while parsing the event files are returned.
+The above functions will also load the mappings between pids and the process
+command line names. In some cases the _tep_ handle is created with one
+of the above before tracing begins. As the mappings get updated during the
+trace, there may be a need to read the mappings again after the trace.
+The _tracefs_load_cmdlines()_ does just that. The _tracing_dir_ is
+the director of the mount point to load from, or NULL to use the
+mount point of the tracefs file system.
+
RETURN VALUE
------------
The _tracefs_local_events()_ and _tracefs_local_events_system()_ functions
@@ -55,6 +64,9 @@ case of an error. The returned _tep_ handler must be freed with _tep_free(3)_.
The _tracefs_fill_local_events()_ function returns -1 in case of an error or
0 otherwise.
+The _tracefs_load_cmdlines()_ function returns -1 in case of an error, or
+0 otherwise.
+
EXAMPLE
-------
[source,c]
@@ -91,6 +103,7 @@ struct tep_event *tep;
if (tracefs_fill_local_events(NULL, tep, &parsing_failures) < 0) {
/* Failed to initialise tep handler with local events from top instance */
}
+ tracefs_load_cmdlines(NULL, tep);
...
tep_free(tep);
--
@@ -94,6 +94,8 @@ struct tep_handle *tracefs_local_events_system(const char *tracing_dir,
int tracefs_fill_local_events(const char *tracing_dir,
struct tep_handle *tep, int *parsing_failures);
+int tracefs_load_cmdlines(const char *tracing_dir, struct tep_handle *tep);
+
char *tracefs_get_clock(struct tracefs_instance *instance);
enum tracefs_option_id {
@@ -610,8 +610,8 @@ static void load_kallsyms(struct tep_handle *tep)
free(buf);
}
-static void load_saved_cmdlines(const char *tracing_dir,
- struct tep_handle *tep)
+static int load_saved_cmdlines(const char *tracing_dir,
+ struct tep_handle *tep, bool warn)
{
char *path;
char *buf;
@@ -619,15 +619,17 @@ static void load_saved_cmdlines(const char *tracing_dir,
path = trace_append_file(tracing_dir, "saved_cmdlines");
if (!path)
- return;
+ return -1;
ret = str_read_file(path, &buf, false);
free(path);
if (ret < 0)
- return;
+ return -1;
- tep_parse_saved_cmdlines(tep, buf);
+ ret = tep_parse_saved_cmdlines(tep, buf);
free(buf);
+
+ return ret;
}
static void load_printk_formats(const char *tracing_dir,
@@ -659,10 +661,15 @@ static void load_mappings(const char *tracing_dir,
struct tep_handle *tep)
{
load_kallsyms(tep);
- load_saved_cmdlines(tracing_dir, tep);
+ load_saved_cmdlines(tracing_dir, tep, false);
load_printk_formats(tracing_dir, tep);
}
+int tracefs_load_cmdlines(const char *tracing_dir, struct tep_handle *tep)
+{
+ return load_saved_cmdlines(tracing_dir, tep, true);
+}
+
static int fill_local_events_system(const char *tracing_dir,
struct tep_handle *tep,
const char * const *sys_names,