.u.perf = { \
PERF_TYPE_HW_CACHE, \
(uint64_t) PERF_COUNT_HW_CACHE_##name \
- * (uint64_t) PERF_COUNT_HW_CACHE_OP_##op \
- * (uint64_t) PERF_COUNT_HW_CACHE_RESULT_##result, \
+ | ((uint64_t) PERF_COUNT_HW_CACHE_OP_##op << 8) \
+ | ((uint64_t) PERF_COUNT_HW_CACHE_RESULT_##result << 16), \
}, \
}
int indent_len = strlen(indent);
int len, i = 0;
- fprintf(ofp, indent);
+ fprintf(ofp, "%s", indent);
len = indent_len;
while (ctx_opts[i].symbol != NULL) {
if (len > indent_len) {
if (len + strlen(ctx_opts[i].symbol) + 2
>= PRINT_LINE_LEN) {
fprintf(ofp, ",\n");
- fprintf(ofp, indent);
+ fprintf(ofp, "%s", indent);
len = indent_len;
} else {
len += fprintf(ofp, ", ");
fprintf(ofp, "\n");
fprintf(ofp, "Example:\n");
fprintf(ofp, "This command will add the context information 'prio' and two perf\n"
- "counters: hardware branch misses and cache-misses, to all events\n"
+ "counters: hardware branch misses and cache misses, to all events\n"
"in the trace data output:\n");
fprintf(ofp, "# lttng add-context -k -t prio -t perf:branch-misses -t perf:cache-misses\n");
fprintf(ofp, "\n");
struct ctx_type *type;
char *ptr;
- if (set_session_name(opt_session_name) < 0) {
- ret = CMD_ERROR;
- goto error;
- }
-
/* 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.u.perf_counter.type = type->opt->u.perf.type;
context.u.perf_counter.config = type->opt->u.perf.config;
- strcpy(context.u.perf_counter.name,
- type->opt->symbol);
+ strcpy(context.u.perf_counter.name, type->opt->symbol);
/* Replace : and - by _ */
while ((ptr = strchr(context.u.perf_counter.name, '-')) != NULL) {
*ptr = '_';
ret = lttng_add_context(&dom, &context, opt_event_name,
opt_channel_name);
if (ret < 0) {
+ fprintf(stderr, "%s: ", type->opt->symbol);
goto error;
} else {
MSG("Kernel context %s added", type->opt->symbol);