| define tracethread |
| set $_p=allproc.lh_first |
| while ( $_p != 0 ) |
| if ($_p->p_pid == $arg0) |
| printf "process %d is %s\n", $_p->p_pid, $_p->p_comm |
| set $_thread=$_p->p_threads.tqh_first |
| set $_ebp=$_thread->td_pcb->pcb_ebp |
| set $_max=$_thread->td_kstack + ($_thread->td_kstack_pages * 4096) |
| set $_min=$_thread->td_kstack |
| while (($_ebp > $_min) && ($_ebp < $_max)) |
| x/2 $_ebp |
| set $_ebp=*$_ebp |
| end |
| set $_p=0 |
| end |
| if ($_p != 0) |
| set $_p=$_p->p_list.le_next |
| end |
| end |
| end |
| document tracethread |
| Using a process index to trace a thread |
| end |