systemview: Use common function to get sysview thread name
Use a common function to get the thread name. There was no necessity in keeping sys_trace_thread_info() inline, Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This commit is contained in:
parent
7a9da57cd8
commit
bc6d16e422
|
@ -105,6 +105,35 @@ void sys_trace_mutex_unlock(struct k_mutex *mutex)
|
|||
SYS_TRACE_ID_MUTEX_UNLOCK, (uint32_t)(uintptr_t)mutex);
|
||||
}
|
||||
|
||||
static void set_thread_name(char *name, struct k_thread *thread)
|
||||
{
|
||||
const char *tname = k_thread_name_get(thread);
|
||||
|
||||
if (tname != NULL && tname[0] != '\0') {
|
||||
memcpy(name, tname, THREAD_NAME_LEN);
|
||||
name[THREAD_NAME_LEN - 1] = '\0';
|
||||
} else {
|
||||
snprintk(name, THREAD_NAME_LEN, "T%pE%p",
|
||||
thread, &thread->entry);
|
||||
}
|
||||
}
|
||||
|
||||
void sys_trace_thread_info(struct k_thread *thread)
|
||||
{
|
||||
char name[THREAD_NAME_LEN];
|
||||
|
||||
set_thread_name(name, thread);
|
||||
|
||||
SEGGER_SYSVIEW_TASKINFO Info;
|
||||
|
||||
Info.TaskID = (uint32_t)(uintptr_t)thread;
|
||||
Info.sName = name;
|
||||
Info.Prio = thread->base.prio;
|
||||
Info.StackBase = thread->stack_info.size;
|
||||
Info.StackSize = thread->stack_info.start;
|
||||
SEGGER_SYSVIEW_SendTaskInfo(&Info);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void send_task_list_cb(void)
|
||||
|
@ -113,19 +142,13 @@ static void send_task_list_cb(void)
|
|||
|
||||
for (thread = _kernel.threads; thread; thread = thread->next_thread) {
|
||||
char name[THREAD_NAME_LEN];
|
||||
const char *tname = k_thread_name_get(thread);
|
||||
|
||||
if (z_is_idle_thread_object(thread)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tname != NULL && tname[0] != '\0') {
|
||||
memcpy(name, tname, THREAD_NAME_LEN);
|
||||
name[THREAD_NAME_LEN - 1] = '\0';
|
||||
} else {
|
||||
snprintk(name, sizeof(name), "T%pE%p",
|
||||
thread, &thread->entry);
|
||||
}
|
||||
set_thread_name(name, thread);
|
||||
|
||||
SEGGER_SYSVIEW_SendTaskInfo(&(SEGGER_SYSVIEW_TASKINFO) {
|
||||
.TaskID = (uint32_t)(uintptr_t)thread,
|
||||
.sName = name,
|
||||
|
|
|
@ -25,37 +25,10 @@ void sys_trace_semaphore_give(struct k_sem *sem);
|
|||
void sys_trace_mutex_init(struct k_mutex *mutex);
|
||||
void sys_trace_mutex_lock(struct k_mutex *mutex);
|
||||
void sys_trace_mutex_unlock(struct k_mutex *mutex);
|
||||
void sys_trace_thread_info(struct k_thread *thread);
|
||||
|
||||
#define sys_trace_thread_priority_set(thread)
|
||||
|
||||
static inline void sys_trace_thread_info(struct k_thread *thread)
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_THREAD_NAME)
|
||||
char name[CONFIG_THREAD_MAX_NAME_LEN];
|
||||
#else
|
||||
char name[20];
|
||||
#endif
|
||||
|
||||
const char *tname = k_thread_name_get(thread);
|
||||
|
||||
if (tname != NULL && tname[0] != '\0') {
|
||||
memcpy(name, tname, sizeof(name));
|
||||
name[sizeof(name) - 1] = '\0';
|
||||
} else {
|
||||
snprintk(name, sizeof(name), "T%pE%p",
|
||||
thread, &thread->entry);
|
||||
}
|
||||
|
||||
SEGGER_SYSVIEW_TASKINFO Info;
|
||||
|
||||
Info.TaskID = (uint32_t)(uintptr_t)thread;
|
||||
Info.sName = name;
|
||||
Info.Prio = thread->base.prio;
|
||||
Info.StackBase = thread->stack_info.size;
|
||||
Info.StackSize = thread->stack_info.start;
|
||||
SEGGER_SYSVIEW_SendTaskInfo(&Info);
|
||||
}
|
||||
|
||||
#define sys_trace_thread_create(thread) \
|
||||
do { \
|
||||
SEGGER_SYSVIEW_OnTaskCreate((uint32_t)(uintptr_t)thread); \
|
||||
|
|
Loading…
Reference in a new issue