1
2#ifndef _LINUX_DEBUGOBJECTS_H
3#define _LINUX_DEBUGOBJECTS_H
4
5#include <linux/list.h>
6#include <linux/spinlock.h>
7
8enum debug_obj_state {
9 ODEBUG_STATE_NONE,
10 ODEBUG_STATE_INIT,
11 ODEBUG_STATE_INACTIVE,
12 ODEBUG_STATE_ACTIVE,
13 ODEBUG_STATE_DESTROYED,
14 ODEBUG_STATE_NOTAVAILABLE,
15 ODEBUG_STATE_MAX,
16};
17
18struct debug_obj_descr;
19
20
21
22
23
24
25
26
27
28struct debug_obj {
29 struct hlist_node node;
30 enum debug_obj_state state;
31 unsigned int astate;
32 void *object;
33 struct debug_obj_descr *descr;
34};
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55struct debug_obj_descr {
56 const char *name;
57 void *(*debug_hint)(void *addr);
58 bool (*is_static_object)(void *addr);
59 bool (*fixup_init)(void *addr, enum debug_obj_state state);
60 bool (*fixup_activate)(void *addr, enum debug_obj_state state);
61 bool (*fixup_destroy)(void *addr, enum debug_obj_state state);
62 bool (*fixup_free)(void *addr, enum debug_obj_state state);
63 bool (*fixup_assert_init)(void *addr, enum debug_obj_state state);
64};
65
66#ifdef CONFIG_DEBUG_OBJECTS
67extern void debug_object_init (void *addr, struct debug_obj_descr *descr);
68extern void
69debug_object_init_on_stack(void *addr, struct debug_obj_descr *descr);
70extern int debug_object_activate (void *addr, struct debug_obj_descr *descr);
71extern void debug_object_deactivate(void *addr, struct debug_obj_descr *descr);
72extern void debug_object_destroy (void *addr, struct debug_obj_descr *descr);
73extern void debug_object_free (void *addr, struct debug_obj_descr *descr);
74extern void debug_object_assert_init(void *addr, struct debug_obj_descr *descr);
75
76
77
78
79
80
81extern void
82debug_object_active_state(void *addr, struct debug_obj_descr *descr,
83 unsigned int expect, unsigned int next);
84
85extern void debug_objects_early_init(void);
86extern void debug_objects_mem_init(void);
87#else
88static inline void
89debug_object_init (void *addr, struct debug_obj_descr *descr) { }
90static inline void
91debug_object_init_on_stack(void *addr, struct debug_obj_descr *descr) { }
92static inline int
93debug_object_activate (void *addr, struct debug_obj_descr *descr) { return 0; }
94static inline void
95debug_object_deactivate(void *addr, struct debug_obj_descr *descr) { }
96static inline void
97debug_object_destroy (void *addr, struct debug_obj_descr *descr) { }
98static inline void
99debug_object_free (void *addr, struct debug_obj_descr *descr) { }
100static inline void
101debug_object_assert_init(void *addr, struct debug_obj_descr *descr) { }
102
103static inline void debug_objects_early_init(void) { }
104static inline void debug_objects_mem_init(void) { }
105#endif
106
107#ifdef CONFIG_DEBUG_OBJECTS_FREE
108extern void debug_check_no_obj_freed(const void *address, unsigned long size);
109#else
110static inline void
111debug_check_no_obj_freed(const void *address, unsigned long size) { }
112#endif
113
114#endif
115