unified: Add object tracing support for kernel objects

Defines an object tracing list for each kernel object type
that supports object tracing, and ensures that both statically
and dynamically defined objects are added to the appropriate list.

Ensure that each static kernel object is grouped together with
the other static objects of the same type. Revise the initialization
function for each kernel type (or create it, if needed) so that
each static object is added to the object tracing list for its
associated type.

Note 1: Threads are handled a bit differently than other kernel
object types. A statically-defined thread is added to the thread
list when the thread is started, not when the kernel initializes.
Also, a thread is removed from the thread list when the thread
terminates or aborts, unlike other types of kernel objects which
are never removed from an object tracing list. (Such support would
require the creation of APIs to "uninitialize" the kernel object.)

Note 2: The list head variables for all kernel object types
are now explicitly defined. However, the list head variable for
the ring buffer type continues to be implicitly defined for the
time being, since it isn't considered to be an core kernel object
type.

Change-Id: Ie24d41023e05b3598dc6b344e6871a9692bba02d
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
This commit is contained in:
Allan Stephens 2016-10-19 16:10:46 -05:00 committed by Anas Nashif
commit e7d2cc216d
17 changed files with 440 additions and 142 deletions

View file

@ -34,6 +34,7 @@
#include <wait_q.h>
#include <misc/dlist.h>
#include <ksched.h>
#include <init.h>
#ifdef CONFIG_SEMAPHORE_GROUPS
struct _sem_desc {
@ -48,6 +49,32 @@ struct _sem_thread {
};
#endif
extern struct k_sem _k_sem_list_start[];
extern struct k_sem _k_sem_list_end[];
struct k_sem *_trace_list_k_sem;
#ifdef CONFIG_DEBUG_TRACING_KERNEL_OBJECTS
/*
* Complete initialization of statically defined semaphores.
*/
static int init_sem_module(struct device *dev)
{
ARG_UNUSED(dev);
struct k_sem *sem;
for (sem = _k_sem_list_start; sem < _k_sem_list_end; sem++) {
SYS_TRACING_OBJ_INIT(k_sem, sem);
}
return 0;
}
SYS_INIT(init_sem_module, PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS);
#endif /* CONFIG_DEBUG_TRACING_KERNEL_OBJECTS */
void k_sem_init(struct k_sem *sem, unsigned int initial_count,
unsigned int limit)
{
@ -56,7 +83,7 @@ void k_sem_init(struct k_sem *sem, unsigned int initial_count,
sem->count = initial_count;
sem->limit = limit;
sys_dlist_init(&sem->wait_q);
SYS_TRACING_OBJ_INIT(nano_sem, sem);
SYS_TRACING_OBJ_INIT(k_sem, sem);
}
#ifdef CONFIG_SEMAPHORE_GROUPS