aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--trace-cmd.h4
-rw-r--r--trace-input.c43
2 files changed, 35 insertions, 12 deletions
diff --git a/trace-cmd.h b/trace-cmd.h
index 7d0a209..cb8e169 100644
--- a/trace-cmd.h
+++ b/trace-cmd.h
@@ -76,6 +76,7 @@ char *tracecmd_find_tracing_dir(void);
76 76
77enum { 77enum {
78 TRACECMD_OPTION_DONE, 78 TRACECMD_OPTION_DONE,
79 TRACECMD_OPTION_DATE,
79}; 80};
80 81
81struct tracecmd_ftrace { 82struct tracecmd_ftrace {
@@ -180,6 +181,9 @@ struct tracecmd_output *tracecmd_create_init_file(const char *output_file);
180struct tracecmd_output *tracecmd_create_init_file_override(const char *output_file, 181struct tracecmd_output *tracecmd_create_init_file_override(const char *output_file,
181 const char *tracing_dir, 182 const char *tracing_dir,
182 const char *kallsyms); 183 const char *kallsyms);
184int tracecmd_add_option(struct tracecmd_output *handle,
185 unsigned short id,
186 int size, void *data);
183void tracecmd_output_close(struct tracecmd_output *handle); 187void tracecmd_output_close(struct tracecmd_output *handle);
184struct tracecmd_output *tracecmd_copy(struct tracecmd_input *ihandle, 188struct tracecmd_output *tracecmd_copy(struct tracecmd_input *ihandle,
185 const char *file); 189 const char *file);
diff --git a/trace-input.c b/trace-input.c
index f3dff08..b11392e 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -84,6 +84,7 @@ struct tracecmd_input {
84 int cpus; 84 int cpus;
85 int ref; 85 int ref;
86 struct cpu_data *cpu_data; 86 struct cpu_data *cpu_data;
87 unsigned long long ts_offset;
87 88
88 struct tracecmd_ftrace finfo; 89 struct tracecmd_ftrace finfo;
89 90
@@ -1720,7 +1721,7 @@ read_again:
1720 return NULL; 1721 return NULL;
1721 memset(record, 0, sizeof(*record)); 1722 memset(record, 0, sizeof(*record));
1722 1723
1723 record->ts = handle->cpu_data[cpu].timestamp; 1724 record->ts = handle->cpu_data[cpu].timestamp + handle->ts_offset;
1724 record->size = length; 1725 record->size = length;
1725 record->cpu = cpu; 1726 record->cpu = cpu;
1726 record->data = ptr; 1727 record->data = ptr;
@@ -1962,30 +1963,48 @@ static int init_cpu(struct tracecmd_input *handle, int cpu)
1962 1963
1963static int handle_options(struct tracecmd_input *handle) 1964static int handle_options(struct tracecmd_input *handle)
1964{ 1965{
1966 unsigned long long offset;
1965 unsigned short option; 1967 unsigned short option;
1966 unsigned int size; 1968 unsigned int size;
1967 char *buf; 1969 char *buf;
1968 1970
1969 do { 1971 for (;;) {
1970 if (do_read_check(handle, &option, 2)) 1972 if (do_read_check(handle, &option, 2))
1971 return -1; 1973 return -1;
1972 1974
1975 if (option == TRACECMD_OPTION_DONE)
1976 break;
1977
1978 /* next 4 bytes is the size of the option */
1979 if (do_read_check(handle, &size, 4))
1980 return -1;
1981 size = __data2host4(handle->pevent, size);
1982 printf("size=%d\n", size);
1983 buf = malloc_or_die(size);
1984 if (do_read_check(handle, buf, size))
1985 return -1;
1986
1973 switch (option) { 1987 switch (option) {
1974 case TRACECMD_OPTION_DONE: 1988 case TRACECMD_OPTION_DATE:
1989 /*
1990 * A time has been mapped that is the
1991 * difference between the timestamps and
1992 * gtod. It is stored as ASCII with '0x'
1993 * appended.
1994 */
1995 offset = strtoll(buf, NULL, 0);
1996 /* Convert from micro to nano */
1997 offset *= 1000;
1998 handle->ts_offset = offset;
1975 break; 1999 break;
1976 default: 2000 default:
1977 warning("unknown option %d", option); 2001 warning("unknown option %d", option);
1978 /* next 4 bytes is the size of the option */
1979 if (do_read_check(handle, &size, 4))
1980 return -1;
1981 size = __data2host4(handle->pevent, size);
1982 buf = malloc_or_die(size);
1983 if (do_read_check(handle, buf, size))
1984 return -1;
1985 free(buf);
1986 break; 2002 break;
1987 } 2003 }
1988 } while (option != TRACECMD_OPTION_DONE); 2004
2005 free(buf);
2006
2007 }
1989 2008
1990 return 0; 2009 return 0;
1991} 2010}