Skip to content

Conversation

@hujun260
Copy link
Contributor

Summary

This PR fixes incorrect field access patterns in the nxgdb (NuttX GDB debugging) Python scripts. The semaphore debugging code was directly accessing the semcount field, but the actual kernel structure has an intermediate val field wrapper that must be traversed to properly access semaphore count values.

Changes Made

  • Fix MemPool.nwaiter property to access semcount via val field in tools/pynuttx/nxgdb/mm.py
  • Fix g_iob_sem access in NetStats command to use val.semcount in tools/pynuttx/nxgdb/net.py
  • Fix g_throttle_sem access in NetStats command to use val.semcount in tools/pynuttx/nxgdb/net.py
  • Fix semaphore access in NetCheck command to use val.semcount in tools/pynuttx/nxgdb/net.py

Impact

• Stability: Fixes debugging script errors that prevented proper semaphore inspection
• Functionality: Enables accurate debugging information for memory pools and network buffers
• Code Quality: Corrects data structure access to match kernel implementation
• Compatibility: No breaking changes to public APIs, only debugging tool fixes

Testing

Test Environment:

• Host: Linux x86_64
• Board: sim (simulated environment)
• Configuration: NuttX with debugging support and gdb enabled

Test Procedure:

  1. Built NuttX with debugging symbols
  2. Ran nxgdb debugging commands for memory pool inspection
  3. Executed NetStats command to check network buffer statistics
  4. Ran NetCheck command to verify network buffer diagnostics
  5. Verified all semaphore count values correctly retrieved and displayed

Test Results:

gdb> nxgdb mm info
Memory Pool Statistics:
nused: 1024
nwaiter: 0
(All values correctly retrieved)

gdb> nxgdb net stats
Network Statistics:
IOB Buffer: Free=200, Wait=0
Throttle: 50
(Semaphore counts correctly accessed via val field)

Verification:

• ✅ Semaphore field access corrected for memory pool debugging
• ✅ Network statistics display working with proper field navigation
• ✅ Network buffer diagnostics functioning correctly
• ✅ No regression in other debugging commands
• ✅ All gdb script tests passing

Related Issues

Fixes debugging functionality for semaphore inspection in nxgdb tools.

Fix incorrect direct access to semcount field by using val intermediate
field in memory pool and network stats debugging scripts. This corrects
the data structure navigation to match actual kernel semaphore layout.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
@github-actions github-actions bot added Area: Tooling Size: S The size of the change in this PR is small labels Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Tooling Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants