Skip to content

Instantly share code, notes, and snippets.

@geky
Last active October 24, 2017 21:18
Show Gist options
  • Save geky/aa1e2f015daa883190a5a782378fb665 to your computer and use it in GitHub Desktop.
Save geky/aa1e2f015daa883190a5a782378fb665 to your computer and use it in GitHub Desktop.
define rtx-threads
set $i = 0
set $tcb = (P_TCB)os_active_TCB[0]
while ($tcb)
printf "thread "
output/x $tcb
printf ":\n ptask = "
output/a $tcb->ptask
printf "\n state = "
rtx-state $tcb->state
printf " pc = "
output/a ((int*)$tcb->tsk_stack)[14]
printf "\n lr = "
output/a ((int*)$tcb->tsk_stack)[13]
printf "\n sp = "
output/a $tcb->tsk_stack
printf "\n"
set $i = $i + 1
set $tcb = (P_TCB)os_active_TCB[$i]
end
end
document rtx-threads
Prints state of all rtx threads
end
define rtx-frame
set $tcb = (P_TCB)$arg0
set $pc = ((int*)$tcb->tsk_stack)[14]
set $lr = ((int*)$tcb->tsk_stack)[13]
set $sp = ((int*)$tcb->tsk_stack) + 16
frame
end
document rtx-frame
Switch current frame to different thread
Note: current implementation is a bit destructive
and does not preserve registers
end
define rtx-tcb
print *(P_TCB)$arg0
end
document rtx-tcb
Prints tcb structure for specific thread ID
end
define rtx-state
if $arg0 == 0
echo Inactive
end
if $arg0 == 1
echo Ready
end
if $arg0 == 2
echo Running
end
if $arg0 == 3
echo WaitingDelay
end
if $arg0 == 4
echo WaitingInterval
end
if $arg0 == 5
echo WaitingOr
end
if $arg0 == 6
echo WaitingAnd
end
if $arg0 == 7
echo WaitingSemaphore
end
if $arg0 == 8
echo WaitingMailbox
end
if $arg0 == 9
echo WaitingMutex
end
echo \n
end
document rtx-state
Prints thread state in readable form
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment