Lines Matching refs:tb

17 	struct trace_buffer *tb;
19 if (size < sizeof(*tb)) {
24 tb = mmap(NULL, size, PROT_READ | PROT_WRITE,
26 if (tb == MAP_FAILED) {
31 tb->size = size;
32 tb->tail = tb->data;
33 tb->overflow = false;
35 return tb;
38 static bool trace_check_bounds(struct trace_buffer *tb, void *p)
40 return p < ((void *)tb + tb->size);
43 static bool trace_check_alloc(struct trace_buffer *tb, void *p)
51 if (tb->overflow)
54 if (!trace_check_bounds(tb, p)) {
55 tb->overflow = true;
62 static void *trace_alloc(struct trace_buffer *tb, int bytes)
66 p = tb->tail;
67 newtail = tb->tail + bytes;
68 if (!trace_check_alloc(tb, newtail))
71 tb->tail = newtail;
76 static struct trace_entry *trace_alloc_entry(struct trace_buffer *tb, int payload_size)
80 e = trace_alloc(tb, sizeof(*e) + payload_size);
87 int trace_log_reg(struct trace_buffer *tb, u64 reg, u64 value)
92 e = trace_alloc_entry(tb, sizeof(reg) + sizeof(value));
104 int trace_log_counter(struct trace_buffer *tb, u64 value)
109 e = trace_alloc_entry(tb, sizeof(value));
120 int trace_log_string(struct trace_buffer *tb, char *str)
129 e = trace_alloc_entry(tb, len + 1);
142 int trace_log_indent(struct trace_buffer *tb)
146 e = trace_alloc_entry(tb, 0);
155 int trace_log_outdent(struct trace_buffer *tb)
159 e = trace_alloc_entry(tb, 0);
269 void trace_buffer_print(struct trace_buffer *tb)
276 printf(" address %p \n", tb);
277 printf(" tail %p\n", tb->tail);
278 printf(" size %llu\n", tb->size);
279 printf(" overflow %s\n", tb->overflow ? "TRUE" : "false");
282 p = tb->data;
287 while (trace_check_bounds(tb, p) && p < tb->tail) {
297 void trace_print_location(struct trace_buffer *tb)
299 printf("Trace buffer 0x%llx bytes @ %p\n", tb->size, tb);