summaryrefslogtreecommitdiffstats
path: root/src/output.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2009-09-15 18:54:43 +0200
committerJiri Olsa <jolsa@redhat.com>2009-09-15 18:54:43 +0200
commit5e542623f3dafab636adbe5690a8a4716a96f956 (patch)
tree472f827abf2e6670465eed719fc34665a2f60ef2 /src/output.c
parent5a9bd15d138627561b4df3bc639f8939167709d1 (diff)
downloadlatrace-5e542623f3dafab636adbe5690a8a4716a96f956.tar.gz
latrace-5e542623f3dafab636adbe5690a8a4716a96f956.tar.xz
latrace-5e542623f3dafab636adbe5690a8a4716a96f956.zip
added initial support for timestamp display
Diffstat (limited to 'src/output.c')
-rw-r--r--src/output.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/output.c b/src/output.c
index b8e8bed..cadf3c6 100644
--- a/src/output.c
+++ b/src/output.c
@@ -19,6 +19,8 @@
*/
#include <stdlib.h>
+#include <time.h>
+#include <sys/time.h>
#include "config.h"
@@ -35,6 +37,22 @@ do { \
fprintf(cfg->fout, "%5d ", (pid_t) syscall(SYS_gettid)); \
} while(0)
+#define PRINT_TIME(tv) \
+do { \
+ struct tm t; \
+\
+ gettimeofday(tv, NULL); \
+ localtime_r(&tv->tv_sec, &t); \
+ fprintf(cfg->fout, "[%02d/%02d/%4d %02d:%02d:%02d.%06u] ", \
+ t.tm_mon, \
+ t.tm_mday, \
+ t.tm_year + 1900, \
+ t.tm_hour, \
+ t.tm_min, \
+ t.tm_sec, \
+ (unsigned int) tv->tv_usec); \
+} while(0)
+
/* libiberty external */
extern char* cplus_demangle(const char *mangled, int options);
@@ -48,11 +66,16 @@ do { \
} \
} while(0)
-int lt_out_entry(struct lt_config_shared *cfg, const char *symname, char *lib_to,
+int lt_out_entry(struct lt_config_shared *cfg,
+ struct timeval *tv,
+ const char *symname, char *lib_to,
char *argbuf, char *argdbuf)
{
int demangled = 0;
+ if (cfg->timestamp && tv)
+ PRINT_TIME(tv);
+
/* Print thread ID */
if (!cfg->hide_tid)
PRINT_TID();
@@ -84,7 +107,9 @@ int lt_out_entry(struct lt_config_shared *cfg, const char *symname, char *lib_to
return 0;
}
-int lt_out_exit(struct lt_config_shared *cfg, const char *symname, char *lib_to,
+int lt_out_exit(struct lt_config_shared *cfg,
+ struct timeval *tv,
+ const char *symname, char *lib_to,
char *argbuf, char *argdbuf)
{
int demangled = 0;
@@ -92,6 +117,9 @@ int lt_out_exit(struct lt_config_shared *cfg, const char *symname, char *lib_to,
if (!*argbuf && (!cfg->braces))
return 0;
+ if (cfg->timestamp && tv)
+ PRINT_TIME(tv);
+
/* Print thread ID */
if (!cfg->hide_tid)
PRINT_TID();