getopt.h sys/ipc.h sys/shm.h popt.h grp.h \
])
-AC_ARG_VAR([LTTNG_TOOLS_COMPAT_BIN_DIR], [Search for LTTng Tools 32-bit compatibility binaries in this location.])
-AC_DEFINE_UNQUOTED([CONFIG_COMPAT_BIN_DIR], $LTTNG_TOOLS_COMPAT_BIN_PREFIX, [Search for LTTng Tools 32-bit compatibility binaries in this location.])
+AC_ARG_VAR([LTTNG_TOOLS_32BIT_BINDIR], [Search for LTTng Tools 32-bit binaries in this location.])
+AC_DEFINE_UNQUOTED([CONFIG_32BIT_BINDIR], $LTTNG_TOOLS_32BIT_BINDIR, [Search for LTTng Tools 32-bit binaries in this location.])
+AC_ARG_VAR([LTTNG_TOOLS_64BIT_BINDIR], [Search for LTTng Tools 64-bit binaries in this location.])
+AC_DEFINE_UNQUOTED([CONFIG_64BIT_BINDIR], $LTTNG_TOOLS_64BIT_BINDIR, [Search for LTTng Tools 64-bit binaries in this location.])
# Check for pthread
AC_CHECK_LIB([pthread], [pthread_create], [],
#define KCONSUMERD_CMD_SOCK_PATH KCONSUMERD_PATH "/command"
#define KCONSUMERD_ERR_SOCK_PATH KCONSUMERD_PATH "/error"
-/* UST consumer path */
-#define USTCONSUMERD_PATH LTTNG_RUNDIR "/ustconsumerd"
-#define USTCONSUMERD_CMD_SOCK_PATH USTCONSUMERD_PATH "/command"
-#define USTCONSUMERD_ERR_SOCK_PATH USTCONSUMERD_PATH "/error"
+/* UST 64-bit consumer path */
+#define USTCONSUMERD64_PATH LTTNG_RUNDIR "/ustconsumerd64"
+#define USTCONSUMERD64_CMD_SOCK_PATH USTCONSUMERD64_PATH "/command"
+#define USTCONSUMERD64_ERR_SOCK_PATH USTCONSUMERD64_PATH "/error"
+
+/* UST 32-bit consumer path */
+#define USTCONSUMERD32_PATH LTTNG_RUNDIR "/ustconsumerd32"
+#define USTCONSUMERD32_CMD_SOCK_PATH USTCONSUMERD32_PATH "/command"
+#define USTCONSUMERD32_ERR_SOCK_PATH USTCONSUMERD32_PATH "/error"
#endif /* _LTTNG_CONSUMERD_H */
LTTCOMM_UST_META_FAIL, /* UST open metadata failed */
LTTCOMM_UST_START_FAIL, /* UST start trace failed */
LTTCOMM_UST_STOP_FAIL, /* UST stop trace failed */
- LTTCOMM_UST_CONSUMER_FAIL, /* UST consumer start failed */
+ LTTCOMM_UST_CONSUMER64_FAIL, /* 64-bit UST consumer start failed */
+ LTTCOMM_UST_CONSUMER32_FAIL, /* 32-bit UST consumer start failed */
LTTCOMM_UST_STREAM_FAIL, /* UST create stream failed */
LTTCOMM_UST_DIR_FAIL, /* UST trace directory creation failed */
LTTCOMM_UST_DIR_EXIST, /* UST trace directory exist */
enum lttng_consumer_type {
LTTNG_CONSUMER_UNKNOWN = 0,
LTTNG_CONSUMER_KERNEL,
- LTTNG_CONSUMER_UST,
+ LTTNG_CONSUMER64_UST,
+ LTTNG_CONSUMER32_UST,
};
struct lttng_consumer_channel {
}
}
break;
- case LTTNG_CONSUMER_UST:
+ case LTTNG_CONSUMER32_UST:
+ case LTTNG_CONSUMER64_UST:
lttng_ustconsumer_del_stream(stream);
break;
default:
switch (consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
break;
- case LTTNG_CONSUMER_UST:
+ case LTTNG_CONSUMER32_UST:
+ case LTTNG_CONSUMER64_UST:
stream->cpu = stream->chan->cpucount++;
ret = lttng_ustconsumer_allocate_stream(stream);
if (ret) {
switch (consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
break;
- case LTTNG_CONSUMER_UST:
+ case LTTNG_CONSUMER32_UST:
+ case LTTNG_CONSUMER64_UST:
/* Streams are in CPU number order (we rely on this) */
stream->cpu = stream->chan->nr_streams++;
break;
switch (consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
break;
- case LTTNG_CONSUMER_UST:
+ case LTTNG_CONSUMER32_UST:
+ case LTTNG_CONSUMER64_UST:
lttng_ustconsumer_del_channel(channel);
break;
default:
channel->mmap_base = NULL;
channel->mmap_len = 0;
break;
- case LTTNG_CONSUMER_UST:
+ case LTTNG_CONSUMER32_UST:
+ case LTTNG_CONSUMER64_UST:
ret = lttng_ustconsumer_allocate_channel(channel);
if (ret) {
free(channel);
switch (consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
return lttng_kconsumer_on_read_subbuffer_mmap(ctx, stream, len);
- case LTTNG_CONSUMER_UST:
+ case LTTNG_CONSUMER32_UST:
+ case LTTNG_CONSUMER64_UST:
return lttng_ustconsumer_on_read_subbuffer_mmap(ctx, stream, len);
default:
ERR("Unknown consumer_data type");
switch (consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
return lttng_kconsumer_on_read_subbuffer_splice(ctx, stream, len);
- case LTTNG_CONSUMER_UST:
+ case LTTNG_CONSUMER32_UST:
+ case LTTNG_CONSUMER64_UST:
return -ENOSYS;
default:
ERR("Unknown consumer_data type");
switch (consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
return lttng_kconsumer_take_snapshot(ctx, stream);
- case LTTNG_CONSUMER_UST:
+ case LTTNG_CONSUMER32_UST:
+ case LTTNG_CONSUMER64_UST:
return lttng_ustconsumer_take_snapshot(ctx, stream);
default:
ERR("Unknown consumer_data type");
switch (consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
return lttng_kconsumer_get_produced_snapshot(ctx, stream, pos);
- case LTTNG_CONSUMER_UST:
+ case LTTNG_CONSUMER32_UST:
+ case LTTNG_CONSUMER64_UST:
return lttng_ustconsumer_get_produced_snapshot(ctx, stream, pos);
default:
ERR("Unknown consumer_data type");
switch (consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
return lttng_kconsumer_recv_cmd(ctx, sock, consumer_sockpoll);
- case LTTNG_CONSUMER_UST:
+ case LTTNG_CONSUMER32_UST:
+ case LTTNG_CONSUMER64_UST:
return lttng_ustconsumer_recv_cmd(ctx, sock, consumer_sockpoll);
default:
ERR("Unknown consumer_data type");
num_hup++;
} else if ((pollfd[i].revents & POLLHUP) &&
!(pollfd[i].revents & POLLIN)) {
- if (consumer_data.type == LTTNG_CONSUMER_UST) {
+ if (consumer_data.type == LTTNG_CONSUMER32_UST
+ || consumer_data.type == LTTNG_CONSUMER64_UST) {
DBG("Polling fd %d tells it has hung up. Attempting flush and read.",
pollfd[i].fd);
if (!local_stream[i]->hangup_flush_done) {
switch (consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
return lttng_kconsumer_read_subbuffer(stream, ctx);
- case LTTNG_CONSUMER_UST:
+ case LTTNG_CONSUMER32_UST:
+ case LTTNG_CONSUMER64_UST:
return lttng_ustconsumer_read_subbuffer(stream, ctx);
default:
ERR("Unknown consumer_data type");
switch (consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
return lttng_kconsumer_on_recv_stream(stream);
- case LTTNG_CONSUMER_UST:
+ case LTTNG_CONSUMER32_UST:
+ case LTTNG_CONSUMER64_UST:
return lttng_ustconsumer_on_recv_stream(stream);
default:
ERR("Unknown consumer_data type");
[ LTTCOMM_ERR_INDEX(LTTCOMM_UST_META_FAIL) ] = "Opening metadata failed",
[ LTTCOMM_ERR_INDEX(LTTCOMM_UST_START_FAIL) ] = "Starting UST trace failed",
[ LTTCOMM_ERR_INDEX(LTTCOMM_UST_STOP_FAIL) ] = "Stoping UST trace failed",
- [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CONSUMER_FAIL) ] = "UST consumer start failed",
+ [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CONSUMER64_FAIL) ] = "64-bit UST consumer start failed",
+ [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CONSUMER32_FAIL) ] = "32-bit UST consumer start failed",
[ LTTCOMM_ERR_INDEX(LTTCOMM_UST_STREAM_FAIL) ] = "UST create stream failed",
[ LTTCOMM_ERR_INDEX(LTTCOMM_UST_DIR_FAIL) ] = "UST trace directory creation failed",
[ LTTCOMM_ERR_INDEX(LTTCOMM_UST_DIR_EXIST) ] = "UST trace directory already exist",
#include <sys/mman.h>
#include <assert.h>
#include <config.h>
+#include <urcu/compiler.h>
#include <lttng-consumerd.h>
#include <lttng-kernel-ctl.h>
static char error_sock_path[PATH_MAX]; /* Global error path */
static enum lttng_consumer_type opt_type = LTTNG_CONSUMER_KERNEL;
-/* the liblttngkconsumerd context */
+/* the liblttngconsumerd context */
static struct lttng_consumer_local_data *ctx;
/*
fprintf(stderr, "Usage: %s OPTIONS\n\nOptions:\n", progname);
fprintf(stderr, " -h, --help "
"Display this usage.\n");
- fprintf(stderr, " -c, --kconsumerd-cmd-sock PATH "
+ fprintf(stderr, " -c, --consumerd-cmd-sock PATH "
"Specify path for the command socket\n");
- fprintf(stderr, " -e, --kconsumerd-err-sock PATH "
+ fprintf(stderr, " -e, --consumerd-err-sock PATH "
"Specify path for the error socket\n");
fprintf(stderr, " -d, --daemonize "
"Start as a daemon.\n");
int c;
static struct option long_options[] = {
- { "kconsumerd-cmd-sock", 1, 0, 'c' },
- { "kconsumerd-err-sock", 1, 0, 'e' },
+ { "consumerd-cmd-sock", 1, 0, 'c' },
+ { "consumerd-err-sock", 1, 0, 'e' },
{ "daemonize", 0, 0, 'd' },
{ "help", 0, 0, 'h' },
{ "quiet", 0, 0, 'q' },
break;
#ifdef HAVE_LIBLTTNG_UST_CTL
case 'u':
- opt_type = LTTNG_CONSUMER_UST;
+# if (CAA_BITS_PER_LONG == 64)
+ opt_type = LTTNG_CONSUMER64_UST;
+# elif (CAA_BITS_PER_LONG == 32)
+ opt_type = LTTNG_CONSUMER32_UST;
+# else
+# error "Unknown bitness"
+# endif
break;
#endif
default:
}
if (strlen(command_sock_path) == 0) {
- snprintf(command_sock_path, PATH_MAX,
- opt_type == LTTNG_CONSUMER_KERNEL ?
- KCONSUMERD_CMD_SOCK_PATH :
- USTCONSUMERD_CMD_SOCK_PATH);
+ switch (opt_type) {
+ case LTTNG_CONSUMER_KERNEL:
+ strcpy(command_sock_path, KCONSUMERD_CMD_SOCK_PATH);
+ break;
+ case LTTNG_CONSUMER64_UST:
+ strcpy(command_sock_path, USTCONSUMERD64_CMD_SOCK_PATH);
+ break;
+ case LTTNG_CONSUMER32_UST:
+ strcpy(command_sock_path, USTCONSUMERD32_CMD_SOCK_PATH);
+ break;
+ default:
+ WARN("Unknown consumerd type");
+ goto error;
+ }
}
/* create the consumer instance with and assign the callbacks */
ctx = lttng_consumer_create(opt_type, lttng_consumer_read_subbuffer,
lttng_consumer_set_command_sock_path(ctx, command_sock_path);
if (strlen(error_sock_path) == 0) {
- snprintf(error_sock_path, PATH_MAX,
- opt_type == LTTNG_CONSUMER_KERNEL ?
- KCONSUMERD_ERR_SOCK_PATH :
- USTCONSUMERD_ERR_SOCK_PATH);
+ switch (opt_type) {
+ case LTTNG_CONSUMER_KERNEL:
+ strcpy(error_sock_path, KCONSUMERD_ERR_SOCK_PATH);
+ break;
+ case LTTNG_CONSUMER64_UST:
+ strcpy(error_sock_path, USTCONSUMERD64_ERR_SOCK_PATH);
+ break;
+ case LTTNG_CONSUMER32_UST:
+ strcpy(error_sock_path, USTCONSUMERD32_ERR_SOCK_PATH);
+ break;
+ default:
+ WARN("Unknown consumerd type");
+ goto error;
+ }
}
if (set_signal_handler() < 0) {
/* Consumer daemon specific control data */
static struct consumer_data kconsumer_data = {
.type = LTTNG_CONSUMER_KERNEL,
+ .err_unix_sock_path = KCONSUMERD_ERR_SOCK_PATH,
+ .cmd_unix_sock_path = KCONSUMERD_CMD_SOCK_PATH,
};
-static struct consumer_data ustconsumer_data = {
- .type = LTTNG_CONSUMER_UST,
+static struct consumer_data ustconsumer64_data = {
+ .type = LTTNG_CONSUMER64_UST,
+ .err_unix_sock_path = USTCONSUMERD64_ERR_SOCK_PATH,
+ .cmd_unix_sock_path = USTCONSUMERD64_CMD_SOCK_PATH,
+};
+static struct consumer_data ustconsumer32_data = {
+ .type = LTTNG_CONSUMER32_UST,
+ .err_unix_sock_path = USTCONSUMERD32_ERR_SOCK_PATH,
+ .cmd_unix_sock_path = USTCONSUMERD32_CMD_SOCK_PATH,
};
static int dispatch_thread_exit;
*/
static struct ltt_session_list *session_list_ptr;
-int ust_consumer_fd;
+int ust_consumerd64_fd = -1;
+int ust_consumerd32_fd = -1;
+
+static const char *consumerd64_prog = "lttng-consumerd";
+static const char *consumerd32_prog = "lttng-consumerd";
-static const char *compat32_consumer_bindir =
- __stringify(CONFIG_COMPAT_BIN_DIR);
-static const char *compat32_consumer_prog = "lttng-consumerd";
+static const char *consumerd64_bindir =
+ __stringify(CONFIG_64BIT_BINDIR);
+static const char *consumerd32_bindir =
+ __stringify(CONFIG_32BIT_BINDIR);
static
-void setup_compat32_consumer(void)
+void setup_consumerd_path(void)
{
const char *bindir;
+ /*
+ * Allow INSTALL_BIN_PATH to be used as a target path for the
+ * native architecture size consumer if CONFIG_NBIT_BINDIR as
+ * not been defined.
+ */
+#if (CAA_BITS_PER_LONG == 64)
+ if (!consumerd64_bindir[0]) {
+ consumerd64_bindir = INSTALL_BIN_PATH;
+ }
+#elif (CAA_BITS_PER_LONG == 32)
+ if (!consumerd32_bindir[0]) {
+ consumerd32_bindir = INSTALL_BIN_PATH;
+ }
+#else
+#error "Unknown bitness"
+#endif
+
/*
* runtime env. var. overrides the build default.
*/
- bindir = getenv("LTTNG_TOOLS_COMPAT_BIN_DIR");
+ bindir = getenv("LTTNG_TOOLS_64BIT_BINDIR");
+ if (bindir) {
+ consumerd64_bindir = bindir;
+ }
+ bindir = getenv("LTTNG_TOOLS_32BIT_BINDIR");
if (bindir) {
- compat32_consumer_bindir = bindir;
+ consumerd32_bindir = bindir;
}
}
switch (consumer_data->type) {
case LTTNG_CONSUMER_KERNEL:
execl(INSTALL_BIN_PATH "/lttng-consumerd",
- "lttng-consumerd", verbosity, "-k", NULL);
+ "lttng-consumerd", verbosity, "-k",
+ "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path,
+ "--consumerd-err-sock", consumer_data->err_unix_sock_path,
+ NULL);
break;
- case LTTNG_CONSUMER_UST:
- execl(INSTALL_BIN_PATH "/lttng-consumerd",
- "lttng-consumerd", verbosity, "-u", NULL);
+ case LTTNG_CONSUMER64_UST:
+ {
+ char path[PATH_MAX];
+
+ snprintf(path, PATH_MAX, "%s/%s",
+ consumerd64_bindir, consumerd64_prog);
+ execl(path, verbosity, "-u",
+ "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path,
+ "--consumerd-err-sock", consumer_data->err_unix_sock_path,
+ NULL);
break;
+ }
+ case LTTNG_CONSUMER32_UST:
+ {
+ char path[PATH_MAX];
+
+ snprintf(path, PATH_MAX, "%s/%s",
+ consumerd32_bindir, consumerd32_prog);
+ execl(path, verbosity, "-u",
+ "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path,
+ "--consumerd-err-sock", consumer_data->err_unix_sock_path,
+ NULL);
+ break;
+ }
default:
perror("unknown consumer type");
exit(EXIT_FAILURE);
goto error;
}
}
- /* Start the kernel consumer daemon */
- pthread_mutex_lock(&ustconsumer_data.pid_mutex);
- if (ustconsumer_data.pid == 0 &&
+ /* Start the UST consumer daemons */
+ /* 64-bit */
+ pthread_mutex_lock(&ustconsumer64_data.pid_mutex);
+ if (consumerd64_bindir[0] != '\0' &&
+ ustconsumer64_data.pid == 0 &&
cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER) {
- pthread_mutex_unlock(&ustconsumer_data.pid_mutex);
- ret = start_consumerd(&ustconsumer_data);
+ pthread_mutex_unlock(&ustconsumer64_data.pid_mutex);
+ ret = start_consumerd(&ustconsumer64_data);
if (ret < 0) {
- ret = LTTCOMM_KERN_CONSUMER_FAIL;
+ ret = LTTCOMM_UST_CONSUMER64_FAIL;
+ ust_consumerd64_fd = -EINVAL;
goto error;
}
- ust_consumer_fd = ustconsumer_data.cmd_sock;
+ ust_consumerd64_fd = ustconsumer64_data.cmd_sock;
} else {
- pthread_mutex_unlock(&ustconsumer_data.pid_mutex);
+ pthread_mutex_unlock(&ustconsumer64_data.pid_mutex);
+ }
+ /* 32-bit */
+ if (consumerd32_bindir[0] != '\0' &&
+ ustconsumer32_data.pid == 0 &&
+ cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER) {
+ pthread_mutex_unlock(&ustconsumer32_data.pid_mutex);
+ ret = start_consumerd(&ustconsumer32_data);
+ if (ret < 0) {
+ ret = LTTCOMM_UST_CONSUMER32_FAIL;
+ ust_consumerd32_fd = -EINVAL;
+ goto error;
+ }
+ ust_consumerd32_fd = ustconsumer32_data.cmd_sock;
+ } else {
+ pthread_mutex_unlock(&ustconsumer32_data.pid_mutex);
}
}
break;
fprintf(stderr, " -a, --apps-sock PATH Specify path for apps unix socket\n");
fprintf(stderr, " --kconsumerd-err-sock PATH Specify path for the kernel consumer error socket\n");
fprintf(stderr, " --kconsumerd-cmd-sock PATH Specify path for the kernel consumer command socket\n");
- fprintf(stderr, " --ustconsumerd-err-sock PATH Specify path for the UST consumer error socket\n");
- fprintf(stderr, " --ustconsumerd-cmd-sock PATH Specify path for the UST consumer command socket\n");
- fprintf(stderr, " --ustconsumerd-compat32 PATH Specify path for the 32-bit UST consumer daemon binary\n");
+ fprintf(stderr, " --ustconsumerd32-err-sock PATH Specify path for the 32-bit UST consumer error socket\n");
+ fprintf(stderr, " --ustconsumerd64-err-sock PATH Specify path for the 64-bit UST consumer error socket\n");
+ fprintf(stderr, " --ustconsumerd32-cmd-sock PATH Specify path for the 32-bit UST consumer command socket\n");
+ fprintf(stderr, " --ustconsumerd64-cmd-sock PATH Specify path for the 64-bit UST consumer command socket\n");
+ fprintf(stderr, " --ustconsumerd32 PATH Specify path for the 32-bit UST consumer daemon binary\n");
+ fprintf(stderr, " --ustconsumerd64 PATH Specify path for the 64-bit UST consumer daemon binary\n");
fprintf(stderr, " -d, --daemonize Start as a daemon.\n");
fprintf(stderr, " -g, --group NAME Specify the tracing group name. (default: tracing)\n");
fprintf(stderr, " -V, --version Show version number.\n");
{ "apps-sock", 1, 0, 'a' },
{ "kconsumerd-cmd-sock", 1, 0, 'C' },
{ "kconsumerd-err-sock", 1, 0, 'E' },
- { "ustconsumerd-cmd-sock", 1, 0, 'D' },
- { "ustconsumerd-err-sock", 1, 0, 'F' },
- { "ustconsumerd-compat32", 1, 0, 'u' },
+ { "ustconsumerd64", 1, 0, 't' },
+ { "ustconsumerd64-cmd-sock", 1, 0, 'D' },
+ { "ustconsumerd64-err-sock", 1, 0, 'F' },
+ { "ustconsumerd32", 1, 0, 'u' },
+ { "ustconsumerd32-cmd-sock", 1, 0, 'G' },
+ { "ustconsumerd32-err-sock", 1, 0, 'H' },
{ "daemonize", 0, 0, 'd' },
{ "sig-parent", 0, 0, 'S' },
{ "help", 0, 0, 'h' },
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "dhqvVS" "a:c:g:s:C:E:D:F:Z:u",
+ c = getopt_long(argc, argv, "dhqvVS" "a:c:g:s:C:E:D:F:Z:u:t",
long_options, &option_index);
if (c == -1) {
break;
snprintf(kconsumer_data.cmd_unix_sock_path, PATH_MAX, "%s", optarg);
break;
case 'F':
- snprintf(ustconsumer_data.err_unix_sock_path, PATH_MAX, "%s", optarg);
+ snprintf(ustconsumer64_data.err_unix_sock_path, PATH_MAX, "%s", optarg);
break;
case 'D':
- snprintf(ustconsumer_data.cmd_unix_sock_path, PATH_MAX, "%s", optarg);
+ snprintf(ustconsumer64_data.cmd_unix_sock_path, PATH_MAX, "%s", optarg);
+ break;
+ case 'H':
+ snprintf(ustconsumer32_data.err_unix_sock_path, PATH_MAX, "%s", optarg);
+ break;
+ case 'G':
+ snprintf(ustconsumer32_data.cmd_unix_sock_path, PATH_MAX, "%s", optarg);
break;
case 'q':
opt_quiet = 1;
opt_verbose_consumer += 1;
break;
case 'u':
- compat32_consumer_bindir = optarg;
+ consumerd32_bindir = optarg;
+ break;
+ case 't':
+ consumerd64_bindir = optarg;
break;
default:
/* Unknown option or other error.
perror("chown");
}
- /* ustconsumer error socket path */
- ret = chown(ustconsumer_data.err_unix_sock_path, 0, gid);
+ /* 64-bit ustconsumer error socket path */
+ ret = chown(ustconsumer64_data.err_unix_sock_path, 0, gid);
+ if (ret < 0) {
+ ERR("Unable to set group on %s", ustconsumer64_data.err_unix_sock_path);
+ perror("chown");
+ }
+
+ /* 32-bit ustconsumer compat32 error socket path */
+ ret = chown(ustconsumer32_data.err_unix_sock_path, 0, gid);
if (ret < 0) {
- ERR("Unable to set group on %s", ustconsumer_data.err_unix_sock_path);
+ ERR("Unable to set group on %s", ustconsumer32_data.err_unix_sock_path);
perror("chown");
}
static int set_consumer_sockets(struct consumer_data *consumer_data)
{
int ret;
- const char *path = consumer_data->type == LTTNG_CONSUMER_KERNEL ?
- KCONSUMERD_PATH : USTCONSUMERD_PATH;
-
- if (strlen(consumer_data->err_unix_sock_path) == 0) {
- snprintf(consumer_data->err_unix_sock_path, PATH_MAX,
- consumer_data->type == LTTNG_CONSUMER_KERNEL ?
- KCONSUMERD_ERR_SOCK_PATH :
- USTCONSUMERD_ERR_SOCK_PATH);
- }
+ const char *path;
- if (strlen(consumer_data->cmd_unix_sock_path) == 0) {
- snprintf(consumer_data->cmd_unix_sock_path, PATH_MAX,
- consumer_data->type == LTTNG_CONSUMER_KERNEL ?
- KCONSUMERD_CMD_SOCK_PATH :
- USTCONSUMERD_CMD_SOCK_PATH);
+ switch (consumer_data->type) {
+ case LTTNG_CONSUMER_KERNEL:
+ path = KCONSUMERD_PATH;
+ break;
+ case LTTNG_CONSUMER64_UST:
+ path = USTCONSUMERD64_PATH;
+ break;
+ case LTTNG_CONSUMER32_UST:
+ path = USTCONSUMERD32_PATH;
+ break;
+ default:
+ ERR("Consumer type unknown");
+ ret = -EINVAL;
+ goto error;
}
ret = mkdir(path, S_IRWXU | S_IRWXG);
goto error;
}
- setup_compat32_consumer();
+ setup_consumerd_path();
/* Parse arguments */
progname = argv[0];
goto exit;
}
- ret = set_consumer_sockets(&ustconsumer_data);
+ ret = set_consumer_sockets(&ustconsumer64_data);
if (ret < 0) {
goto exit;
}
+
+ ret = set_consumer_sockets(&ustconsumer32_data);
+ if (ret < 0) {
+ goto exit;
+ }
+
/* Setup kernel tracer */
init_kernel_tracer();
{
struct ust_app *lta;
- /*
- * Currently support only tracing of application which share the
- * same bitness as the consumer. Eventually implement dispatch
- * to specific compat32 consumer.
- */
- if (msg->bits_per_long != CAA_BITS_PER_LONG) {
+ if ((msg->bits_per_long == 64 && ust_consumerd64_fd == -EINVAL)
+ || (msg->bits_per_long == 32 && ust_consumerd32_fd == -EINVAL)) {
ERR("Registration failed: application \"%s\" (pid: %d) has "
- "%d-bit long, but only "
- "%d-bit lttng-consumerd is available.\n",
- msg->name, msg->pid, msg->bits_per_long,
- CAA_BITS_PER_LONG);
+ "%d-bit long, but no consumerd for this long size is available.\n",
+ msg->name, msg->pid, msg->bits_per_long);
close(sock);
return -EINVAL;
}
-
lta = zmalloc(sizeof(struct ust_app));
if (lta == NULL) {
PERROR("malloc");
lta->ppid = msg->ppid;
lta->uid = msg->uid;
lta->gid = msg->gid;
+ lta->bits_per_long = msg->bits_per_long;
lta->v_major = msg->major;
lta->v_minor = msg->minor;
strncpy(lta->name, msg->name, sizeof(lta->name));
struct ust_app_session *ua_sess;
struct ust_app_channel *ua_chan;
struct ltt_ust_stream *ustream;
+ int consumerd_fd;
DBG("Starting tracing for ust app pid %d", app->key.pid);
}
}
+ switch (app->bits_per_long) {
+ case 64:
+ consumerd_fd = ust_consumerd64_fd;
+ break;
+ case 32:
+ consumerd_fd = ust_consumerd32_fd;
+ break;
+ default:
+ ret = -EINVAL;
+ goto error_rcu_unlock;
+ }
/* Setup UST consumer socket and send fds to it */
- ret = ust_consumer_send_session(ust_consumer_fd, ua_sess);
+ ret = ust_consumer_send_session(consumerd_fd, ua_sess);
if (ret < 0) {
goto error_rcu_unlock;
}
#define UST_APP_EVENT_LIST_SIZE 32
-extern int ust_consumer_fd;
+extern int ust_consumerd64_fd, ust_consumerd32_fd;
/*
* Application registration data structure.
struct ust_app {
pid_t ppid;
uid_t uid; /* User ID that owns the apps */
- gid_t gid; /* Group ID that owns the apps */
+ gid_t gid; /* Group ID that owns the apps */
+ int bits_per_long;
uint32_t v_major; /* Verion major number */
uint32_t v_minor; /* Verion minor number */
char name[17]; /* Process name (short) */
DBG("Sending metadata stream fd");
+ if (consumer_fd < 0) {
+ ERR("Consumer has negative file descriptor");
+ return -EINVAL;
+ }
+
if (usess->metadata->obj->shm_fd != 0) {
int fd;
int fds[2];