Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@seokhun-eom24
Copy link
Contributor

@seokhun-eom24 seokhun-eom24 commented Dec 22, 2025

Add current errno and task-specific pterrno to the assertion detail logs.

[Global IRQ errno]

===========================================================
Assertion details
===========================================================
Assertion failed CPU0 at file: chip/amebasmart_timerisr.c line 70 irq: 27
print_assert_detail: Assert location (PC) : 0x0e028459
check_assert_location: Code asserted in IRQ state!
check_assert_location: IRQ num: 27
check_assert_location: IRQ handler: 0e0283f5
check_assert_location: IRQ errno: 0
===========================================================

[TCB errno]

===========================================================
Asserted task's TCB info
===========================================================
task_show_tcbinfo: State       : 4
task_show_tcbinfo: Flags       : 6
task_show_tcbinfo: Errno       : 0
task_show_tcbinfo: Lock count  : 0
task_show_tcbinfo: Timeslice   : 0
task_show_tcbinfo: Waitdog     : 0
task_show_tcbinfo: WaitSem     : 0
task_show_tcbinfo: MsgwaitQ    : 0
task_show_tcbinfo: Sigdeliver  : 0
task_show_tcbinfo: Nsyscalls   : 0
===========================================================

tools/trap: Add errno mapping and display for assert logs

  • Update TCB and IRQ information parsing to display errno
  • Implement init_errno_info() to map errno values to description

[Trap tool example]

5. Assertion Data during interrupt mode:

	- Interrupt handler at addr		Symbol_name
	  0xe0283b5				bsp_pm_domain_control

	- Interrupt number			: 27
	- Interrupt errno			: 9 	 - EBADF(Bad file number)

t. Asserted TCB info:

 State       : Inactive
 Flags       : 6	 - Kernel Thread	 - Non-cancellable Pthread
 Errno       : 22	 - EINVAL(Invalid argument)
 Lock count  : 0
 Timeslice   : 0
 Waitdog     : 0
 WaitSem     : 0
 MsgwaitQ    : 0
 Sigdeliver  : 0
 Nsyscalls   : 0

Add current errno and task-specific pterrno to the assertion detail logs.

[Global IRQ errno]
```
===========================================================
Assertion details
===========================================================
Assertion failed CPU0 at file: chip/amebasmart_timerisr.c line 70 irq: 27
print_assert_detail: Assert location (PC) : 0x0e028459
check_assert_location: Code asserted in IRQ state!
check_assert_location: IRQ num: 27
check_assert_location: IRQ handler: 0e0283f5
check_assert_location: IRQ errno: 0
===========================================================
```

[TCB errno]
```
===========================================================
Asserted task's TCB info
===========================================================
task_show_tcbinfo: State       : 4
task_show_tcbinfo: Flags       : 6
task_show_tcbinfo: Errno       : 0
task_show_tcbinfo: Lock count  : 0
task_show_tcbinfo: Timeslice   : 0
task_show_tcbinfo: Waitdog     : 0
task_show_tcbinfo: WaitSem     : 0
task_show_tcbinfo: MsgwaitQ    : 0
task_show_tcbinfo: Sigdeliver  : 0
task_show_tcbinfo: Nsyscalls   : 0
===========================================================
```

Signed-off-by: seokhun-eom <[email protected]>
@seokhun-eom24 seokhun-eom24 force-pushed the 251222-add-errno-assert-log branch from 8adfc08 to 3ff3ecb Compare December 22, 2025 05:14
@seokhun-eom24 seokhun-eom24 changed the title arch/arm: Include errno and TCB pterrno in assert logs os: Include errno and TCB pterrno in assert logs Dec 22, 2025
Copy link
Contributor

@ewoodev ewoodev left a comment

Choose a reason for hiding this comment

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

Could you please explain more why we need errno in assertion log?

@seokhun-eom24
Copy link
Contributor Author

Could you please explain more why we need errno in assertion log?

This change was inspired by the following code snippet.

static void i2s_exclsem_take(struct amebasmart_i2s_s *priv)
{
	int ret;

	/* Wait until we successfully get the semaphore.  EINTR is the only
	 * expected 'failure' (meaning that the wait for the semaphore was
	 * interrupted by a signal.
	 */
	do {
		ret = sem_wait(&priv->exclsem);
		DEBUGASSERT(ret == OK || errno == EINTR);
	} while (ret != OK);
}

In code like the above, when an assertion occurs, it is difficult to determine the exact errno value that was set at the time of the failure.
To address this issue, I modified to ensure that the errno is also visible in the assertion logs.

- Update TCB and IRQ information parsing to display errno
- Implement init_errno_info() to map errno values to description

[Trap tool example]
```
5. Assertion Data during interrupt mode:

	- Interrupt handler at addr		Symbol_name
	  0xe0283b5				bsp_pm_domain_control

	- Interrupt number			: 27
	- Interrupt errno			: 9 	 - EBADF(Bad file number)

t. Asserted TCB info:

 State       : Inactive
 Flags       : 6	 - Kernel Thread	 - Non-cancellable Pthread
 Errno       : 22	 - EINVAL(Invalid argument)
 Lock count  : 0
 Timeslice   : 0
 Waitdog     : 0
 WaitSem     : 0
 MsgwaitQ    : 0
 Sigdeliver  : 0
 Nsyscalls   : 0
```

Signed-off-by: seokhun-eom <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants