/*
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 EfficiOS Inc.
*
* SPDX-License-Identifier: GPL-2.0-only
*
#include <inttypes.h>
#include <ctype.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/compat/string.h>
-#include <common/compat/getenv.h>
-#include <common/string-utils/string-utils.h>
-#include <common/utils.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/compat/string.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <common/utils.hpp>
/* Mi dependancy */
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
-#include <lttng/domain-internal.h>
-#include <lttng/event-internal.h>
+#include <lttng/domain-internal.hpp>
+#include <lttng/event-internal.hpp>
-#include "../command.h"
-#include "../loglevel.h"
-#include "../uprobe.h"
+#include "../command.hpp"
+#include "../loglevel.hpp"
+#include "../uprobe.hpp"
#if (LTTNG_SYMBOL_NAME_LEN == 256)
#define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "255"
#endif
-static char *opt_event_list;
static int opt_event_type;
static const char *opt_loglevel;
static int opt_loglevel_type;
ret = CMD_ERROR;
goto end;
}
- ev->attr.probe.offset = strtoul(s_hex, NULL, 0);
+ ev->attr.probe.offset = strtoull(s_hex, NULL, 0);
DBG("probe offset %" PRIu64, ev->attr.probe.offset);
ev->attr.probe.addr = 0;
goto end;
ret = CMD_ERROR;
goto end;
}
- ev->attr.probe.addr = strtoul(s_hex, NULL, 0);
+ ev->attr.probe.addr = strtoull(s_hex, NULL, 0);
DBG("probe addr %" PRIu64, ev->attr.probe.addr);
ev->attr.probe.offset = 0;
memset(ev->attr.probe.symbol_name, 0, LTTNG_SYMBOL_NAME_LEN);
}
length += sizeof(preamble);
- ret = (char *) zmalloc(length);
+ ret = calloc<char>(length);
if (!ret) {
return NULL;
}
* Enabling event using the lttng API.
* Note: in case of error only the last error code will be return.
*/
-static int enable_events(char *session_name)
+static int enable_events(char *session_name, char *event_list)
{
int ret = CMD_SUCCESS, command_ret = CMD_SUCCESS;
int error_holder = CMD_SUCCESS, warn = 0, error = 0, success = 1;
}
/* Strip event list */
- event_name = strtok(opt_event_list, ",");
+ event_name = strtok(event_list, ",");
while (event_name != NULL) {
/* Copy name and type of the event */
strncpy(ev->name, event_name, LTTNG_SYMBOL_NAME_LEN);
int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
char *session_name = NULL;
+ char *event_list = NULL;
+ const char *arg_event_list = NULL;
const char *leftover = NULL;
int event_type = -1;
}
}
- opt_event_list = (char*) poptGetArg(pc);
- if (opt_event_list == NULL && opt_enable_all == 0) {
- ERR("Missing event name(s).\n");
+ arg_event_list = poptGetArg(pc);
+ if (arg_event_list == NULL && opt_enable_all == 0) {
+ ERR("Missing event name(s).");
ret = CMD_ERROR;
goto end;
}
+ if (opt_enable_all == 0) {
+ event_list = strdup(arg_event_list);
+ if (event_list == NULL) {
+ PERROR("Failed to copy event name(s)");
+ ret = CMD_ERROR;
+ goto end;
+ }
+ }
+
leftover = poptGetArg(pc);
if (leftover) {
ERR("Unknown argument: %s", leftover);
session_name = opt_session_name;
}
- command_ret = enable_events(session_name);
+ command_ret = enable_events(session_name, event_list);
if (command_ret) {
success = 0;
goto mi_closing;
free(session_name);
}
+ free(event_list);
+
/* Overwrite ret if an error occurred in enable_events */
ret = command_ret ? command_ret : ret;