projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Preliminary work for full UST support
[lttng-tools.git]
/
lttng
/
commands
/
add_context.c
diff --git
a/lttng/commands/add_context.c
b/lttng/commands/add_context.c
index 5756684caedb85299d054590b7367c9fa9fbf1c6..e82678bfccd08054fee3a1f82dd330f45d9db0f6 100644
(file)
--- a/
lttng/commands/add_context.c
+++ b/
lttng/commands/add_context.c
@@
-47,6
+47,8
@@
enum {
OPT_TYPE,
};
OPT_TYPE,
};
+static struct lttng_handle *handle;
+
/*
* Taken from the LTTng ABI
*/
/*
* Taken from the LTTng ABI
*/
@@
-341,7
+343,7
@@
end:
/*
* Add context to channel or event.
*/
/*
* Add context to channel or event.
*/
-static int add_context(
void
)
+static int add_context(
char *session_name
)
{
int ret = CMD_SUCCESS;
struct lttng_event_context context;
{
int ret = CMD_SUCCESS;
struct lttng_event_context context;
@@
-349,13
+351,18
@@
static int add_context(void)
struct ctx_type *type;
char *ptr;
struct ctx_type *type;
char *ptr;
+ if (opt_kernel) {
+ dom.type = LTTNG_DOMAIN_KERNEL;
+ }
+
+ handle = lttng_create_handle(session_name, &dom);
+ if (handle == NULL) {
+ ret = -1;
+ goto error;
+ }
+
/* Iterate over all context type given */
cds_list_for_each_entry(type, &ctx_type_list.head, list) {
/* Iterate over all context type given */
cds_list_for_each_entry(type, &ctx_type_list.head, list) {
- /* Set session name for the current command */
- if (set_session_name(opt_session_name) < 0) {
- ret = CMD_ERROR;
- goto error;
- }
context.ctx = type->opt->ctx_type;
if (context.ctx == LTTNG_EVENT_CONTEXT_PERF_COUNTER) {
context.ctx = type->opt->ctx_type;
if (context.ctx == LTTNG_EVENT_CONTEXT_PERF_COUNTER) {
@@
-371,15
+378,12
@@
static int add_context(void)
}
}
if (opt_kernel) {
}
}
if (opt_kernel) {
- /* Create kernel domain */
- dom.type = LTTNG_DOMAIN_KERNEL;
-
DBG("Adding kernel context");
DBG("Adding kernel context");
- ret = lttng_add_context(
&dom
, &context, opt_event_name,
+ ret = lttng_add_context(
handle
, &context, opt_event_name,
opt_channel_name);
if (ret < 0) {
fprintf(stderr, "%s: ", type->opt->symbol);
opt_channel_name);
if (ret < 0) {
fprintf(stderr, "%s: ", type->opt->symbol);
-
goto error
;
+
continue
;
} else {
MSG("Kernel context %s added", type->opt->symbol);
}
} else {
MSG("Kernel context %s added", type->opt->symbol);
}
@@
-393,12
+397,14
@@
static int add_context(void)
ret = CMD_NOT_IMPLEMENTED;
goto error;
} else {
ret = CMD_NOT_IMPLEMENTED;
goto error;
} else {
- ERR("Please specify a tracer (
kernel or user-
space)");
+ ERR("Please specify a tracer (
--kernel or --user
space)");
goto error;
}
}
error:
goto error;
}
}
error:
+ lttng_destroy_handle(handle);
+
return ret;
}
return ret;
}
@@
-411,6
+417,7
@@
int cmd_add_context(int argc, const char **argv)
char *tmp;
static poptContext pc;
struct ctx_type *type, *tmptype;
char *tmp;
static poptContext pc;
struct ctx_type *type, *tmptype;
+ char *session_name = NULL;
if (argc < 2) {
usage(stderr);
if (argc < 2) {
usage(stderr);
@@
-461,7
+468,17
@@
int cmd_add_context(int argc, const char **argv)
}
}
}
}
- ret = add_context();
+ if (!opt_session_name) {
+ session_name = get_session_name();
+ if (session_name == NULL) {
+ ret = -1;
+ goto end;
+ }
+ } else {
+ session_name = opt_session_name;
+ }
+
+ ret = add_context(session_name);
/* Cleanup allocated memory */
cds_list_for_each_entry_safe(type, tmptype, &ctx_type_list.head, list) {
/* Cleanup allocated memory */
cds_list_for_each_entry_safe(type, tmptype, &ctx_type_list.head, list) {
This page took
0.024312 seconds
and
4
git commands to generate.