Blame view
include/linux/trace_seq.h
3.72 KB
9504504cb tracing: make tra... |
1 2 |
#ifndef _LINUX_TRACE_SEQ_H #define _LINUX_TRACE_SEQ_H |
3a161d99c tracing: Create s... |
3 |
#include <linux/seq_buf.h> |
6d723736e tracing/events: a... |
4 |
|
78be6914c tracing: fix unde... |
5 |
#include <asm/page.h> |
9504504cb tracing: make tra... |
6 7 |
/* * Trace sequences are used to allow a function to call several other functions |
6d3f1e12f tracing: Remove c... |
8 |
* to create a string of data to use (up to a max of PAGE_SIZE). |
9504504cb tracing: make tra... |
9 10 11 12 |
*/ struct trace_seq { unsigned char buffer[PAGE_SIZE]; |
3a161d99c tracing: Create s... |
13 |
struct seq_buf seq; |
d184b31c0 tracing: Add full... |
14 |
int full; |
9504504cb tracing: make tra... |
15 16 17 18 19 |
}; static inline void trace_seq_init(struct trace_seq *s) { |
3a161d99c tracing: Create s... |
20 |
seq_buf_init(&s->seq, s->buffer, PAGE_SIZE); |
d184b31c0 tracing: Add full... |
21 |
s->full = 0; |
9504504cb tracing: make tra... |
22 |
} |
7b039cb4c tracing: Add trac... |
23 |
/** |
5ac483784 tracing: Use trac... |
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
* trace_seq_used - amount of actual data written to buffer * @s: trace sequence descriptor * * Returns the amount of data written to the buffer. * * IMPORTANT! * * Use this instead of @s->seq.len if you need to pass the amount * of data from the buffer to another buffer (userspace, or what not). * The @s->seq.len on overflow is bigger than the buffer size and * using it can cause access to undefined memory. */ static inline int trace_seq_used(struct trace_seq *s) { return seq_buf_used(&s->seq); } /** |
7b039cb4c tracing: Add trac... |
42 43 44 45 46 47 48 49 50 51 52 |
* trace_seq_buffer_ptr - return pointer to next location in buffer * @s: trace sequence descriptor * * Returns the pointer to the buffer where the next write to * the buffer will happen. This is useful to save the location * that is about to be written to and then return the result * of that write. */ static inline unsigned char * trace_seq_buffer_ptr(struct trace_seq *s) { |
5ac483784 tracing: Use trac... |
53 |
return s->buffer + seq_buf_used(&s->seq); |
7b039cb4c tracing: Add trac... |
54 |
} |
19a7fe206 tracing: Add trac... |
55 56 57 58 59 60 61 62 63 |
/** * trace_seq_has_overflowed - return true if the trace_seq took too much * @s: trace sequence descriptor * * Returns true if too much data was added to the trace_seq and it is * now full and will not take anymore. */ static inline bool trace_seq_has_overflowed(struct trace_seq *s) { |
3a161d99c tracing: Create s... |
64 |
return s->full || seq_buf_has_overflowed(&s->seq); |
19a7fe206 tracing: Add trac... |
65 |
} |
9504504cb tracing: make tra... |
66 67 68 69 |
/* * Currently only defined when tracing is enabled. */ #ifdef CONFIG_TRACING |
b9075fa96 treewide: use __p... |
70 |
extern __printf(2, 3) |
dba39448a tracing: Remove r... |
71 |
void trace_seq_printf(struct trace_seq *s, const char *fmt, ...); |
b9075fa96 treewide: use __p... |
72 |
extern __printf(2, 0) |
dba39448a tracing: Remove r... |
73 74 |
void trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args); extern void |
9504504cb tracing: make tra... |
75 |
trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary); |
a63ce5b30 tracing: Buffer t... |
76 |
extern int trace_print_seq(struct seq_file *m, struct trace_seq *s); |
36aabfff5 tracing: Clean up... |
77 78 |
extern int trace_seq_to_user(struct trace_seq *s, char __user *ubuf, int cnt); |
dba39448a tracing: Remove r... |
79 80 81 82 |
extern void trace_seq_puts(struct trace_seq *s, const char *str); extern void trace_seq_putc(struct trace_seq *s, unsigned char c); extern void trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len); extern void trace_seq_putmem_hex(struct trace_seq *s, const void *mem, |
36aabfff5 tracing: Clean up... |
83 |
unsigned int len); |
38eff2892 constify path arg... |
84 |
extern int trace_seq_path(struct trace_seq *s, const struct path *path); |
9504504cb tracing: make tra... |
85 |
|
dba39448a tracing: Remove r... |
86 |
extern void trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, |
4449bf927 tracing: Add __bi... |
87 |
int nmaskbits); |
9504504cb tracing: make tra... |
88 |
#else /* CONFIG_TRACING */ |
dba39448a tracing: Remove r... |
89 |
static inline void trace_seq_printf(struct trace_seq *s, const char *fmt, ...) |
9504504cb tracing: make tra... |
90 |
{ |
9504504cb tracing: make tra... |
91 |
} |
dba39448a tracing: Remove r... |
92 |
static inline void |
9504504cb tracing: make tra... |
93 94 |
trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) { |
9504504cb tracing: make tra... |
95 |
} |
dba39448a tracing: Remove r... |
96 |
static inline void |
4449bf927 tracing: Add __bi... |
97 98 99 |
trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, int nmaskbits) { |
4449bf927 tracing: Add __bi... |
100 |
} |
a63ce5b30 tracing: Buffer t... |
101 |
static inline int trace_print_seq(struct seq_file *m, struct trace_seq *s) |
9504504cb tracing: make tra... |
102 |
{ |
a63ce5b30 tracing: Buffer t... |
103 |
return 0; |
9504504cb tracing: make tra... |
104 |
} |
36aabfff5 tracing: Clean up... |
105 106 |
static inline int trace_seq_to_user(struct trace_seq *s, char __user *ubuf, int cnt) |
9504504cb tracing: make tra... |
107 108 109 |
{ return 0; } |
dba39448a tracing: Remove r... |
110 |
static inline void trace_seq_puts(struct trace_seq *s, const char *str) |
9504504cb tracing: make tra... |
111 |
{ |
9504504cb tracing: make tra... |
112 |
} |
dba39448a tracing: Remove r... |
113 |
static inline void trace_seq_putc(struct trace_seq *s, unsigned char c) |
9504504cb tracing: make tra... |
114 |
{ |
9504504cb tracing: make tra... |
115 |
} |
dba39448a tracing: Remove r... |
116 |
static inline void |
36aabfff5 tracing: Clean up... |
117 |
trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len) |
9504504cb tracing: make tra... |
118 |
{ |
9504504cb tracing: make tra... |
119 |
} |
dba39448a tracing: Remove r... |
120 |
static inline void trace_seq_putmem_hex(struct trace_seq *s, const void *mem, |
36aabfff5 tracing: Clean up... |
121 |
unsigned int len) |
9504504cb tracing: make tra... |
122 |
{ |
9504504cb tracing: make tra... |
123 |
} |
38eff2892 constify path arg... |
124 |
static inline int trace_seq_path(struct trace_seq *s, const struct path *path) |
9504504cb tracing: make tra... |
125 126 127 128 129 130 |
{ return 0; } #endif /* CONFIG_TRACING */ #endif /* _LINUX_TRACE_SEQ_H */ |