~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/trace_seq.h

Version: ~ [ linux-5.3-rc5 ] ~ [ linux-5.2.9 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.67 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.139 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.189 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.189 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.72 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp