X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Flttng-trace.c;h=3b0aafedb46f16693fabe49c51c94d18b063414f;hb=c65c49ac5d6de89eadafc39f7a79af7f86e59add;hp=7cef9138eb3c03d7b0149a8ce0f23b44984943c5;hpb=27caca78522727c29c777d3697d007a2fe9724c6;p=lttng-trace.git diff --git a/src/lttng-trace.c b/src/lttng-trace.c index 7cef913..3b0aafe 100644 --- a/src/lttng-trace.c +++ b/src/lttng-trace.c @@ -36,7 +36,7 @@ #include #include -#define MESSAGE_PREFIX "[lttng-ptrace] " +#define MESSAGE_PREFIX "[lttng-trace] " #define NR_HANDLES 2 #ifndef PTRACE_EVENT_STOP @@ -44,10 +44,10 @@ #endif #define PERROR(msg) perror(msg "\n") -#define ERR(fmt, args...) fprintf(stderr, fmt, ## args) +#define ERR(fmt, args...) fprintf(stderr, fmt "\n", ## args) #ifdef DEBUG -#define DBG(fmt, args...) printf(fmt, ## args) +#define DBG(fmt, args...) printf(fmt "\n", ## args) #else #define DBG(fmt, args...) #endif @@ -542,11 +542,8 @@ void sighandler(int signo, siginfo_t *siginfo __unused, void *context __unused) } static -int lttng_trace_ctx_init(struct lttng_trace_ctx *ctx) +int lttng_trace_ctx_init(struct lttng_trace_ctx *ctx, const char *cmd_name) { - pid_t pid; - char pid_str[12]; - int ret; char datetime[16]; struct tm *timeinfo; @@ -565,12 +562,8 @@ int lttng_trace_ctx_init(struct lttng_trace_ctx *ctx) strcpy(ctx->session_name, session_name); } else { memset(ctx, 0, sizeof(*ctx)); - strcpy(ctx->session_name, "lttng-ptrace-"); - pid = getpid(); - ret = sprintf(pid_str, "%d", (int) pid); - if (ret < 0) - return -1; - strcat(ctx->session_name, pid_str); + strncpy(ctx->session_name, cmd_name, LTTNG_NAME_MAX - 1); + ctx->session_name[LTTNG_NAME_MAX - 1] = '\0'; strcat(ctx->session_name, "-"); strcat(ctx->session_name, datetime); } @@ -581,7 +574,7 @@ int lttng_trace_ctx_init(struct lttng_trace_ctx *ctx) } strcpy(ctx->path, output_path); } else { - strcpy(ctx->path, "/tmp/lttng-ptrace/"); + strcpy(ctx->path, "/tmp/lttng-trace/"); strcat(ctx->path, ctx->session_name); } return 0; @@ -704,7 +697,7 @@ int main(int argc, char **argv) return EXIT_SUCCESS; } - if (lttng_trace_ctx_init(&ptrace_ctx)) + if (lttng_trace_ctx_init(&ptrace_ctx, argv[skip_args])) abort(); act.sa_sigaction = sighandler; @@ -758,7 +751,7 @@ int main(int argc, char **argv) } fprintf(stderr, "%sTracing session `%s` created. It can be customized using the `lttng` command.\n", MESSAGE_PREFIX, ptrace_ctx.session_name); if (!opt_no_pause) { - fprintf(stderr, "Press key when ready to run the child process.\n"); + fprintf(stderr, "%sPress key when ready to run the child process.\n", MESSAGE_PREFIX); getchar(); }