Something went wrong. Try again.
(I'm so sorry!) Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119/* SPDX-License-Identifier: GPL-2.0 */#ifndef _LINUX_DEBUGOBJECTS_H#define _LINUX_DEBUGOBJECTS_H
#include <linux/list.h>#include <linux/spinlock.h>
enum debug_obj_state { ODEBUG_STATE_NONE, ODEBUG_STATE_INIT, ODEBUG_STATE_INACTIVE, ODEBUG_STATE_ACTIVE, ODEBUG_STATE_DESTROYED, ODEBUG_STATE_NOTAVAILABLE, ODEBUG_STATE_MAX,};
struct debug_obj_descr;
/** * struct debug_obj - representation of an tracked object * @node: hlist node to link the object into the tracker list * @state: tracked object state * @astate: current active state * @object: pointer to the real object * @batch_last: pointer to the last hlist node in a batch * @descr: pointer to an object type specific debug description structure */struct debug_obj { struct hlist_node node; enum debug_obj_state state; unsigned int astate; union { void *object; struct hlist_node *batch_last; }; const struct debug_obj_descr *descr;};
/** * struct debug_obj_descr - object type specific debug description structure * * @name: name of the object typee * @debug_hint: function returning address, which have associated * kernel symbol, to allow identify the object * @is_static_object: return true if the obj is static, otherwise return false * @fixup_init: fixup function, which is called when the init check * fails. All fixup functions must return true if fixup * was successful, otherwise return false * @fixup_activate: fixup function, which is called when the activate check * fails * @fixup_destroy: fixup function, which is called when the destroy check * fails * @fixup_free: fixup function, which is called when the free check * fails * @fixup_assert_init: fixup function, which is called when the assert_init * check fails */struct debug_obj_descr { const char *name; void *(*debug_hint)(void *addr); bool (*is_static_object)(void *addr); bool (*fixup_init)(void *addr, enum debug_obj_state state); bool (*fixup_activate)(void *addr, enum debug_obj_state state); bool (*fixup_destroy)(void *addr, enum debug_obj_state state); bool (*fixup_free)(void *addr, enum debug_obj_state state); bool (*fixup_assert_init)(void *addr, enum debug_obj_state state);};
#ifdef CONFIG_DEBUG_OBJECTSextern void debug_object_init (void *addr, const struct debug_obj_descr *descr);extern voiddebug_object_init_on_stack(void *addr, const struct debug_obj_descr *descr);extern int debug_object_activate (void *addr, const struct debug_obj_descr *descr);extern void debug_object_deactivate(void *addr, const struct debug_obj_descr *descr);extern void debug_object_destroy (void *addr, const struct debug_obj_descr *descr);extern void debug_object_free (void *addr, const struct debug_obj_descr *descr);extern void debug_object_assert_init(void *addr, const struct debug_obj_descr *descr);
/* * Active state: * - Set at 0 upon initialization. * - Must return to 0 before deactivation. */extern voiddebug_object_active_state(void *addr, const struct debug_obj_descr *descr, unsigned int expect, unsigned int next);
extern void debug_objects_early_init(void);extern void debug_objects_mem_init(void);#elsestatic inline voiddebug_object_init (void *addr, const struct debug_obj_descr *descr) { }static inline voiddebug_object_init_on_stack(void *addr, const struct debug_obj_descr *descr) { }static inline intdebug_object_activate (void *addr, const struct debug_obj_descr *descr) { return 0; }static inline voiddebug_object_deactivate(void *addr, const struct debug_obj_descr *descr) { }static inline voiddebug_object_destroy (void *addr, const struct debug_obj_descr *descr) { }static inline voiddebug_object_free (void *addr, const struct debug_obj_descr *descr) { }static inline voiddebug_object_assert_init(void *addr, const struct debug_obj_descr *descr) { }
static inline void debug_objects_early_init(void) { }static inline void debug_objects_mem_init(void) { }#endif
#ifdef CONFIG_DEBUG_OBJECTS_FREEextern void debug_check_no_obj_freed(const void *address, unsigned long size);#elsestatic inline voiddebug_check_no_obj_freed(const void *address, unsigned long size) { }#endif
#endif