Repository navigation
tools/trap: Fix TCB log parsing and detect semaphore circular waits - #7676
Open
namanjain7 wants to merge 2 commits into
Open
namanjain7 wants to merge 2 commits into
namanjain7 wants to merge 2 commits into
Conversation
Parse application text ranges from the loading location section in one pass and compare addresses numerically. Resolve saved syscall return addresses using the appropriate XIP or non-XIP address. Recognize the current Task TCB info heading and decode thread type and scheduling policy using their masks, including zero-valued fields. Example raw log: Loading location information =========================================================== elf_show_all_bin_section_addr: [common] Text Addr : 0x70400020, Text Size : 227296 elf_show_all_bin_section_addr: [app1] Text Addr : 0x706c8a20, Text Size : 96 elf_show_all_bin_section_addr: [app2] Text Addr : 0x704d4740, Text Size : 96 Task TCB info =========================================================== task_show_tcbinfo: PID : 20 task_show_tcbinfo: Name : hello task_show_tcbinfo: CPU : 0 task_show_tcbinfo: Priority : 100 task_show_tcbinfo: TCB address : 0x70028490 task_show_tcbinfo: State : 4 task_show_tcbinfo: Flags : 32 task_show_tcbinfo: Lock count : 0 task_show_tcbinfo: Timeslice : 10 task_show_tcbinfo: Waitdog : 0 task_show_tcbinfo: WaitSem : 0 task_show_tcbinfo: MsgwaitQ : 0 task_show_tcbinfo: Sigdeliver : 0 task_show_tcbinfo: Nsyscalls : 1 task_show_tcbinfo: Syscall 0 : 0x70426bca Corresponding TRAP output: Number of binaries : 4 [kernel + apps] "kernel" elf_file : ../../../build/output/bin/tinyara.axf "common" elf_file : ../../../build/output/bin/common_dbg "app1" elf_file : ../../../build/output/bin/app1_dbg "app2" elf_file : ../../../build/output/bin/app2_dbg t. Asserted TCB info: PID : 20 Name : hello CPU : 0 Priority : 100 TCB address : 0x70028490 State : Running Flags : 32 - User Task - Round Robin Lock count : 0 Timeslice : 10 Waitdog : 0 WaitSem : 0 MsgwaitQ : 0 Sigdeliver : 0 Nsyscalls : 1 Syscall 0 : up_assert
Parse the Semaphore info section of assertion logs and display
semaphore waiters, holders, counts and decoded flags.
Identify possible circular waits from recorded waiter-holder
relationships and report when missing or truncated information may
limit the analysis.
Below is os log For BK7239N:
===========================================================
Semaphore info
===========================================================
W <waiter> <sem>(<count>,<flags>) [H <holder>(<refs>)]
H <holder>(<refs>) <sem>(<count>,<flags>)
===========================================================
W 3 0x70026460(-1,6)
W 4 0x7000f320(-1,6)
W 8 0x38047724(-1,7)
W 9 0x70004c5c(-1,6)
W 17 0x704d8cf4(-1,7)
W 18 0x704da4ec(-1,7)
W 19 0x704db794(-1,7)
W 21 0x70455754(-1,2) H 22(1)
W 22 0x70455748(-1,2) H 21(1)
Below is TRAP output of Semaphore Information:
Semaphore information:
Count: negative = number of waiters; zero or positive = available count
Flags in this log:
2 = initialized
6 = initialized, signaling
7 = priority inheritance disabled, initialized, signaling
Possible circular waits:
Cycle group 1: PIDs 21, 22
PID 21 waits on 0x70455754 (count: -1, flags: 2) held by PID 22 (refs 1)
PID 22 waits on 0x70455748 (count: -1, flags: 2) held by PID 21 (refs 1)
Other semaphore relationships:
PID 3 waits on 0x70026460 (count: -1, flags: 6)
PID 4 waits on 0x7000f320 (count: -1, flags: 6)
PID 8 waits on 0x38047724 (count: -1, flags: 7)
PID 9 waits on 0x70004c5c (count: -1, flags: 6)
PID 17 waits on 0x704d8cf4 (count: -1, flags: 7)
PID 18 waits on 0x704da4ec (count: -1, flags: 7)
PID 19 waits on 0x704db794 (count: -1, flags: 7)
Warning: Some waiters have no recorded holder; circular waits may be missed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes TRAP’s asserted TCB parsing for the current log format, including flag decoding and syscall address resolution. It also adds semaphore log analysis to report waiter–holder relationships and identify possible circular waits.
I’ll address the other issues in a follow-up PR, currently working on those.
The PR is verified on rtl8730e and bk7239n.
Both below examples use the same BK7239N log.
t. Asserted TCB info:No fields printed.
t. Asserted TCB info:PID: 20Name: helloCPU: 0Priority: 100TCB address: 0x70028490State: RunningFlags: 32 - User Task - Round RobinLock count: 0Timeslice: 10Waitdog: 0WaitSem: 0MsgwaitQ: 0Sigdeliver: 0Nsyscalls: 1Syscall 0: up_assertSemaphore information:Count: negative = number of waiters; zero or positive = available countFlags: 2 = initialized; 6 = initialized, signaling; 7 = priority inheritance disabled, initialized, signalingPossible circular waits:Cycle group 1: PIDs 21, 22PID 21 waits on 0x70455754 (count: -1, flags: 2) held by PID 22 (refs 1)PID 22 waits on 0x70455748 (count: -1, flags: 2) held by PID 21 (refs 1)Other semaphore relationships:PID 3 waits on 0x70026460 (count: -1, flags: 6)PID 4 waits on 0x7000f320 (count: -1, flags: 6)PID 8 waits on 0x38047724 (count: -1, flags: 7)PID 9 waits on 0x70004c5c (count: -1, flags: 6)PID 17 waits on 0x704d8cf4 (count: -1, flags: 7)PID 18 waits on 0x704da4ec (count: -1, flags: 7)PID 19 waits on 0x704db794 (count: -1, flags: 7)Warning: Some waiters have no recorded holder; circular waits may be missed.