Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/libc/semaphore/sem_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#include <semaphore.h>
#include <errno.h>

#ifdef CONFIG_SEMAPHORE_HISTORY
#if defined(CONFIG_SEMAPHORE_HISTORY) && defined(__KERNEL__)
Copy link
Member

@pcs1265 pcs1265 Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, sysdbg cannot track sem_init of user-space semaphores.
You should mention this I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. As you mentioned, currently, sem_init calls from user-space may not be tracked.
Moving sem_init to the kernel and calling it via a syscall would solve this problem, but it would impact performance.
We need to discuss whether it's necessary to add tracking for sem_init in user-space.

And I updated this limitation in save_semaphore_history's explanation.

#include <tinyara/debug/sysdbg.h>
#endif
#if defined(CONFIG_BINMGR_RECOVERY) && defined(__KERNEL__)
Expand Down Expand Up @@ -110,7 +110,7 @@ int sem_init(FAR sem_t *sem, int pshared, unsigned int value)
/* Initialize the semaphore count */

sem->semcount = (int16_t)value;
#ifdef CONFIG_SEMAPHORE_HISTORY
#if defined(CONFIG_SEMAPHORE_HISTORY) && defined(__KERNEL__)
save_semaphore_history(sem, (void *)NULL, SEM_INIT);
#endif

Expand Down
10 changes: 10 additions & 0 deletions os/include/tinyara/debug/sysdbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,23 @@ typedef enum sem_status_s sem_status_t;

struct sysdbg_s {
#ifdef CONFIG_TASK_SCHED_HISTORY
#ifdef CONFIG_SMP
sched_history_t *sched[CONFIG_SMP_NCPUS];
int task_lastindex[CONFIG_SMP_NCPUS];
#else
sched_history_t *sched;
int task_lastindex;
#endif
#endif
#ifdef CONFIG_IRQ_SCHED_HISTORY
#ifdef CONFIG_SMP
irq_history_t *irq[CONFIG_SMP_NCPUS];
int irq_lastindex[CONFIG_SMP_NCPUS];
#else
irq_history_t *irq;
int irq_lastindex;
#endif
#endif
#ifdef CONFIG_SEMAPHORE_HISTORY
sem_history_t *sem_log;
int sem_lastindex;
Expand Down
Loading