Merge branch 'address-masking'
[linux-2.6-block.git] / include / linux / trace.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
478409dd
CZ
2#ifndef _LINUX_TRACE_H
3#define _LINUX_TRACE_H
4
8438f521 5#define TRACE_EXPORT_FUNCTION BIT(0)
8ab7a2b7 6#define TRACE_EXPORT_EVENT BIT(1)
458999c6 7#define TRACE_EXPORT_MARKER BIT(2)
8438f521 8
478409dd
CZ
9/*
10 * The trace export - an export of Ftrace output. The trace_export
11 * can process traces and export them to a registered destination as
12 * an addition to the current only output of Ftrace - i.e. ring buffer.
13 *
14 * If you want traces to be sent to some other place rather than ring
15 * buffer only, just need to register a new trace_export and implement
16 * its own .write() function for writing traces to the storage.
17 *
18 * next - pointer to the next trace_export
19 * write - copy traces which have been delt with ->commit() to
20 * the destination
8438f521 21 * flags - which ftrace to be exported
478409dd
CZ
22 */
23struct trace_export {
24 struct trace_export __rcu *next;
a773d419 25 void (*write)(struct trace_export *, const void *, unsigned int);
8438f521 26 int flags;
478409dd
CZ
27};
28
bedf0683
AS
29struct trace_array;
30
1a77dd1c
AE
31#ifdef CONFIG_TRACING
32
478409dd
CZ
33int register_ftrace_export(struct trace_export *export);
34int unregister_ftrace_export(struct trace_export *export);
35
d503b8f7
SRG
36/**
37 * trace_array_puts - write a constant string into the trace buffer.
38 * @tr: The trace array to write to
39 * @str: The constant string to write
40 */
41#define trace_array_puts(tr, str) \
42 ({ \
43 str ? __trace_array_puts(tr, _THIS_IP_, str, strlen(str)) : -1; \
44 })
45int __trace_array_puts(struct trace_array *tr, unsigned long ip,
46 const char *str, int size);
47
2d6425af 48void trace_printk_init_buffers(void);
bd0c9706 49__printf(3, 4)
2d6425af 50int trace_array_printk(struct trace_array *tr, unsigned long ip,
bd0c9706 51 const char *fmt, ...);
38ce2a9e 52int trace_array_init_printk(struct trace_array *tr);
28879787 53void trace_array_put(struct trace_array *tr);
d2356997 54struct trace_array *trace_array_get_by_name(const char *name, const char *systems);
2d6425af 55int trace_array_destroy(struct trace_array *tr);
bce29ac9
DBO
56
57/* For osnoise tracer */
58int osnoise_arch_register(void);
59void osnoise_arch_unregister(void);
f7d9f637
DBO
60void osnoise_trace_irq_entry(int id);
61void osnoise_trace_irq_exit(int id, const char *desc);
bce29ac9 62
1a77dd1c
AE
63#else /* CONFIG_TRACING */
64static inline int register_ftrace_export(struct trace_export *export)
65{
66 return -EINVAL;
67}
68static inline int unregister_ftrace_export(struct trace_export *export)
69{
70 return 0;
71}
72static inline void trace_printk_init_buffers(void)
73{
74}
75static inline int trace_array_printk(struct trace_array *tr, unsigned long ip,
76 const char *fmt, ...)
77{
78 return 0;
79}
80static inline int trace_array_init_printk(struct trace_array *tr)
81{
82 return -EINVAL;
83}
84static inline void trace_array_put(struct trace_array *tr)
85{
86}
d2356997 87static inline struct trace_array *trace_array_get_by_name(const char *name, const char *systems)
1a77dd1c
AE
88{
89 return NULL;
90}
91static inline int trace_array_destroy(struct trace_array *tr)
92{
93 return 0;
94}
478409dd
CZ
95#endif /* CONFIG_TRACING */
96
97#endif /* _LINUX_TRACE_H */