fprintf(fp, " Available field names:\n");
fprintf(fp, " (payload OR args OR arg)\n");
fprintf(fp, " all, scope, header, (context OR ctx)\n");
- fprintf(fp, " trace\n");
+ fprintf(fp, " trace, trace:domain, trace:procname, trace:vpid\n");
fprintf(fp, " (payload active by default)\n");
list_formats(fp);
fprintf(fp, "\n");
opt_payload_field_names = 1;
else if (!strcmp(str, "trace"))
opt_trace_name = 1;
+ else if (!strcmp(str, "trace:domain"))
+ opt_trace_domain = 1;
+ else if (!strcmp(str, "trace:procname"))
+ opt_trace_procname = 1;
+ else if (!strcmp(str, "trace:vpid"))
+ opt_trace_vpid = 1;
else {
fprintf(stdout, "[error] unknown field name type %s\n", str);
return -EINVAL;
} else {
close(fd);
close(dirfd);
- td_read = fmt_read->open_trace(fpath, O_RDONLY, ctf_move_pos_slow,
+ td_read = fmt_read->open_trace(opt_input_path,
+ fpath, O_RDONLY, ctf_move_pos_slow,
NULL);
if (!td_read) {
fprintf(stdout, "Error opening trace \"%s\" "
return 0;
}
- td_write = fmt_write->open_trace(opt_output_path, O_RDWR, NULL, NULL);
+ td_write = fmt_write->open_trace(NULL, opt_output_path, O_RDWR, NULL, NULL);
if (!td_write) {
fprintf(stdout, "Error opening trace \"%s\" for writing.\n\n",
opt_output_path ? : "<none>");
}
static
-struct trace_descriptor *bt_dummy_open_trace(const char *path, int flags,
+struct trace_descriptor *bt_dummy_open_trace(const char *collection_path,
+ const char *path, int flags,
void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
int whence), FILE *metadata_fp)
{
opt_header_field_names,
opt_context_field_names,
opt_payload_field_names,
- opt_trace_name;
+ opt_trace_name,
+ opt_trace_domain,
+ opt_trace_procname,
+ opt_trace_vpid;
enum field_item {
ITEM_SCOPE,
ITEM_PAYLOAD,
};
-struct trace_descriptor *ctf_text_open_trace(const char *path, int flags,
+struct trace_descriptor *ctf_text_open_trace(const char *collection_path,
+ const char *path, int flags,
void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
int whence), FILE *metadata_fp);
void ctf_text_close_trace(struct trace_descriptor *descriptor);
struct ctf_stream_event *event;
uint64_t id;
int ret;
+ int dom_print = 0;
id = stream->event_id;
}
if ((opt_trace_name || opt_all_field_names) && stream_class->trace->path[0] != '\0') {
set_field_names_print(pos, ITEM_HEADER);
- if (pos->print_names)
- fprintf(pos->fp, "trace = ");
+ if (pos->print_names) {
+ if (opt_trace_name || opt_all_field_names)
+ fprintf(pos->fp, "trace = ");
+ }
fprintf(pos->fp, "%s", stream_class->trace->path);
-
if (pos->print_names)
fprintf(pos->fp, ", ");
else
fprintf(pos->fp, " ");
}
+ if ((opt_trace_domain) && stream_class->trace->domain[0] != '\0') {
+ set_field_names_print(pos, ITEM_HEADER);
+ if (pos->print_names) {
+ fprintf(pos->fp, "trace:domain = ");
+ }
+ if (opt_trace_domain)
+ fprintf(pos->fp, "%s", stream_class->trace->domain);
+ if (pos->print_names)
+ fprintf(pos->fp, ", ");
+ dom_print = 1;
+ }
+ if ((opt_trace_procname) && stream_class->trace->procname[0] != '\0') {
+ set_field_names_print(pos, ITEM_HEADER);
+ if (pos->print_names) {
+ fprintf(pos->fp, "trace:procname = ");
+ } else if (dom_print) {
+ fprintf(pos->fp, ":");
+ }
+
+ if (opt_trace_procname)
+ fprintf(pos->fp, "%s", stream_class->trace->procname);
+ if (pos->print_names)
+ fprintf(pos->fp, ", ");
+ dom_print = 1;
+ }
+ if ((opt_trace_vpid) && stream_class->trace->vpid[0] != '\0') {
+ set_field_names_print(pos, ITEM_HEADER);
+ if (pos->print_names) {
+ fprintf(pos->fp, "trace:vpid = ");
+ } else if (dom_print) {
+ fprintf(pos->fp, ":");
+ }
+
+ if (opt_trace_vpid)
+ fprintf(pos->fp, "%s", stream_class->trace->vpid);
+ if (pos->print_names)
+ fprintf(pos->fp, ", ");
+ dom_print = 1;
+ }
+ if (dom_print && !pos->print_names)
+ fprintf(pos->fp, " ");
set_field_names_print(pos, ITEM_HEADER);
if (pos->print_names)
fprintf(pos->fp, "name = ");
}
-struct trace_descriptor *ctf_text_open_trace(const char *path, int flags,
+struct trace_descriptor *ctf_text_open_trace(const char *collection_path,
+ const char *path, int flags,
void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
int whence), FILE *metadata_fp)
{
extern int yydebug;
static
-struct trace_descriptor *ctf_open_trace(const char *path, int flags,
+struct trace_descriptor *ctf_open_trace(const char *collection_path, const char *path, int flags,
void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
int whence), FILE *metadata_fp);
static
return ret;
}
+static void
+init_domain_name(struct ctf_trace *td)
+{
+ char *start, *end;
+
+ start = td->path + strlen(td->collection_path);
+ start++; /* skip / */
+ end = strchr(start, '/');
+ if (!end)
+ return;
+ memcpy(td->domain, start, end - start);
+ td->domain[end - start] = '\0';
+}
+
+static void
+init_proc_name(struct ctf_trace *td)
+{
+ char buf[PATH_MAX];
+ char *start, *end;
+
+ if (td->domain[0] == '\0')
+ return;
+ memcpy(buf, td->path, PATH_MAX);
+ start = buf + strlen(td->collection_path);
+ start++; /* skip / */
+ start = strchr(start, '/'); /* get begin of domain content */
+ if (!start)
+ return;
+ start++; /* skip / */
+ /* find last -, skips time */
+ end = strrchr(start, '-');
+ if (!end)
+ return;
+ *end = '\0';
+ /* find previous -, skips date */
+ end = strrchr(start, '-');
+ if (!end)
+ return;
+ *end = '\0';
+ /* find previous -, skips pid */
+ end = strrchr(start, '-');
+ if (!end)
+ return;
+ *end = '\0';
+
+ memcpy(td->procname, start, end - start);
+ td->procname[end - start] = '\0';
+}
+
+static void
+init_vpid(struct ctf_trace *td)
+{
+ char buf[PATH_MAX];
+ char *start, *end;
+
+ if (td->domain[0] == '\0')
+ return;
+ memcpy(buf, td->path, PATH_MAX);
+ start = buf + strlen(td->collection_path);
+ start++; /* skip / */
+ start = strchr(start, '/'); /* get begin of domain content */
+ if (!start)
+ return;
+ start++; /* skip / */
+ /* find last -, skips time */
+ end = strrchr(start, '-');
+ if (!end)
+ return;
+ *end = '\0';
+ /* find previous -, skips date */
+ end = strrchr(start, '-');
+ if (!end)
+ return;
+ *end = '\0';
+ /* find previous -, skips pid */
+ start = strrchr(start, '-');
+ if (!start)
+ return;
+ start++; /* skip - */
+
+ memcpy(td->vpid, start, end - start);
+ td->vpid[end - start] = '\0';
+}
+
static
-int ctf_open_trace_read(struct ctf_trace *td, const char *path, int flags,
+int ctf_open_trace_read(struct ctf_trace *td, const char *collection_path,
+ const char *path, int flags,
void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
int whence), FILE *metadata_fp)
{
ret = -errno;
goto error_dirfd;
}
+ strncpy(td->collection_path, collection_path, PATH_MAX);
+ td->collection_path[PATH_MAX - 1] = '\0';
strncpy(td->path, path, PATH_MAX);
td->path[PATH_MAX - 1] = '\0';
+ init_domain_name(td);
+ init_proc_name(td);
+ init_vpid(td);
/*
* Keep the metadata file separate.
}
static
-struct trace_descriptor *ctf_open_trace(const char *path, int flags,
+struct trace_descriptor *ctf_open_trace(const char *collection_path, const char *path, int flags,
void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
int whence), FILE *metadata_fp)
{
fprintf(stdout, "[error] Path missing for input CTF trace.\n");
goto error;
}
- ret = ctf_open_trace_read(td, path, flags, move_pos_slow, metadata_fp);
+ ret = ctf_open_trace_read(td, collection_path, path, flags, move_pos_slow, metadata_fp);
if (ret)
goto error;
break;
opt_header_field_names,
opt_context_field_names,
opt_payload_field_names,
- opt_trace_name;
+ opt_trace_name,
+ opt_trace_domain,
+ opt_trace_procname,
+ opt_trace_vpid;
#endif
/* Heap of streams, ordered to always get the lowest timestam */
struct ptr_heap *stream_heap;
+ char collection_path[PATH_MAX];
char path[PATH_MAX];
+ char domain[PATH_MAX];
+ char procname[PATH_MAX];
+ char vpid[PATH_MAX];
};
#define CTF_STREAM_SET_FIELD(ctf_stream, field) \
struct format {
GQuark name;
- struct trace_descriptor *(*open_trace)(const char *path, int flags,
+ struct trace_descriptor *(*open_trace)(const char *collection_path,
+ const char *path, int flags,
void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
int whence), FILE *metadata_fp);
struct trace_descriptor *(*open_mmap_trace)(