diff options
author | Jiri Olsa <Jiri Olsa jolsa@redhat.com> | 2010-07-02 16:32:02 +0200 |
---|---|---|
committer | Jiri Olsa <Jiri Olsa jolsa@redhat.com> | 2010-07-02 16:32:02 +0200 |
commit | b50eadc591dc3417677a05667f620603f0f94076 (patch) | |
tree | 2e24e11b3f2828bed0f6c430df0ef05b9a8734ca /src | |
parent | 67798a992d761432898f7c31dbd1d36194eb1b12 (diff) | |
download | latrace-b50eadc591dc3417677a05667f620603f0f94076.tar.gz latrace-b50eadc591dc3417677a05667f620603f0f94076.tar.xz latrace-b50eadc591dc3417677a05667f620603f0f94076.zip |
fixing output for thread applications
- proper tid displayed for pipe mode
- proper indentation for pipe mode
Diffstat (limited to 'src')
-rw-r--r-- | src/audit.c | 13 | ||||
-rw-r--r-- | src/config.h | 7 | ||||
-rw-r--r-- | src/output.c | 22 | ||||
-rw-r--r-- | src/run.c | 14 |
4 files changed, 32 insertions, 24 deletions
diff --git a/src/audit.c b/src/audit.c index 58b9496..475dd47 100644 --- a/src/audit.c +++ b/src/audit.c @@ -39,6 +39,7 @@ extern struct lt_config_audit cfg; static __thread int pipe_fd = 0; static __thread int flow_below_stack = 0; +static __thread int indent_depth = 0; static int check_names(char *name, char **ptr) @@ -99,9 +100,11 @@ static int sym_entry(const char *symname, char *lib_from, char *lib_to, return lt_fifo_send(&cfg, pipe_fd, buf, len); } - lt_sh(&cfg, indent_depth)++; + indent_depth++; - lt_out_entry(cfg.sh, &tv, symname, lib_to, + lt_out_entry(cfg.sh, &tv, syscall(SYS_gettid), + indent_depth, + symname, lib_to, argbuf, argdbuf); if (!argret) { @@ -142,10 +145,12 @@ static int sym_exit(const char *symname, char *lib_from, char *lib_to, return lt_fifo_send(&cfg, pipe_fd, buf, len); } - lt_out_exit(cfg.sh, &tv, symname, lib_from, + lt_out_exit(cfg.sh, &tv, syscall(SYS_gettid), + indent_depth, + symname, lib_from, argbuf, argdbuf); - lt_sh(&cfg, indent_depth)--; + indent_depth--; if (!argret) { free(argbuf); diff --git a/src/config.h b/src/config.h index 893381d..78dee86 100644 --- a/src/config.h +++ b/src/config.h @@ -120,9 +120,6 @@ struct lt_config_shared { /* for 'not_follow_fork' */ pid_t pid; - /* used by both app and lib */ - unsigned int indent_depth; - /* XXX feel like an idiot.. find another way!!! */ struct lt_config_shared *sh; }; @@ -243,6 +240,8 @@ struct lt_thread { int fifo_fd; pid_t tid; + int indent_depth; + /* start/stop time */ struct timeval tv_start; struct timeval tv_stop; @@ -413,9 +412,11 @@ int lt_args_cb_struct(struct lt_config_shared *cfg, int type, /* output */ int lt_out_entry(struct lt_config_shared *cfg, struct timeval *tv, + pid_t tid, int indent_depth, const char *symname, char *lib_to, char *argbuf, char *argdbuf); int lt_out_exit(struct lt_config_shared *cfg, struct timeval *tv, + pid_t tid, int indent_depth, const char *symname, char *lib_to, char *argbuf, char *argdbuf); diff --git a/src/output.c b/src/output.c index 5a569ae..e504503 100644 --- a/src/output.c +++ b/src/output.c @@ -32,9 +32,9 @@ static int print_details(struct lt_config_shared *cfg, char *argdbuf) return 0; } -#define PRINT_TID() \ +#define PRINT_TID(tid) \ do { \ - fprintf(cfg->fout, "%5d ", (pid_t) syscall(SYS_gettid)); \ + fprintf(cfg->fout, "%5d ", tid); \ } while(0) #define PRINT_TIME(tv) \ @@ -71,7 +71,8 @@ do { \ #endif int lt_out_entry(struct lt_config_shared *cfg, - struct timeval *tv, + struct timeval *tv, pid_t tid, + int indent_depth, const char *symname, char *lib_to, char *argbuf, char *argdbuf) { @@ -82,11 +83,11 @@ int lt_out_entry(struct lt_config_shared *cfg, /* Print thread ID */ if (!cfg->hide_tid) - PRINT_TID(); + PRINT_TID(tid); /* Print indentation. */ - if (cfg->indent_depth && cfg->indent_sym) - fprintf(cfg->fout, "%.*s", cfg->indent_depth * cfg->indent_size, spaces); + if (indent_depth && cfg->indent_sym) + fprintf(cfg->fout, "%.*s", indent_depth * cfg->indent_size, spaces); /* Demangle the symbol if needed */ if (cfg->demangle) @@ -112,7 +113,8 @@ int lt_out_entry(struct lt_config_shared *cfg, } int lt_out_exit(struct lt_config_shared *cfg, - struct timeval *tv, + struct timeval *tv, pid_t tid, + int indent_depth, const char *symname, char *lib_to, char *argbuf, char *argdbuf) { @@ -126,11 +128,11 @@ int lt_out_exit(struct lt_config_shared *cfg, /* Print thread ID */ if (!cfg->hide_tid) - PRINT_TID(); + PRINT_TID(tid); /* Print indentation. */ - if (cfg->indent_depth && cfg->indent_sym) - fprintf(cfg->fout, "%.*s", cfg->indent_depth * cfg->indent_size, spaces); + if (indent_depth && cfg->indent_sym) + fprintf(cfg->fout, "%.*s", indent_depth * cfg->indent_size, spaces); /* We got here, because we have '-B' option enabled. */ if (!*argbuf && (cfg->braces)) { @@ -118,8 +118,8 @@ static int get_fifo(struct lt_config_app *cfg, int notify_fd, static int process_fifo(struct lt_config_app *cfg, struct lt_thread *t) { static char buf[FIFO_MSG_MAXLEN]; - struct lt_fifo_mbase *mbase = (struct lt_fifo_mbase*) buf; + struct lt_fifo_msym *msym = (struct lt_fifo_msym*) buf; if (-1 == lt_fifo_recv(cfg, t, mbase, FIFO_MSG_MAXLEN)) return -1; @@ -131,15 +131,14 @@ static int process_fifo(struct lt_config_app *cfg, struct lt_thread *t) return -1; } - struct lt_fifo_msym *msym = (struct lt_fifo_msym*) buf; - if (lt_sh(cfg, counts)) return lt_stats_sym(cfg, t, msym); if (FIFO_MSG_TYPE_ENTRY == msym->h.type) { - lt_sh(cfg, indent_depth)++; - lt_out_entry(cfg->sh, &msym->h.tv, + t->indent_depth++; + lt_out_entry(cfg->sh, &msym->h.tv, msym->h.tid, + t->indent_depth, msym->data + msym->sym, msym->data + msym->lib, msym->data + msym->arg, @@ -147,13 +146,14 @@ static int process_fifo(struct lt_config_app *cfg, struct lt_thread *t) } else if (FIFO_MSG_TYPE_EXIT == msym->h.type) { - lt_out_exit(cfg->sh, &msym->h.tv, + lt_out_exit(cfg->sh, &msym->h.tv, msym->h.tid, + t->indent_depth, msym->data + msym->sym, msym->data + msym->lib, msym->data + msym->arg, msym->data + msym->argd); - lt_sh(cfg, indent_depth)--; + t->indent_depth--; } return 0; |