Skip to content

Commit 374855c

Browse files
rostedtacmel
authored andcommitted
tools lib traceevent: Add API to read time information from kbuffer
Add the functions kbuffer_subbuf_timestamp() and kbuffer_ptr_delta() to get the timing data stored in the ring buffer that is used to produced the time stamps of the records. This is useful for tools like trace-cmd to be able to display the content of the read data to understand why the records show the time stamps that they do. Link: http://lore.kernel.org/linux-trace-devel/[email protected] Signed-off-by: Steven Rostedt (VMware) <[email protected]> [ Ported from trace-cmd.git ] Cc: Andrew Morton <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: [email protected] Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Tzvetomir Stoyanov (VMware) <[email protected]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent f18d5cf commit 374855c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tools/lib/traceevent/kbuffer-parse.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,34 @@ int kbuffer_load_subbuffer(struct kbuffer *kbuf, void *subbuffer)
546546
return 0;
547547
}
548548

549+
/**
550+
* kbuffer_subbuf_timestamp - read the timestamp from a sub buffer
551+
* @kbuf: The kbuffer to load
552+
* @subbuf: The subbuffer to read from.
553+
*
554+
* Return the timestamp from a subbuffer.
555+
*/
556+
unsigned long long kbuffer_subbuf_timestamp(struct kbuffer *kbuf, void *subbuf)
557+
{
558+
return kbuf->read_8(subbuf);
559+
}
560+
561+
/**
562+
* kbuffer_ptr_delta - read the delta field from a record
563+
* @kbuf: The kbuffer to load
564+
* @ptr: The record in the buffe.
565+
*
566+
* Return the timestamp delta from a record
567+
*/
568+
unsigned int kbuffer_ptr_delta(struct kbuffer *kbuf, void *ptr)
569+
{
570+
unsigned int type_len_ts;
571+
572+
type_len_ts = read_4(kbuf, ptr);
573+
return ts4host(kbuf, type_len_ts);
574+
}
575+
576+
549577
/**
550578
* kbuffer_read_event - read the next event in the kbuffer subbuffer
551579
* @kbuf: The kbuffer to read from

tools/lib/traceevent/kbuffer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ int kbuffer_load_subbuffer(struct kbuffer *kbuf, void *subbuffer);
4949
void *kbuffer_read_event(struct kbuffer *kbuf, unsigned long long *ts);
5050
void *kbuffer_next_event(struct kbuffer *kbuf, unsigned long long *ts);
5151
unsigned long long kbuffer_timestamp(struct kbuffer *kbuf);
52+
unsigned long long kbuffer_subbuf_timestamp(struct kbuffer *kbuf, void *subbuf);
53+
unsigned int kbuffer_ptr_delta(struct kbuffer *kbuf, void *ptr);
5254

5355
void *kbuffer_translate_data(int swap, void *data, unsigned int *size);
5456

0 commit comments

Comments
 (0)