object tracing: Fix the issue that objects lost from trace list
Add a flag for identifing whether this object is on the trace list. Ensure that link any object to the trace list only one time. It will avoid the issue about lost object caused by adding a object to trace list twice. Fixes #19537 Signed-off-by: Shih-Wei Teng <swteng@andestech.com>
This commit is contained in:
parent
13120f7313
commit
5ebceeb8cb
2 changed files with 26 additions and 10 deletions
|
@ -38,8 +38,11 @@
|
||||||
unsigned int key; \
|
unsigned int key; \
|
||||||
\
|
\
|
||||||
key = irq_lock(); \
|
key = irq_lock(); \
|
||||||
|
if (!(obj)->__linked) { \
|
||||||
(obj)->__next = _trace_list_ ## name; \
|
(obj)->__next = _trace_list_ ## name; \
|
||||||
_trace_list_ ## name = obj; \
|
_trace_list_ ## name = obj; \
|
||||||
|
(obj)->__linked = 1; \
|
||||||
|
} \
|
||||||
irq_unlock(key); \
|
irq_unlock(key); \
|
||||||
} \
|
} \
|
||||||
while (false)
|
while (false)
|
||||||
|
|
|
@ -98,10 +98,14 @@ typedef struct {
|
||||||
|
|
||||||
#ifdef CONFIG_OBJECT_TRACING
|
#ifdef CONFIG_OBJECT_TRACING
|
||||||
#define _OBJECT_TRACING_NEXT_PTR(type) struct type *__next;
|
#define _OBJECT_TRACING_NEXT_PTR(type) struct type *__next;
|
||||||
#define _OBJECT_TRACING_INIT .__next = NULL,
|
#define _OBJECT_TRACING_LINKED_FLAG u8_t __linked;
|
||||||
|
#define _OBJECT_TRACING_INIT \
|
||||||
|
.__next = NULL, \
|
||||||
|
.__linked = 0,
|
||||||
#else
|
#else
|
||||||
#define _OBJECT_TRACING_INIT
|
#define _OBJECT_TRACING_INIT
|
||||||
#define _OBJECT_TRACING_NEXT_PTR(type)
|
#define _OBJECT_TRACING_NEXT_PTR(type)
|
||||||
|
#define _OBJECT_TRACING_LINKED_FLAG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_POLL
|
#ifdef CONFIG_POLL
|
||||||
|
@ -1461,6 +1465,7 @@ struct k_timer {
|
||||||
void *user_data;
|
void *user_data;
|
||||||
|
|
||||||
_OBJECT_TRACING_NEXT_PTR(k_timer)
|
_OBJECT_TRACING_NEXT_PTR(k_timer)
|
||||||
|
_OBJECT_TRACING_LINKED_FLAG
|
||||||
};
|
};
|
||||||
|
|
||||||
#define Z_TIMER_INITIALIZER(obj, expiry, stop) \
|
#define Z_TIMER_INITIALIZER(obj, expiry, stop) \
|
||||||
|
@ -1837,6 +1842,7 @@ struct k_queue {
|
||||||
};
|
};
|
||||||
|
|
||||||
_OBJECT_TRACING_NEXT_PTR(k_queue)
|
_OBJECT_TRACING_NEXT_PTR(k_queue)
|
||||||
|
_OBJECT_TRACING_LINKED_FLAG
|
||||||
};
|
};
|
||||||
|
|
||||||
#define _K_QUEUE_INITIALIZER(obj) \
|
#define _K_QUEUE_INITIALIZER(obj) \
|
||||||
|
@ -2559,6 +2565,7 @@ struct k_stack {
|
||||||
stack_data_t *base, *next, *top;
|
stack_data_t *base, *next, *top;
|
||||||
|
|
||||||
_OBJECT_TRACING_NEXT_PTR(k_stack)
|
_OBJECT_TRACING_NEXT_PTR(k_stack)
|
||||||
|
_OBJECT_TRACING_LINKED_FLAG
|
||||||
u8_t flags;
|
u8_t flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3214,6 +3221,7 @@ struct k_mutex {
|
||||||
int owner_orig_prio;
|
int owner_orig_prio;
|
||||||
|
|
||||||
_OBJECT_TRACING_NEXT_PTR(k_mutex)
|
_OBJECT_TRACING_NEXT_PTR(k_mutex)
|
||||||
|
_OBJECT_TRACING_LINKED_FLAG
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3316,6 +3324,7 @@ struct k_sem {
|
||||||
_POLL_EVENT;
|
_POLL_EVENT;
|
||||||
|
|
||||||
_OBJECT_TRACING_NEXT_PTR(k_sem)
|
_OBJECT_TRACING_NEXT_PTR(k_sem)
|
||||||
|
_OBJECT_TRACING_LINKED_FLAG
|
||||||
};
|
};
|
||||||
|
|
||||||
#define Z_SEM_INITIALIZER(obj, initial_count, count_limit) \
|
#define Z_SEM_INITIALIZER(obj, initial_count, count_limit) \
|
||||||
|
@ -3475,6 +3484,7 @@ struct k_msgq {
|
||||||
u32_t used_msgs;
|
u32_t used_msgs;
|
||||||
|
|
||||||
_OBJECT_TRACING_NEXT_PTR(k_msgq)
|
_OBJECT_TRACING_NEXT_PTR(k_msgq)
|
||||||
|
_OBJECT_TRACING_LINKED_FLAG
|
||||||
u8_t flags;
|
u8_t flags;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
@ -3772,6 +3782,7 @@ struct k_mbox {
|
||||||
struct k_spinlock lock;
|
struct k_spinlock lock;
|
||||||
|
|
||||||
_OBJECT_TRACING_NEXT_PTR(k_mbox)
|
_OBJECT_TRACING_NEXT_PTR(k_mbox)
|
||||||
|
_OBJECT_TRACING_LINKED_FLAG
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @cond INTERNAL_HIDDEN
|
* @cond INTERNAL_HIDDEN
|
||||||
|
@ -3956,6 +3967,7 @@ struct k_pipe {
|
||||||
} wait_q;
|
} wait_q;
|
||||||
|
|
||||||
_OBJECT_TRACING_NEXT_PTR(k_pipe)
|
_OBJECT_TRACING_NEXT_PTR(k_pipe)
|
||||||
|
_OBJECT_TRACING_LINKED_FLAG
|
||||||
u8_t flags; /**< Flags */
|
u8_t flags; /**< Flags */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4133,6 +4145,7 @@ struct k_mem_slab {
|
||||||
u32_t num_used;
|
u32_t num_used;
|
||||||
|
|
||||||
_OBJECT_TRACING_NEXT_PTR(k_mem_slab)
|
_OBJECT_TRACING_NEXT_PTR(k_mem_slab)
|
||||||
|
_OBJECT_TRACING_LINKED_FLAG
|
||||||
};
|
};
|
||||||
|
|
||||||
#define _K_MEM_SLAB_INITIALIZER(obj, slab_buffer, slab_block_size, \
|
#define _K_MEM_SLAB_INITIALIZER(obj, slab_buffer, slab_block_size, \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue