Needed to find error culprits.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
ret = kernctl_add_context(chan->fd, ctx);
if (ret < 0) {
if (errno != EEXIST) {
- perror("add context ioctl");
+ PERROR("add context ioctl");
} else {
/* If EEXIST, we just ignore the error */
ret = 0;
chan->ctx = zmalloc(sizeof(struct lttng_kernel_context));
if (chan->ctx == NULL) {
- perror("zmalloc event context");
+ PERROR("zmalloc event context");
goto error;
}
DBG("Adding context to event %s", event->event->name);
ret = kernctl_add_context(event->fd, ctx);
if (ret < 0) {
- perror("add context ioctl");
+ PERROR("add context ioctl");
goto error;
}
event->ctx = zmalloc(sizeof(struct lttng_kernel_context));
if (event->ctx == NULL) {
- perror("zmalloc event context");
+ PERROR("zmalloc event context");
goto error;
}
/* Kernel tracer session creation */
ret = kernctl_create_session(tracer_fd);
if (ret < 0) {
- perror("ioctl kernel create session");
+ PERROR("ioctl kernel create session");
goto error;
}
/* Prevent fd duplication after execlp() */
ret = fcntl(lks->fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
- perror("fcntl session fd");
+ PERROR("fcntl session fd");
}
lks->consumer_fds_sent = 0;
/* Kernel tracer channel creation */
ret = kernctl_create_channel(session->fd, &lkc->channel->attr);
if (ret < 0) {
- perror("ioctl kernel create channel");
+ PERROR("ioctl kernel create channel");
goto error;
}
/* Prevent fd duplication after execlp() */
ret = fcntl(lkc->fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
- perror("fcntl session fd");
+ PERROR("fcntl session fd");
}
/* Add channel to session */
/* Prevent fd duplication after execlp() */
ret = fcntl(event->fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
- perror("fcntl session fd");
+ PERROR("fcntl session fd");
}
add_list:
ret = kernctl_disable(chan->fd);
if (ret < 0) {
- perror("disable chan ioctl");
+ PERROR("disable chan ioctl");
ret = errno;
goto error;
}
ret = kernctl_enable(chan->fd);
if (ret < 0 && errno != EEXIST) {
- perror("Enable kernel chan");
+ PERROR("Enable kernel chan");
goto error;
}
ret = kernctl_enable(event->fd);
if (ret < 0 && errno != EEXIST) {
- perror("enable kernel event");
+ PERROR("enable kernel event");
goto error;
}
ret = kernctl_disable(event->fd);
if (ret < 0 && errno != EEXIST) {
- perror("disable kernel event");
+ PERROR("disable kernel event");
goto error;
}
/* Prevent fd duplication after execlp() */
ret = fcntl(lkm->fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
- perror("fcntl session fd");
+ PERROR("fcntl session fd");
}
session->metadata = lkm;
ret = kernctl_start_session(session->fd);
if (ret < 0) {
- perror("ioctl start session");
+ PERROR("ioctl start session");
goto error;
}
ret = kernctl_wait_quiescent(fd);
if (ret < 0) {
- perror("wait quiescent ioctl");
+ PERROR("wait quiescent ioctl");
ERR("Kernel quiescent wait failed");
}
}
ret = kernctl_calibrate(fd, calibrate);
if (ret < 0) {
- perror("calibrate ioctl");
+ PERROR("calibrate ioctl");
return -1;
}
DBG("Flushing channel stream %d", stream->fd);
ret = kernctl_buffer_flush(stream->fd);
if (ret < 0) {
- perror("ioctl");
+ PERROR("ioctl");
ERR("Fail to flush buffer for stream %d (ret: %d)",
stream->fd, ret);
}
/* Prevent fd duplication after execlp() */
ret = fcntl(lks->fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
- perror("fcntl session fd");
+ PERROR("fcntl session fd");
}
ret = asprintf(&lks->pathname, "%s/%s_%d",
channel->pathname, channel->channel->name, channel->stream_count);
if (ret < 0) {
- perror("asprintf kernel create stream");
+ PERROR("asprintf kernel create stream");
goto error;
}
ret = kernctl_create_stream(session->metadata->fd);
if (ret < 0) {
- perror("kernel create metadata stream");
+ PERROR("kernel create metadata stream");
goto error;
}
/* Prevent fd duplication after execlp() */
ret = fcntl(session->metadata_stream_fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
- perror("fcntl session fd");
+ PERROR("fcntl session fd");
}
return 0;
fd = kernctl_tracepoint_list(tracer_fd);
if (fd < 0) {
- perror("kernel tracepoint list");
+ PERROR("kernel tracepoint list");
goto error;
}
fp = fdopen(fd, "r");
if (fp == NULL) {
- perror("kernel tracepoint list fdopen");
+ PERROR("kernel tracepoint list fdopen");
goto error_fp;
}
nbmem <<= 1;
elist = realloc(elist, nbmem * sizeof(struct lttng_event));
if (elist == NULL) {
- perror("realloc list events");
+ PERROR("realloc list events");
count = -ENOMEM;
goto end;
}
"/sbin/modprobe -r -q %s",
kern_modules_list[i].name);
if (ret < 0) {
- perror("snprintf modprobe -r");
+ PERROR("snprintf modprobe -r");
goto error;
}
modprobe[sizeof(modprobe) - 1] = '\0';
kern_modules_list[i].required ? "" : "-q ",
kern_modules_list[i].name);
if (ret < 0) {
- perror("snprintf modprobe");
+ PERROR("snprintf modprobe");
goto error;
}
modprobe[sizeof(modprobe) - 1] = '\0';
/* Allocate session data structure */
new_session = zmalloc(sizeof(struct ltt_session));
if (new_session == NULL) {
- perror("zmalloc");
+ PERROR("zmalloc");
ret = LTTCOMM_FATAL;
goto error_malloc;
}
ret = chown(shm_path, 0, 0);
if (ret < 0) {
if (errno != ENOENT) {
- perror("chown wait shm");
+ PERROR("chown wait shm");
goto error;
}
}
ret = chown(shm_path, getuid(), getgid());
if (ret < 0) {
if (errno != ENOENT) {
- perror("chown wait shm");
+ PERROR("chown wait shm");
goto error;
}
}
ret = chmod(shm_path, mode);
if (ret < 0) {
if (errno != ENOENT) {
- perror("chmod wait shm");
+ PERROR("chmod wait shm");
goto error;
}
}
*/
wait_shm_fd = shm_open(shm_path, O_RDWR | O_CREAT, mode);
if (wait_shm_fd < 0) {
- perror("shm_open wait shm");
+ PERROR("shm_open wait shm");
goto error;
}
ret = ftruncate(wait_shm_fd, mmap_size);
if (ret < 0) {
- perror("ftruncate wait shm");
+ PERROR("ftruncate wait shm");
exit(EXIT_FAILURE);
}
ret = fchmod(wait_shm_fd, mode);
if (ret < 0) {
- perror("fchmod");
+ PERROR("fchmod");
exit(EXIT_FAILURE);
}
/* close shm fd immediately after taking the mmap reference */
ret = close(wait_shm_fd);
if (ret) {
- perror("Error closing fd");
+ PERROR("Error closing fd");
}
if (wait_shm_mmap == MAP_FAILED) {
/* Allocate a new ltt kernel session */
lks = zmalloc(sizeof(struct ltt_kernel_session));
if (lks == NULL) {
- perror("create kernel session zmalloc");
+ PERROR("create kernel session zmalloc");
goto error;
}
/* Set session path */
ret = asprintf(&lks->trace_path, "%s/kernel", path);
if (ret < 0) {
- perror("asprintf kernel traces path");
+ PERROR("asprintf kernel traces path");
goto error;
}
lkc = zmalloc(sizeof(struct ltt_kernel_channel));
if (lkc == NULL) {
- perror("ltt_kernel_channel zmalloc");
+ PERROR("ltt_kernel_channel zmalloc");
goto error;
}
lkc->channel = zmalloc(sizeof(struct lttng_channel));
if (lkc->channel == NULL) {
- perror("lttng_channel zmalloc");
+ PERROR("lttng_channel zmalloc");
goto error;
}
memcpy(lkc->channel, chan, sizeof(struct lttng_channel));
/* Set default trace output path */
ret = asprintf(&lkc->pathname, "%s", path);
if (ret < 0) {
- perror("asprintf kernel create channel");
+ PERROR("asprintf kernel create channel");
goto error;
}
lke = zmalloc(sizeof(struct ltt_kernel_event));
attr = zmalloc(sizeof(struct lttng_kernel_event));
if (lke == NULL || attr == NULL) {
- perror("kernel event zmalloc");
+ PERROR("kernel event zmalloc");
goto error;
}
lkm = zmalloc(sizeof(struct ltt_kernel_metadata));
chan = zmalloc(sizeof(struct lttng_channel));
if (lkm == NULL || chan == NULL) {
- perror("kernel metadata zmalloc");
+ PERROR("kernel metadata zmalloc");
goto error;
}
/* Set default metadata path */
ret = asprintf(&lkm->pathname, "%s/metadata", path);
if (ret < 0) {
- perror("asprintf kernel metadata");
+ PERROR("asprintf kernel metadata");
goto error;
}
lks = zmalloc(sizeof(struct ltt_kernel_stream));
if (lks == NULL) {
- perror("kernel stream zmalloc");
+ PERROR("kernel stream zmalloc");
goto error;
}
luc = zmalloc(sizeof(struct ltt_ust_channel));
if (luc == NULL) {
- perror("ltt_ust_channel zmalloc");
+ PERROR("ltt_ust_channel zmalloc");
goto error;
}
/* Set trace output path */
ret = snprintf(luc->pathname, PATH_MAX, "%s", path);
if (ret < 0) {
- perror("asprintf ust create channel");
+ PERROR("asprintf ust create channel");
goto error_free_channel;
}
lum = zmalloc(sizeof(struct ltt_ust_metadata));
if (lum == NULL) {
- perror("ust metadata zmalloc");
+ PERROR("ust metadata zmalloc");
goto error;
}
/* Set metadata trace path */
ret = snprintf(lum->pathname, PATH_MAX, "%s/metadata", path);
if (ret < 0) {
- perror("asprintf ust metadata");
+ PERROR("asprintf ust metadata");
goto error_free_metadata;
}
DBG("Sending channel %d to consumer", lum.u.channel.channel_key);
ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum));
if (ret < 0) {
- perror("send consumer channel");
+ PERROR("send consumer channel");
goto error;
}
fd = uchan->obj->shm_fd;
ret = lttcomm_send_fds_unix_sock(sock, &fd, 1);
if (ret < 0) {
- perror("send consumer channel ancillary data");
+ PERROR("send consumer channel ancillary data");
goto error;
}
DBG("Sending stream %d to consumer", lum.u.stream.stream_key);
ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum));
if (ret < 0) {
- perror("send consumer stream");
+ PERROR("send consumer stream");
goto error;
}
fds[1] = stream->obj->wait_fd;
ret = lttcomm_send_fds_unix_sock(sock, fds, 2);
if (ret < 0) {
- perror("send consumer stream ancillary data");
+ PERROR("send consumer stream ancillary data");
goto error;
}
}
DBG("Sending metadata channel %d to consumer", lum.u.channel.channel_key);
ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum));
if (ret < 0) {
- perror("send consumer channel");
+ PERROR("send consumer channel");
goto error;
}
fd = usess->metadata->obj->shm_fd;
ret = lttcomm_send_fds_unix_sock(sock, &fd, 1);
if (ret < 0) {
- perror("send consumer metadata channel");
+ PERROR("send consumer metadata channel");
goto error;
}
DBG("Sending metadata stream %d to consumer", lum.u.stream.stream_key);
ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum));
if (ret < 0) {
- perror("send consumer metadata stream");
+ PERROR("send consumer metadata stream");
goto error;
}
fds[0] = usess->metadata->stream_obj->shm_fd;
fds[1] = usess->metadata->stream_obj->wait_fd;
ret = lttcomm_send_fds_unix_sock(sock, fds, 2);
if (ret < 0) {
- perror("send consumer stream");
+ PERROR("send consumer stream");
goto error;
}
}