2 # Assembler-level macros for i386
3 # Disassemble the next 10 instructions.
8 # Top 12 words on stack
13 # Top 12 words from frame pointer
18 # single step through calls and disassemble the next instruction
24 # single step over calls and disassemble the next instruction
30 # show current stack frame and first 4 parameters
35 output (((int)$ebp)-(int)$esp)/4-4
36 printf " words on stack)\n ebp: "
42 printf " (maximum of "
43 output ((*(int*)$ebp)-(int)$ebp)/4-4
44 printf " parameters possible)\nSaved eip: "
47 output/x (int) ($ebp+8)
49 output (char*) *(int*)($ebp+8)
51 output/x (int) ($ebp+12)
53 output (char*) *(int*)($ebp+12)
55 output/x (int) ($ebp+16)
57 output (char*) *(int*)($ebp+16)
59 output/x (int) ($ebp+20)
61 output (char*) *(int*)($ebp+20)
65 Show the register contents and the first four parameter
66 words of the current frame.
69 # show current stack frame and first 10 parameters
79 printf " (maximum of "
80 output ((*(int*)$ebp)-(int)$ebp)/4-4
81 printf " parameters possible)\nSaved eip: "
84 output/x (int) ($ebp+8)
86 output (char*) *(int*)($ebp+8)
88 output/x (int) ($ebp+12)
90 output (char*) *(int*)($ebp+12)
92 output/x (int) ($ebp+16)
94 output (char*) *(int*)($ebp+16)
96 output/x (int) ($ebp+20)
98 output (char*) *(int*)($ebp+20)
100 output/x (int) ($ebp+24)
102 output (char*) *(int*)($ebp+24)
103 printf "\nParm 6 at "
104 output/x (int) ($ebp+28)
106 output (char*) *(int*)($ebp+28)
107 printf "\nParm 7 at "
108 output/x (int) ($ebp+32)
110 output (char*) *(int*)($ebp+32)
111 printf "\nParm 8 at "
112 output/x (int) ($ebp+36)
114 output (char*) *(int*)($ebp+36)
115 printf "\nParm 9 at "
116 output/x (int) ($ebp+40)
118 output (char*) *(int*)($ebp+40)
119 printf "\nParm 10 at "
120 output/x (int) ($ebp+44)
122 output (char*) *(int*)($ebp+44)
126 Show the register contents and the first ten parameter
127 words of the current frame.
130 # Show first to fifth parameters of current frame as int, int * and char *.
137 x/12x *(int*)($ebp+4)
142 x/12x *(int*)($ebp+8)
147 x/12x *(int*)($ebp+12)
152 x/12x *(int*)($ebp+16)
157 Show the first parameter of current stack frame in various formats
160 Show the second parameter of current stack frame in various formats
163 Show the third parameter of current stack frame in various formats
166 Show the fourth parameter of current stack frame in various formats
169 Show the fifth parameter of current stack frame in various formats
172 # Select frame 0 to 5 and show stack information.
198 Select stack frame 0 and show assembler-level details
201 Select stack frame 1 and show assembler-level details
204 Select stack frame 2 and show assembler-level details
207 Select stack frame 3 and show assembler-level details
210 Select stack frame 4 and show assembler-level details
213 Select stack frame 5 and show assembler-level details
216 Single step 1 instruction (over calls) and show next instruction.
219 Single step 1 instruction (through calls) and show next instruction.
222 List the next 10 instructions from the current IP value
225 Show the last 12 words on stack in hex
228 Show 12 words starting at current BP value in hex
232 # show contents of pcb, currently only i386.
235 set $aproc = allproc.lh_first
236 set $proc = allproc.lh_first
237 while (--$nproc >= 0)
238 set $pptr = $proc.p_pptr
239 if ($proc->p_pid == $arg0)
240 set $pcba = $proc->p_threads.tqh_first->td_pcb
241 printf "ip: %08x sp: %08x bp: %08x bx: %08x\n", $pcba->pcb_eip, $pcba->pcb_esp, $pcba->pcb_ebp, $pcba->pcb_ebx
245 set $aproc = $proc.p_list.le_next
246 if ($aproc == 0 && $nproc > 0)
247 set $aproc = zombproc
253 Show some pcb contents of process whose pid is specified.
257 # primitive backtrace. frame is a memory address.
261 while (*(int *) $frame > 0xc0000000)
262 set $myebp = *(int *) $frame
263 set $myeip = *(int *) ($frame + 4)
264 printf " frame %d at %p: ebp %8x, eip ", $fno, $frame, $myebp
271 Show a backtrace from the ebp address specified. This can be used to get a backtrace from any stack resident in memory. It's the user's responsibility to ensure that the address is meaningful.
275 # backtrace for process <pid>. Uses btr (machine dependent) to perform the backtrace.
276 # may produce nonsense.
279 set $aproc = allproc.lh_first
280 set $proc = allproc.lh_first
281 while (--$nproc >= 0)
282 if ($proc->p_pid == $arg0)
283 btr $proc->p_threads.tqh_first->td_pcb->pcb_ebp
286 set $aproc = $proc.p_list.le_next
287 if ($aproc == 0 && $nproc > 0)
288 set $aproc = zombproc
295 Show a backtrace for the process whose pid is specified as a parameter.
298 # Do backtraces for all processes in the system.
299 # Uses btr (machine dependent) to perform the backtrace.
302 set $aproc = allproc.lh_first
303 set $proc = allproc.lh_first
304 printf " pid proc uid ppid pgrp flag stat comm wchan\n"
305 while (--$nproc >= 0)
306 set $pptr = $proc.p_pptr
311 printf "%5d %08x %4d %5d %5d %06x %d %-10s ", \
312 $proc.p_pid, $aproc, \
313 $proc.p_cred->p_ruid, $pptr->p_pid, \
314 $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_stat, \
318 printf "%s ", $proc.p_wmesg
320 printf "%x", $proc.p_wchan
323 if ($proc->p_flag & 4)
324 btr $proc->p_threads.tqh_first->td_pcb->pcb_ebp
329 set $aproc = $proc.p_list.le_next
330 if ($aproc == 0 && $nproc > 0)
331 set $aproc = zombproc
337 Show backtraces for all processes in the system.
340 # Show backtrace for process selected with "defproc"
342 btr $myvectorproc->p_threads.tqh_first->td_pcb->pcb_ebp
345 Show a backtrace for the process previously selected with 'defproc'.
348 # Specific stack fram of process selected with "defproc".
352 set $frame = $myvectorproc->p_threads.tqh_first->td_pcb->pcb_ebp
353 while (($searching == 1) && (*(int *) $frame > 0xc0000000))
354 set $myebp = *(int *) $frame
355 set $myeip = *(int *) ($frame + 4)
357 printf " frame %d at %p: ebp %8x, eip ", $fno, $frame, $myebp
359 printf "Called from %8x, stack frame at %8x\n", *(int *) ($myebp+4), *(int *) $myebp
360 printf "last 20 local variables:\n"
362 printf "call parameters:\n"
371 echo frame not found\n
375 Show the frame of the stack of the process previously selected with 'defproc'.