]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | # |
2 | # Kernel gdb macros | |
3 | # | |
4 | # These gdb macros should be useful during kernel development in | |
5 | # determining what's going on in the kernel. | |
6 | # | |
7 | # All the convenience variables used by these macros begin with $kgm_ | |
8 | ||
9 | set $kgm_vers = 2 | |
10 | ||
9bccf70c A |
11 | set $kgm_dummy = &proc0 |
12 | set $kgm_dummy = &kmod | |
13 | ||
1c79356b A |
14 | echo Loading Kernel GDB Macros package. Type "help kgm" for more info.\n |
15 | ||
16 | define kgm | |
17 | printf "These are the kernel gdb macros version %d. ", $kgm_vers | |
18 | echo Type "help kgm" for more info.\n | |
19 | end | |
20 | ||
21 | document kgm | |
22 | | These are the kernel gdb macros. These gdb macros are intended to be | |
23 | | used when debugging a remote kernel via the kdp protocol. Typically, you | |
24 | | would connect to your remote target like so: | |
25 | | (gdb) target remote-kdp | |
26 | | (gdb) attach <name-of-remote-host> | |
27 | | | |
28 | | The following macros are available in this package: | |
29 | | | |
30 | | showalltasks Display a summary listing of tasks | |
31 | | showallacts Display a summary listing of all activations | |
32 | | showallstacks Display the kernel stacks for all activations | |
33 | | showallvm Display a summary listing of all the vm maps | |
34 | | showallvme Display a summary listing of all the vm map entries | |
35 | | showallipc Display a summary listing of all the ipc spaces | |
36 | | showallrights Display a summary listing of all the ipc rights | |
37 | | showallkmods Display a summary listing of all the kernel modules | |
38 | | | |
39 | | showtask Display status of the specified task | |
40 | | showtaskacts Display the status of all activations in the task | |
41 | | showtaskstacks Display all kernel stacks for all activations in the task | |
42 | | showtaskvm Display status of the specified task's vm_map | |
43 | | showtaskvme Display a summary list of the task's vm_map entries | |
44 | | showtaskipc Display status of the specified task's ipc space | |
45 | | showtaskrights Display a summary list of the task's ipc space entries | |
46 | | | |
47 | | showact Display status of the specified thread activation | |
48 | | showactstack Display the kernel stack for the specified activation | |
49 | | | |
50 | | showmap Display the status of the specified vm_map | |
51 | | showmapvme Display a summary list of the specified vm_map's entries | |
52 | | | |
53 | | showipc Display the status of the specified ipc space | |
54 | | showrights Display a summary list of all the rights in an ipc space | |
55 | | | |
56 | | showpid Display the status of the process identified by pid | |
57 | | showproc Display the status of the process identified by a proc pointer | |
58 | | | |
59 | | showkmod Display information about a kernel module | |
60 | | showkmodaddr Given an address, display the kernel module and offset | |
61 | | | |
62 | | zprint Display zone information | |
9bccf70c A |
63 | | paniclog Display the panic log information |
64 | | | |
65 | | switchtoact Switch thread context | |
66 | | switchtoctx Switch context | |
67 | | resetctx Reset context | |
1c79356b A |
68 | | |
69 | | Type "help <macro>" for more specific help on a particular macro. | |
70 | | Type "show user <macro>" to see what the macro is really doing. | |
71 | end | |
72 | ||
73 | ||
74 | define showkmodheader | |
75 | printf "kmod address size " | |
76 | printf "id refs version name\n" | |
77 | end | |
78 | ||
79 | define showkmodint | |
80 | set $kgm_kmodp = (struct kmod_info *)$arg0 | |
81 | printf "0x%08x ", $arg0 | |
82 | printf "0x%08x ", $kgm_kmodp->address | |
83 | printf "0x%08x ", $kgm_kmodp->size | |
84 | printf "%3d ", $kgm_kmodp->id | |
85 | printf "%5d ", $kgm_kmodp->reference_count | |
86 | printf "%10s ", &$kgm_kmodp->version | |
87 | printf "%s\n", &$kgm_kmodp->name | |
88 | end | |
89 | ||
90 | set $kgm_kmodmin = 0xffffffff | |
91 | set $kgm_fkmodmin = 0x00000000 | |
92 | set $kgm_kmodmax = 0x00000000 | |
93 | set $kgm_fkmodmax = 0xffffffff | |
94 | set $kgm_pkmod = 0 | |
95 | set $kgm_pkmodst = 0 | |
96 | set $kgm_pkmoden = 0 | |
97 | define showkmodaddr | |
98 | printf "0x%x" , $arg0 | |
99 | if ((unsigned int)$arg0 >= (unsigned int)$kgm_pkmodst) && ((unsigned int)$arg0 <= (unsigned int)$kgm_pkmoden) | |
100 | set $kgm_off = ((unsigned int)$arg0 - (unsigned int)$kgm_pkmodst) | |
101 | printf " <%s + 0x%x>", $kgm_pkmod->name, $kgm_off | |
102 | else | |
103 | if ((unsigned int)$arg0 <= (unsigned int)$kgm_fkmodmax) && ((unsigned int)$arg0 >= (unsigned int)$kgm_fkmodmin) | |
104 | set $kgm_kmodp = (struct kmod_info *)kmod | |
105 | while $kgm_kmodp | |
106 | set $kgm_kmod = *$kgm_kmodp | |
107 | if $kgm_kmod.address && ($kgm_kmod.address < $kgm_kmodmin) | |
108 | set $kgm_kmodmin = $kgm_kmod.address | |
109 | end | |
110 | if ($kgm_kmod.address + $kgm_kmod.size) > $kgm_kmodmax | |
111 | set $kgm_kmodmax = $kgm_kmod.address | |
112 | end | |
113 | set $kgm_off = ((unsigned int)$arg0 - (unsigned int)$kgm_kmod.address) | |
114 | if ($kgm_kmod.address <= $arg0) && ($kgm_off <= $kgm_kmod.size) | |
115 | printf " <%s + 0x%x>", $kgm_kmodp->name, $kgm_off | |
116 | set $kgm_pkmod = $kgm_kmodp | |
117 | set $kgm_pkmodst = $kgm_kmod.address | |
118 | set $kgm_pkmoden = $kgm_pkmodst + $kgm_kmod.size | |
119 | set $kgm_kmodp = 0 | |
120 | else | |
121 | set $kgm_kmodp = $kgm_kmod.next | |
122 | end | |
123 | end | |
124 | if !$kgm_pkmod | |
125 | set $kgm_fkmodmin = $kgm_kmodmin | |
126 | set $kgm_fkmodmax = $kgm_kmodmax | |
127 | end | |
128 | end | |
129 | end | |
130 | end | |
131 | document showkmodaddr | |
132 | | Given an address, print the offset and name for the kmod containing it | |
133 | | The following is the syntax: | |
134 | | (gdb) showkmodaddr <addr> | |
135 | end | |
136 | ||
137 | define showkmod | |
138 | showkmodheader | |
139 | showkmodint $arg0 | |
140 | end | |
141 | document showkmod | |
142 | | Routine to print info about a kernel module | |
143 | | The following is the syntax: | |
144 | | (gdb) showkmod <kmod> | |
145 | end | |
146 | ||
147 | define showallkmods | |
148 | showkmodheader | |
149 | set $kgm_kmodp = (struct kmod_info *)kmod | |
150 | while $kgm_kmodp | |
151 | showkmodint $kgm_kmodp | |
152 | set $kgm_kmodp = $kgm_kmodp->next | |
153 | end | |
154 | end | |
155 | document showallkmods | |
156 | | Routine to print a summary listing of all the kernel modules | |
157 | | The following is the syntax: | |
158 | | (gdb) showallkmods | |
159 | end | |
160 | ||
161 | define showactheader | |
162 | printf " activation " | |
163 | printf "thread pri state wait_queue wait_event\n" | |
164 | end | |
165 | ||
166 | ||
167 | define showactint | |
168 | printf " 0x%08x ", $arg0 | |
9bccf70c | 169 | set $kgm_actp = *(struct thread_activation *)$arg0 |
1c79356b A |
170 | if $kgm_actp.thread |
171 | set $kgm_thread = *$kgm_actp.thread | |
172 | printf "0x%08x ", $kgm_actp.thread | |
173 | printf "%3d ", $kgm_thread.sched_pri | |
174 | set $kgm_state = $kgm_thread.state | |
175 | if $kgm_state & 0x80 | |
176 | printf "I" | |
177 | end | |
178 | if $kgm_state & 0x40 | |
179 | printf "P" | |
180 | end | |
181 | if $kgm_state & 0x20 | |
182 | printf "A" | |
183 | end | |
184 | if $kgm_state & 0x10 | |
185 | printf "H" | |
186 | end | |
187 | if $kgm_state & 0x08 | |
188 | printf "U" | |
189 | end | |
190 | if $kgm_state & 0x04 | |
191 | printf "R" | |
192 | end | |
193 | if $kgm_state & 0x02 | |
194 | printf "S" | |
195 | end | |
196 | if $kgm_state & 0x01 | |
197 | printf "W\t" | |
198 | printf "0x%08x ", $kgm_thread.wait_queue | |
199 | output /a $kgm_thread.wait_event | |
200 | end | |
201 | if $arg1 != 0 | |
202 | if ($kgm_thread.kernel_stack != 0) | |
203 | if ($kgm_thread.stack_privilege != 0) | |
204 | printf "\n\t\tstack_privilege=0x%08x", $kgm_thread.stack_privilege | |
205 | end | |
206 | printf "\n\t\tkernel_stack=0x%08x", $kgm_thread.kernel_stack | |
9bccf70c | 207 | set $mysp = $kgm_actp->mact.pcb->save_r1 |
1c79356b A |
208 | set $prevsp = 0 |
209 | printf "\n\t\tstacktop=0x%08x", $mysp | |
210 | while ($mysp != 0) && (($mysp & 0xf) == 0) && ($mysp < 0xb0000000) && ($mysp > $prevsp) | |
211 | printf "\n\t\t0x%08x ", $mysp | |
212 | set $kgm_return = *($mysp + 8) | |
0b4e3aa0 | 213 | if (($kgm_return > end) && ($kgm_return < 0x40000000)) |
1c79356b A |
214 | showkmodaddr $kgm_return |
215 | else | |
216 | output /a * ($mysp + 8) | |
217 | end | |
218 | set $prevsp = $mysp | |
219 | set $mysp = * $mysp | |
220 | end | |
221 | printf "\n\t\tstackbottom=0x%08x", $prevsp | |
222 | else | |
223 | printf "\n\t\t\tcontinuation=" | |
224 | output /a $kgm_thread.continuation | |
225 | end | |
226 | printf "\n" | |
227 | else | |
228 | printf "\n" | |
229 | end | |
230 | end | |
231 | end | |
232 | ||
233 | define showact | |
234 | showactheader | |
235 | showactint $arg0 0 | |
236 | end | |
237 | document showact | |
238 | | Routine to print out the state of a specific thread activation. | |
239 | | The following is the syntax: | |
240 | | (gdb) showact <activation> | |
241 | end | |
242 | ||
243 | ||
244 | define showactstack | |
245 | showactheader | |
246 | showactint $arg0 1 | |
247 | end | |
248 | document showactstack | |
249 | | Routine to print out the stack of a specific thread activation. | |
250 | | The following is the syntax: | |
251 | | (gdb) showactstack <activation> | |
252 | end | |
253 | ||
254 | ||
255 | define showallacts | |
256 | set $kgm_head_taskp = &default_pset.tasks | |
9bccf70c | 257 | set $kgm_taskp = (struct task *)($kgm_head_taskp->next) |
1c79356b A |
258 | while $kgm_taskp != $kgm_head_taskp |
259 | showtaskheader | |
260 | showtaskint $kgm_taskp | |
261 | showactheader | |
262 | set $kgm_head_actp = &($kgm_taskp->thr_acts) | |
9bccf70c | 263 | set $kgm_actp = (struct thread_activation *)($kgm_taskp->thr_acts.next) |
1c79356b A |
264 | while $kgm_actp != $kgm_head_actp |
265 | showactint $kgm_actp 0 | |
9bccf70c | 266 | set $kgm_actp = (struct thread_activation *)($kgm_actp->thr_acts.next) |
1c79356b A |
267 | end |
268 | printf "\n" | |
9bccf70c | 269 | set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next) |
1c79356b A |
270 | end |
271 | end | |
272 | document showallacts | |
273 | | Routine to print out a summary listing of all the thread activations. | |
274 | | The following is the syntax: | |
275 | | (gdb) showallacts | |
276 | end | |
277 | ||
278 | ||
279 | define showallstacks | |
280 | set $kgm_head_taskp = &default_pset.tasks | |
9bccf70c | 281 | set $kgm_taskp = (struct task *)($kgm_head_taskp->next) |
1c79356b A |
282 | while $kgm_taskp != $kgm_head_taskp |
283 | showtaskheader | |
284 | showtaskint $kgm_taskp | |
285 | set $kgm_head_actp = &($kgm_taskp->thr_acts) | |
9bccf70c | 286 | set $kgm_actp = (struct thread_activation *)($kgm_taskp->thr_acts.next) |
1c79356b A |
287 | while $kgm_actp != $kgm_head_actp |
288 | showactheader | |
289 | showactint $kgm_actp 1 | |
9bccf70c | 290 | set $kgm_actp = (struct thread_activation *)($kgm_actp->thr_acts.next) |
1c79356b A |
291 | end |
292 | printf "\n" | |
9bccf70c | 293 | set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next) |
1c79356b A |
294 | end |
295 | end | |
296 | document showallstacks | |
297 | | Routine to print out a summary listing of all the thread kernel stacks. | |
298 | | The following is the syntax: | |
299 | | (gdb) showallstacks | |
300 | end | |
301 | ||
9bccf70c A |
302 | define showwaiterheader |
303 | printf "waiters activation " | |
304 | printf "thread pri state wait_queue wait_event\n" | |
305 | end | |
306 | ||
307 | define showwaitqwaiters | |
308 | set $kgm_w_waitqp = (struct wait_queue *)$arg0 | |
309 | set $kgm_w_linksp = &($kgm_w_waitqp->wq_queue) | |
310 | set $kgm_w_wqe = (struct wait_queue_element *)$kgm_w_linksp->next | |
311 | set $kgm_w_found = 0 | |
312 | while ( (queue_entry_t)$kgm_w_wqe != (queue_entry_t)$kgm_w_linksp) | |
313 | if ($kgm_w_wqe->wqe_type != &_wait_queue_link) | |
314 | if !$kgm_w_found | |
315 | set $kgm_w_found = 1 | |
316 | showwaiterheader | |
317 | end | |
318 | set $kgm_w_shuttle = (struct thread_shuttle *)$kgm_w_wqe | |
319 | showactint $kgm_w_shuttle->top_act 0 | |
320 | end | |
321 | set $kgm_w_wqe = (struct wait_queue_element *)$kgm_w_wqe->wqe_links.next | |
322 | end | |
323 | end | |
324 | ||
325 | define showwaitqwaitercount | |
326 | set $kgm_wc_waitqp = (struct wait_queue *)$arg0 | |
327 | set $kgm_wc_linksp = &($kgm_wc_waitqp->wq_queue) | |
328 | set $kgm_wc_wqe = (struct wait_queue_element *)$kgm_wc_linksp->next | |
329 | set $kgm_wc_count = 0 | |
330 | while ( (queue_entry_t)$kgm_wc_wqe != (queue_entry_t)$kgm_wc_linksp) | |
331 | if ($kgm_wc_wqe->wqe_type != &_wait_queue_link) | |
332 | set $kgm_wc_count = $kgm_wc_count + 1 | |
333 | end | |
334 | set $kgm_wc_wqe = (struct wait_queue_element *)$kgm_wc_wqe->wqe_links.next | |
335 | end | |
336 | printf "0x%08x ", $kgm_wc_count | |
337 | end | |
338 | ||
1c79356b | 339 | define showwaitqmembercount |
9bccf70c A |
340 | set $kgm_mc_waitqsetp = (struct wait_queue_set *)$arg0 |
341 | set $kgm_mc_setlinksp = &($kgm_mc_waitqsetp->wqs_setlinks) | |
342 | set $kgm_mc_wql = (struct wait_queue_link *)$kgm_mc_setlinksp->next | |
343 | set $kgm_mc_count = 0 | |
344 | while ( (queue_entry_t)$kgm_mc_wql != (queue_entry_t)$kgm_mc_setlinksp) | |
345 | set $kgm_mc_count = $kgm_mc_count + 1 | |
346 | set $kgm_mc_wql = (struct wait_queue_link *)$kgm_mc_wql->wql_setlinks.next | |
1c79356b | 347 | end |
9bccf70c | 348 | printf "0x%08x ", $kgm_mc_count |
1c79356b A |
349 | end |
350 | ||
351 | ||
9bccf70c A |
352 | define showwaitqmemberheader |
353 | printf "set-members wait_queue interlock " | |
354 | printf "pol type member_cnt waiter_cnt\n" | |
355 | end | |
356 | ||
1c79356b | 357 | define showwaitqmemberint |
9bccf70c A |
358 | set $kgm_m_waitqp = (struct wait_queue *)$arg0 |
359 | printf " 0x%08x ", $kgm_m_waitqp | |
360 | printf "0x%08x ", $kgm_m_waitqp->wq_interlock.lock_data | |
361 | if ($kgm_m_waitqp->wq_fifo) | |
362 | printf "Fifo " | |
1c79356b | 363 | else |
9bccf70c | 364 | printf "Prio " |
1c79356b | 365 | end |
9bccf70c A |
366 | if ($kgm_m_waitqp->wq_type == 0xf1d1) |
367 | printf "Set " | |
368 | showwaitqmembercount $kgm_m_waitqp | |
1c79356b | 369 | else |
9bccf70c | 370 | printf "Que 0x00000000 " |
1c79356b | 371 | end |
9bccf70c | 372 | showwaitqwaitercount $kgm_m_waitqp |
1c79356b A |
373 | printf "\n" |
374 | end | |
375 | ||
376 | ||
9bccf70c A |
377 | define showwaitqmemberofheader |
378 | printf "member-of wait_queue interlock " | |
379 | printf "pol type member_cnt waiter_cnt\n" | |
380 | end | |
381 | ||
382 | define showwaitqmemberof | |
383 | set $kgm_mo_waitqp = (struct wait_queue *)$arg0 | |
384 | set $kgm_mo_linksp = &($kgm_mo_waitqp->wq_queue) | |
385 | set $kgm_mo_wqe = (struct wait_queue_element *)$kgm_mo_linksp->next | |
386 | set $kgm_mo_found = 0 | |
387 | while ( (queue_entry_t)$kgm_mo_wqe != (queue_entry_t)$kgm_mo_linksp) | |
388 | if ($kgm_mo_wqe->wqe_type == &_wait_queue_link) | |
389 | if !$kgm_mo_found | |
390 | set $kgm_mo_found = 1 | |
391 | showwaitqmemberofheader | |
392 | end | |
393 | set $kgm_mo_wqlp = (struct wait_queue_link *)$kgm_mo_wqe | |
394 | set $kgm_mo_wqsetp = (struct wait_queue *)($kgm_mo_wqlp->wql_setqueue) | |
395 | showwaitqmemberint $kgm_mo_wqsetp | |
396 | end | |
397 | set $kgm_mo_wqe = (struct wait_queue_element *)$kgm_mo_wqe->wqe_links.next | |
398 | end | |
399 | end | |
400 | ||
1c79356b | 401 | define showwaitqmembers |
9bccf70c A |
402 | set $kgm_ms_waitqsetp = (struct wait_queue_set *)$arg0 |
403 | set $kgm_ms_setlinksp = &($kgm_ms_waitqsetp->wqs_setlinks) | |
404 | set $kgm_ms_wql = (struct wait_queue_link *)$kgm_ms_setlinksp->next | |
405 | set $kgm_ms_found = 0 | |
406 | while ( (queue_entry_t)$kgm_ms_wql != (queue_entry_t)$kgm_ms_setlinksp) | |
407 | set $kgm_ms_waitqp = $kgm_ms_wql->wql_element.wqe_queue | |
408 | if !$kgm_ms_found | |
1c79356b | 409 | showwaitqmemberheader |
9bccf70c | 410 | set $kgm_ms_found = 1 |
1c79356b | 411 | end |
9bccf70c A |
412 | showwaitqmemberint $kgm_ms_waitqp |
413 | set $kgm_ms_wql = (struct wait_queue_link *)$kgm_ms_wql->wql_setlinks.next | |
1c79356b A |
414 | end |
415 | end | |
416 | ||
9bccf70c A |
417 | define showwaitqheader |
418 | printf "wait_queue ref_count interlock " | |
419 | printf "pol type member_cnt waiter_cnt\n" | |
420 | end | |
421 | ||
422 | define showwaitqint | |
423 | set $kgm_waitqp = (struct wait_queue *)$arg0 | |
424 | printf "0x%08x ", $kgm_waitqp | |
425 | if ($kgm_waitqp->wq_type == 0xf1d1) | |
426 | printf "0x%08x ", ((struct wait_queue_set *)$kgm_waitqp)->wqs_refcount | |
427 | else | |
428 | printf "0x00000000 " | |
429 | end | |
430 | printf "0x%08x ", $kgm_waitqp->wq_interlock.lock_data | |
431 | if ($kgm_waitqp->wq_fifo) | |
432 | printf "Fifo " | |
433 | else | |
434 | printf "Prio " | |
435 | end | |
436 | if ($kgm_waitqp->wq_type == 0xf1d1) | |
437 | printf "Set " | |
438 | showwaitqmembercount $kgm_waitqp | |
439 | else | |
440 | printf "Que 0x00000000 " | |
441 | end | |
442 | showwaitqwaitercount $kgm_waitqp | |
443 | printf "\n" | |
444 | end | |
445 | ||
1c79356b | 446 | define showwaitq |
9bccf70c | 447 | set $kgm_waitq1p = (wait_queue_t)$arg0 |
1c79356b | 448 | showwaitqheader |
9bccf70c A |
449 | showwaitqint $kgm_waitq1p |
450 | if ($kgm_waitq1p->wq_type == 0xf1d1) | |
451 | showwaitqmembers $kgm_waitq1p | |
452 | else | |
453 | showwaitqmemberof $kgm_waitq1p | |
1c79356b | 454 | end |
9bccf70c | 455 | showwaitqwaiters $kgm_waitq1p |
1c79356b A |
456 | end |
457 | ||
458 | define showmapheader | |
459 | printf "vm_map pmap vm_size " | |
460 | printf "#ents rpage hint first_free\n" | |
461 | end | |
462 | ||
463 | define showvmeheader | |
464 | printf " entry start " | |
465 | printf "prot #page object offset\n" | |
466 | end | |
467 | ||
468 | define showvmint | |
469 | set $kgm_mapp = (vm_map_t)$arg0 | |
470 | set $kgm_map = *$kgm_mapp | |
471 | printf "0x%08x ", $arg0 | |
472 | printf "0x%08x ", $kgm_map.pmap | |
473 | printf "0x%08x ", $kgm_map.size | |
474 | printf "%3d ", $kgm_map.hdr.nentries | |
475 | printf "%5d ", $kgm_map.pmap->stats.resident_count | |
476 | printf "0x%08x ", $kgm_map.hint | |
477 | printf "0x%08x\n", $kgm_map.first_free | |
478 | if $arg1 != 0 | |
479 | showvmeheader | |
480 | set $kgm_head_vmep = &($kgm_mapp->hdr.links) | |
481 | set $kgm_vmep = $kgm_map.hdr.links.next | |
482 | while (($kgm_vmep != 0) && ($kgm_vmep != $kgm_head_vmep)) | |
483 | set $kgm_vme = *$kgm_vmep | |
484 | printf " 0x%08x ", $kgm_vmep | |
485 | printf "0x%08x ", $kgm_vme.links.start | |
486 | printf "%1x", $kgm_vme.protection | |
487 | printf "%1x", $kgm_vme.max_protection | |
488 | if $kgm_vme.inheritance == 0x0 | |
489 | printf "S" | |
490 | end | |
491 | if $kgm_vme.inheritance == 0x1 | |
492 | printf "C" | |
493 | end | |
494 | if $kgm_vme.inheritance == 0x2 | |
495 | printf "-" | |
496 | end | |
497 | if $kgm_vme.inheritance == 0x3 | |
498 | printf "D" | |
499 | end | |
500 | if $kgm_vme.is_sub_map | |
501 | printf "s " | |
502 | else | |
503 | if $kgm_vme.needs_copy | |
504 | printf "n " | |
505 | else | |
506 | printf " " | |
507 | end | |
508 | end | |
509 | printf "%5d ",($kgm_vme.links.end - $kgm_vme.links.start) >> 12 | |
510 | printf "0x%08x ", $kgm_vme.object.vm_object | |
511 | printf "0x%08x\n", $kgm_vme.offset | |
512 | set $kgm_vmep = $kgm_vme.links.next | |
513 | end | |
514 | end | |
515 | printf "\n" | |
516 | end | |
517 | ||
518 | ||
519 | define showmapvme | |
520 | showmapheader | |
521 | showvmint $arg0 1 | |
522 | end | |
523 | document showmapvme | |
524 | | Routine to print out a summary listing of all the entries in a vm_map | |
525 | | The following is the syntax: | |
526 | | (gdb) showmapvme <vm_map> | |
527 | end | |
528 | ||
529 | ||
530 | define showmap | |
531 | showmapheader | |
532 | showvmint $arg0 0 | |
533 | end | |
534 | document showmap | |
535 | | Routine to print out a summary description of a vm_map | |
536 | | The following is the syntax: | |
537 | | (gdb) showmap <vm_map> | |
538 | end | |
539 | ||
540 | define showallvm | |
541 | set $kgm_head_taskp = &default_pset.tasks | |
9bccf70c | 542 | set $kgm_taskp = (struct task *)($kgm_head_taskp->next) |
1c79356b A |
543 | while $kgm_taskp != $kgm_head_taskp |
544 | showtaskheader | |
545 | showmapheader | |
546 | showtaskint $kgm_taskp | |
547 | showvmint $kgm_taskp->map 0 | |
9bccf70c | 548 | set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next) |
1c79356b A |
549 | end |
550 | end | |
551 | document showallvm | |
552 | | Routine to print a summary listing of all the vm maps | |
553 | | The following is the syntax: | |
554 | | (gdb) showallvm | |
555 | end | |
556 | ||
557 | ||
558 | define showallvme | |
559 | set $kgm_head_taskp = &default_pset.tasks | |
9bccf70c | 560 | set $kgm_taskp = (struct task *)($kgm_head_taskp->next) |
1c79356b A |
561 | while $kgm_taskp != $kgm_head_taskp |
562 | showtaskheader | |
563 | showmapheader | |
564 | showtaskint $kgm_taskp | |
565 | showvmint $kgm_taskp->map 1 | |
9bccf70c | 566 | set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next) |
1c79356b A |
567 | end |
568 | end | |
569 | document showallvme | |
570 | | Routine to print a summary listing of all the vm map entries | |
571 | | The following is the syntax: | |
572 | | (gdb) showallvme | |
573 | end | |
574 | ||
575 | ||
576 | define showipcheader | |
577 | printf "ipc_space is_table table_next " | |
578 | printf "flags tsize splaytree splaybase\n" | |
579 | end | |
580 | ||
581 | define showipceheader | |
582 | printf " name object " | |
583 | printf "rite urefs destname destination\n" | |
584 | end | |
585 | ||
586 | define showipceint | |
587 | set $kgm_ie = *(ipc_entry_t)$arg0 | |
588 | printf " 0x%08x ", $arg1 | |
589 | printf "0x%08x ", $kgm_ie.ie_object | |
590 | if $kgm_ie.ie_bits & 0x00100000 | |
591 | printf "Dead " | |
592 | printf "%5d\n", $kgm_ie.ie_bits & 0xffff | |
593 | else | |
594 | if $kgm_ie.ie_bits & 0x00080000 | |
595 | printf "SET " | |
596 | printf "%5d\n", $kgm_ie.ie_bits & 0xffff | |
597 | else | |
598 | if $kgm_ie.ie_bits & 0x00010000 | |
599 | if $kgm_ie.ie_bits & 0x00020000 | |
600 | printf " SR" | |
601 | else | |
602 | printf " S" | |
603 | end | |
604 | else | |
605 | if $kgm_ie.ie_bits & 0x00020000 | |
606 | printf " R" | |
607 | end | |
608 | end | |
609 | if $kgm_ie.ie_bits & 0x00040000 | |
610 | printf " O" | |
611 | end | |
612 | if $kgm_ie.index.request | |
613 | printf "n" | |
614 | else | |
615 | printf " " | |
616 | end | |
617 | if $kgm_ie.ie_bits & 0x00800000 | |
618 | printf "c" | |
619 | else | |
620 | printf " " | |
621 | end | |
622 | printf "%5d ", $kgm_ie.ie_bits & 0xffff | |
623 | showportdest $kgm_ie.ie_object | |
624 | end | |
625 | end | |
626 | end | |
627 | ||
628 | define showipcint | |
629 | set $kgm_isp = (ipc_space_t)$arg0 | |
630 | set $kgm_is = *$kgm_isp | |
631 | printf "0x%08x ", $arg0 | |
632 | printf "0x%08x ", $kgm_is.is_table | |
633 | printf "0x%08x ", $kgm_is.is_table_next | |
634 | if $kgm_is.is_growing != 0 | |
635 | printf "G" | |
636 | else | |
637 | printf " " | |
638 | end | |
639 | if $kgm_is.is_fast != 0 | |
640 | printf "F" | |
641 | else | |
642 | printf " " | |
643 | end | |
644 | if $kgm_is.is_active != 0 | |
645 | printf "A " | |
646 | else | |
647 | printf " " | |
648 | end | |
649 | printf "%5d ", $kgm_is.is_table_size | |
650 | printf "0x%08x ", $kgm_is.is_tree_total | |
651 | printf "0x%08x\n", &$kgm_isp->is_tree | |
652 | if $arg1 != 0 | |
653 | showipceheader | |
654 | set $kgm_iindex = 0 | |
655 | set $kgm_iep = $kgm_is.is_table | |
656 | set $kgm_destspacep = (ipc_space_t)0 | |
657 | while ( $kgm_iindex < $kgm_is.is_table_size ) | |
658 | set $kgm_ie = *$kgm_iep | |
659 | if $kgm_ie.ie_bits & 0x001f0000 | |
660 | set $kgm_name = (($kgm_iindex << 8)|($kgm_ie.ie_bits >> 24)) | |
661 | showipceint $kgm_iep $kgm_name | |
662 | end | |
663 | set $kgm_iindex = $kgm_iindex + 1 | |
664 | set $kgm_iep = &($kgm_is.is_table[$kgm_iindex]) | |
665 | end | |
666 | if $kgm_is.is_tree_total | |
667 | printf "Still need to write tree traversal\n" | |
668 | end | |
669 | end | |
670 | printf "\n" | |
671 | end | |
672 | ||
673 | ||
674 | define showipc | |
675 | set $kgm_isp = (ipc_space_t)$arg0 | |
676 | showipcheader | |
677 | showipcint $kgm_isp 0 | |
678 | end | |
679 | document showipc | |
680 | | Routine to print the status of the specified ipc space | |
681 | | The following is the syntax: | |
682 | | (gdb) showipc <ipc_space> | |
683 | end | |
684 | ||
685 | define showrights | |
686 | set $kgm_isp = (ipc_space_t)$arg0 | |
687 | showipcheader | |
688 | showipcint $kgm_isp 1 | |
689 | end | |
690 | document showrights | |
691 | | Routine to print a summary list of all the rights in a specified ipc space | |
692 | | The following is the syntax: | |
693 | | (gdb) showrights <ipc_space> | |
694 | end | |
695 | ||
696 | ||
697 | define showtaskipc | |
698 | set $kgm_taskp = (task_t)$arg0 | |
699 | showtaskheader | |
700 | showipcheader | |
701 | showtaskint $kgm_taskp | |
702 | showipcint $kgm_taskp->itk_space 0 | |
703 | end | |
704 | document showtaskipc | |
705 | | Routine to print the status of the ipc space for a task | |
706 | | The following is the syntax: | |
707 | | (gdb) showtaskipc <task> | |
708 | end | |
709 | ||
710 | ||
711 | define showtaskrights | |
712 | set $kgm_taskp = (task_t)$arg0 | |
713 | showtaskheader | |
714 | showipcheader | |
715 | showtaskint $kgm_taskp | |
716 | showipcint $kgm_taskp->itk_space 1 | |
717 | end | |
718 | document showtaskrights | |
719 | | Routine to print a summary listing of all the ipc rights for a task | |
720 | | The following is the syntax: | |
721 | | (gdb) showtaskrights <task> | |
722 | end | |
723 | ||
724 | define showallipc | |
725 | set $kgm_head_taskp = &default_pset.tasks | |
9bccf70c | 726 | set $kgm_taskp = (struct task *)($kgm_head_taskp->next) |
1c79356b A |
727 | while $kgm_taskp != $kgm_head_taskp |
728 | showtaskheader | |
729 | showipcheader | |
730 | showtaskint $kgm_taskp | |
731 | showipcint $kgm_taskp->itk_space 0 | |
9bccf70c | 732 | set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next) |
1c79356b A |
733 | end |
734 | end | |
735 | document showallipc | |
736 | | Routine to print a summary listing of all the ipc spaces | |
737 | | The following is the syntax: | |
738 | | (gdb) showallipc | |
739 | end | |
740 | ||
741 | ||
742 | define showallrights | |
743 | set $kgm_head_taskp = &default_pset.tasks | |
9bccf70c | 744 | set $kgm_taskp = (struct task *)($kgm_head_taskp->next) |
1c79356b A |
745 | while $kgm_taskp != $kgm_head_taskp |
746 | showtaskheader | |
747 | showipcheader | |
748 | showtaskint $kgm_taskp | |
749 | showipcint $kgm_taskp->itk_space 1 | |
9bccf70c | 750 | set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next) |
1c79356b A |
751 | end |
752 | end | |
753 | document showallrights | |
754 | | Routine to print a summary listing of all the ipc rights | |
755 | | The following is the syntax: | |
756 | | (gdb) showallrights | |
757 | end | |
758 | ||
759 | ||
760 | define showtaskvm | |
761 | set $kgm_taskp = (task_t)$arg0 | |
762 | showtaskheader | |
763 | showmapheader | |
764 | showtaskint $kgm_taskp | |
765 | showvmint $kgm_taskp->map 0 | |
766 | end | |
767 | document showtaskvm | |
768 | | Routine to print out a summary description of a task's vm_map | |
769 | | The following is the syntax: | |
770 | | (gdb) showtaskvm <task> | |
771 | end | |
772 | ||
773 | define showtaskvme | |
774 | set $kgm_taskp = (task_t)$arg0 | |
775 | showtaskheader | |
776 | showmapheader | |
777 | showtaskint $kgm_taskp | |
778 | showvmint $kgm_taskp->map 1 | |
779 | end | |
780 | document showtaskvme | |
781 | | Routine to print out a summary listing of a task's vm_map_entries | |
782 | | The following is the syntax: | |
783 | | (gdb) showtaskvme <task> | |
784 | end | |
785 | ||
786 | ||
787 | define showtaskheader | |
788 | printf "task vm_map ipc_space #acts " | |
789 | showprocheader | |
790 | end | |
791 | ||
792 | ||
793 | define showtaskint | |
9bccf70c | 794 | set $kgm_task = *(struct task *)$arg0 |
1c79356b A |
795 | printf "0x%08x ", $arg0 |
796 | printf "0x%08x ", $kgm_task.map | |
797 | printf "0x%08x ", $kgm_task.itk_space | |
798 | printf "%3d ", $kgm_task.thr_act_count | |
799 | showprocint $kgm_task.bsd_info | |
800 | end | |
801 | ||
802 | define showtask | |
803 | showtaskheader | |
804 | showtaskint $arg0 | |
805 | end | |
806 | document showtask | |
807 | | Routine to print out info about a task. | |
808 | | The following is the syntax: | |
809 | | (gdb) showtask <task> | |
810 | end | |
811 | ||
812 | ||
813 | define showtaskacts | |
814 | showtaskheader | |
9bccf70c | 815 | set $kgm_taskp = (struct task *)$arg0 |
1c79356b A |
816 | showtaskint $kgm_taskp |
817 | showactheader | |
818 | set $kgm_head_actp = &($kgm_taskp->thr_acts) | |
9bccf70c | 819 | set $kgm_actp = (struct thread_activation *)($kgm_taskp->thr_acts.next) |
1c79356b A |
820 | while $kgm_actp != $kgm_head_actp |
821 | showactint $kgm_actp 0 | |
9bccf70c | 822 | set $kgm_actp = (struct thread_activation *)($kgm_actp->thr_acts.next) |
1c79356b A |
823 | end |
824 | end | |
825 | document showtaskacts | |
826 | | Routine to print a summary listing of the activations in a task | |
827 | | The following is the syntax: | |
828 | | (gdb) showtaskacts <task> | |
829 | end | |
830 | ||
831 | ||
832 | define showtaskstacks | |
833 | showtaskheader | |
9bccf70c | 834 | set $kgm_taskp = (struct task *)$arg0 |
1c79356b A |
835 | showtaskint $kgm_taskp |
836 | set $kgm_head_actp = &($kgm_taskp->thr_acts) | |
9bccf70c | 837 | set $kgm_actp = (struct thread_activation *)($kgm_taskp->thr_acts.next) |
1c79356b A |
838 | while $kgm_actp != $kgm_head_actp |
839 | showactheader | |
840 | showactint $kgm_actp 1 | |
9bccf70c | 841 | set $kgm_actp = (struct thread_activation *)($kgm_actp->thr_acts.next) |
1c79356b A |
842 | end |
843 | end | |
844 | document showtaskstacks | |
845 | | Routine to print a summary listing of the activations in a task and their stacks | |
846 | | The following is the syntax: | |
847 | | (gdb) showtaskstacks <task> | |
848 | end | |
849 | ||
850 | ||
851 | define showalltasks | |
852 | showtaskheader | |
853 | set $kgm_head_taskp = &default_pset.tasks | |
9bccf70c | 854 | set $kgm_taskp = (struct task *)($kgm_head_taskp->next) |
1c79356b A |
855 | while $kgm_taskp != $kgm_head_taskp |
856 | showtaskint $kgm_taskp | |
9bccf70c | 857 | set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next) |
1c79356b A |
858 | end |
859 | end | |
860 | document showalltasks | |
861 | | Routine to print a summary listing of all the tasks | |
862 | | The following is the syntax: | |
863 | | (gdb) showalltasks | |
864 | end | |
865 | ||
866 | ||
867 | define showprocheader | |
868 | printf " pid proc command\n" | |
869 | end | |
870 | ||
871 | define showprocint | |
872 | set $kgm_procp = (struct proc *)$arg0 | |
873 | if $kgm_procp != 0 | |
874 | printf "%5d ", $kgm_procp->p_pid | |
875 | printf "0x%08x ", $kgm_procp | |
876 | printf "%s\n", $kgm_procp->p_comm | |
877 | else | |
878 | printf " *0* 0x00000000 --\n" | |
879 | end | |
880 | end | |
881 | ||
882 | define showpid | |
883 | showtaskheader | |
884 | set $kgm_head_taskp = &default_pset.tasks | |
9bccf70c | 885 | set $kgm_taskp = (struct task *)($kgm_head_taskp->next) |
1c79356b A |
886 | while $kgm_taskp != $kgm_head_taskp |
887 | set $kgm_procp = (struct proc *)$kgm_taskp->bsd_info | |
888 | if (($kgm_procp != 0) && ($kgm_procp->p_pid == $arg0)) | |
889 | showtaskint $kgm_taskp | |
890 | set $kgm_taskp = $kgm_head_taskp | |
891 | else | |
9bccf70c | 892 | set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next) |
1c79356b A |
893 | end |
894 | end | |
895 | end | |
896 | document showpid | |
897 | | Routine to print a single process by pid | |
898 | | The following is the syntax: | |
899 | | (gdb) showpid <pid> | |
900 | end | |
901 | ||
902 | define showproc | |
903 | showtaskheader | |
904 | set $kgm_procp = (struct proc *)$arg0 | |
905 | showtaskint $kgm_procp->task $arg1 $arg2 | |
906 | end | |
907 | ||
908 | ||
909 | define kdb | |
910 | set switch_debugger=1 | |
911 | continue | |
912 | end | |
913 | document kdb | |
914 | | kdb - Switch to the inline kernel debugger | |
915 | | | |
916 | | usage: kdb | |
917 | | | |
918 | | The kdb macro allows you to invoke the inline kernel debugger. | |
919 | end | |
920 | ||
921 | define showpsetheader | |
922 | printf "portset waitqueue recvname " | |
923 | printf "flags refs recvname process\n" | |
924 | end | |
925 | ||
926 | define showportheader | |
927 | printf "port mqueue recvname " | |
928 | printf "flags refs recvname process\n" | |
929 | end | |
930 | ||
931 | define showportmemberheader | |
9bccf70c | 932 | printf "members port recvname " |
1c79356b A |
933 | printf "flags refs mqueue msgcount\n" |
934 | end | |
935 | ||
936 | define showkmsgheader | |
9bccf70c | 937 | printf "messages kmsg size " |
1c79356b A |
938 | printf "disp msgid remote-port local-port\n" |
939 | end | |
940 | ||
941 | define showkmsgint | |
942 | printf " 0x%08x ", $arg0 | |
943 | set $kgm_kmsgh = ((ipc_kmsg_t)$arg0)->ikm_header | |
944 | printf "0x%08x ", $kgm_kmsgh.msgh_size | |
945 | if (($kgm_kmsgh.msgh_bits & 0xff) == 19) | |
946 | printf "rC" | |
947 | else | |
948 | printf "rM" | |
949 | end | |
950 | if (($kgm_kmsgh.msgh_bits & 0xff00) == (19 < 8)) | |
951 | printf "lC" | |
952 | else | |
953 | printf "lM" | |
954 | end | |
955 | if ($kgm_kmsgh.msgh_bits & 0xf0000000) | |
956 | printf "c" | |
957 | else | |
958 | printf "s" | |
959 | end | |
9bccf70c | 960 | printf "%5d ", $kgm_kmsgh.msgh_id |
1c79356b A |
961 | printf "0x%08x ", $kgm_kmsgh.msgh_remote_port |
962 | printf "0x%08x\n", $kgm_kmsgh.msgh_local_port | |
963 | end | |
964 | ||
965 | ||
966 | ||
967 | define showkobject | |
9bccf70c | 968 | set $kgm_portp = (struct ipc_port *)$arg0 |
1c79356b A |
969 | printf "0x%08x kobject(", $kgm_portp->ip_kobject |
970 | set $kgm_kotype = ($kgm_portp->ip_object.io_bits & 0x00000fff) | |
971 | if ($kgm_kotype == 1) | |
972 | printf "THREAD" | |
973 | end | |
974 | if ($kgm_kotype == 2) | |
975 | printf "TASK" | |
976 | end | |
977 | if ($kgm_kotype == 3) | |
978 | printf "HOST" | |
979 | end | |
980 | if ($kgm_kotype == 4) | |
981 | printf "HOST_PRIV" | |
982 | end | |
983 | if ($kgm_kotype == 5) | |
984 | printf "PROCESSOR" | |
985 | end | |
986 | if ($kgm_kotype == 6) | |
987 | printf "PSET" | |
988 | end | |
989 | if ($kgm_kotype == 7) | |
990 | printf "PSET_NAME" | |
991 | end | |
992 | if ($kgm_kotype == 8) | |
993 | printf "TIMER" | |
994 | end | |
995 | if ($kgm_kotype == 9) | |
996 | printf "PAGER_REQ" | |
997 | end | |
998 | if ($kgm_kotype == 10) | |
999 | printf "DEVICE" | |
1000 | end | |
1001 | if ($kgm_kotype == 11) | |
1002 | printf "XMM_OBJECT" | |
1003 | end | |
1004 | if ($kgm_kotype == 12) | |
1005 | printf "XMM_PAGER" | |
1006 | end | |
1007 | if ($kgm_kotype == 13) | |
1008 | printf "XMM_KERNEL" | |
1009 | end | |
1010 | if ($kgm_kotype == 14) | |
1011 | printf "XMM_REPLY" | |
1012 | end | |
1013 | if ($kgm_kotype == 15) | |
1014 | printf "NOTDEF 15" | |
1015 | end | |
1016 | if ($kgm_kotype == 16) | |
1017 | printf "NOTDEF 16" | |
1018 | end | |
1019 | if ($kgm_kotype == 17) | |
1020 | printf "HOST_SEC" | |
1021 | end | |
1022 | if ($kgm_kotype == 18) | |
1023 | printf "LEDGER" | |
1024 | end | |
1025 | if ($kgm_kotype == 19) | |
1026 | printf "MASTER_DEV" | |
1027 | end | |
1028 | if ($kgm_kotype == 20) | |
1029 | printf "ACTIVATION" | |
1030 | end | |
1031 | if ($kgm_kotype == 21) | |
1032 | printf "SUBSYSTEM" | |
1033 | end | |
1034 | if ($kgm_kotype == 22) | |
1035 | printf "IO_DONE_QUE" | |
1036 | end | |
1037 | if ($kgm_kotype == 23) | |
1038 | printf "SEMAPHORE" | |
1039 | end | |
1040 | if ($kgm_kotype == 24) | |
1041 | printf "LOCK_SET" | |
1042 | end | |
1043 | if ($kgm_kotype == 25) | |
1044 | printf "CLOCK" | |
1045 | end | |
1046 | if ($kgm_kotype == 26) | |
1047 | printf "CLOCK_CTRL" | |
1048 | end | |
1049 | if ($kgm_kotype == 27) | |
1050 | printf "IOKIT_SPARE" | |
1051 | end | |
1052 | if ($kgm_kotype == 28) | |
1053 | printf "NAMED_MEM" | |
1054 | end | |
1055 | if ($kgm_kotype == 29) | |
1056 | printf "IOKIT_CON" | |
1057 | end | |
1058 | if ($kgm_kotype == 30) | |
1059 | printf "IOKIT_OBJ" | |
1060 | end | |
1061 | if ($kgm_kotype == 31) | |
1062 | printf "UPL" | |
1063 | end | |
1064 | printf ")\n" | |
1065 | end | |
1066 | ||
1067 | define showportdestproc | |
9bccf70c | 1068 | set $kgm_portp = (struct ipc_port *)$arg0 |
1c79356b A |
1069 | set $kgm_spacep = $kgm_portp->data.receiver |
1070 | # check against the previous cached value - this is slow | |
1071 | if ($kgm_spacep != $kgm_destspacep) | |
1072 | set $kgm_destprocp = (struct proc *)0 | |
1073 | set $kgm_head_taskp = &default_pset.tasks | |
9bccf70c | 1074 | set $kgm_taskp = (struct task *)($kgm_head_taskp->next) |
1c79356b A |
1075 | while (($kgm_destprocp == 0) && ($kgm_taskp != $kgm_head_taskp)) |
1076 | set $kgm_destspacep = $kgm_taskp->itk_space | |
1077 | if ($kgm_destspacep == $kgm_spacep) | |
1078 | set $kgm_destprocp = (struct proc *)$kgm_taskp->bsd_info | |
1079 | else | |
9bccf70c | 1080 | set $kgm_taskp = (struct task *)($kgm_taskp->pset_tasks.next) |
1c79356b A |
1081 | end |
1082 | end | |
1083 | end | |
1084 | if $kgm_destprocp != 0 | |
1085 | printf "%s(%d)\n", $kgm_destprocp->p_comm, $kgm_destprocp->p_pid | |
1086 | else | |
1087 | printf "task 0x%08x\n", $kgm_taskp | |
1088 | end | |
1089 | end | |
1090 | ||
1091 | define showportdest | |
9bccf70c | 1092 | set $kgm_portp = (struct ipc_port *)$arg0 |
1c79356b A |
1093 | set $kgm_spacep = $kgm_portp->data.receiver |
1094 | if ($kgm_spacep == ipc_space_kernel) | |
1095 | showkobject $kgm_portp | |
1096 | else | |
1097 | if ($kgm_portp->ip_object.io_bits & 0x80000000) | |
1098 | printf "0x%08x ", $kgm_portp->ip_object.io_receiver_name | |
1099 | showportdestproc $kgm_portp | |
1100 | else | |
1101 | printf "0x%08x inactive-port\n", $kgm_portp | |
1102 | end | |
1103 | end | |
1104 | end | |
1105 | ||
1106 | define showportmember | |
1107 | printf " 0x%08x ", $arg0 | |
9bccf70c | 1108 | set $kgm_portp = (struct ipc_port *)$arg0 |
1c79356b A |
1109 | printf "0x%08x ", $kgm_portp->ip_object.io_receiver_name |
1110 | if ($kgm_portp->ip_object.io_bits & 0x80000000) | |
1111 | printf "A" | |
1112 | else | |
1113 | printf " " | |
1114 | end | |
1115 | if ($kgm_portp->ip_object.io_bits & 0x7fff0000) | |
1116 | printf "Set " | |
1117 | else | |
1118 | printf "Port" | |
1119 | end | |
1120 | printf "%5d ", $kgm_portp->ip_object.io_references | |
1121 | printf "0x%08x ", &($kgm_portp->ip_messages) | |
1122 | printf "0x%08x\n", $kgm_portp->ip_messages.data.port.msgcount | |
1123 | end | |
1124 | ||
1125 | define showportint | |
1126 | printf "0x%08x ", $arg0 | |
9bccf70c | 1127 | set $kgm_portp = (struct ipc_port *)$arg0 |
1c79356b A |
1128 | printf "0x%08x ", &($kgm_portp->ip_messages) |
1129 | printf "0x%08x ", $kgm_portp->ip_object.io_receiver_name | |
1130 | if ($kgm_portp->ip_object.io_bits & 0x80000000) | |
1131 | printf "A" | |
1132 | else | |
1133 | printf "D" | |
1134 | end | |
1135 | printf "Port" | |
1136 | printf "%5d ", $kgm_portp->ip_object.io_references | |
9bccf70c | 1137 | set $kgm_destspacep = (struct ipc_space *)0 |
1c79356b A |
1138 | showportdest $kgm_portp |
1139 | set $kgm_kmsgp = (ipc_kmsg_t)$kgm_portp->ip_messages.data.port.messages.ikmq_base | |
1140 | if $arg1 && $kgm_kmsgp | |
1141 | showkmsgheader | |
1142 | showkmsgint $kgm_kmsgp | |
1143 | set $kgm_kmsgheadp = $kgm_kmsgp | |
1144 | set $kgm_kmsgp = $kgm_kmsgp->ikm_next | |
1145 | while $kgm_kmsgp != $kgm_kmsgheadp | |
1146 | showkmsgint $kgm_kmsgp | |
1147 | set $kgm_kmsgp = $kgm_kmsgp->ikm_next | |
1148 | end | |
1149 | end | |
1150 | end | |
1151 | ||
1152 | define showpsetint | |
1153 | printf "0x%08x ", $arg0 | |
9bccf70c | 1154 | set $kgm_psetp = (struct ipc_pset *)$arg0 |
1c79356b A |
1155 | printf "0x%08x ", &($kgm_psetp->ips_messages) |
1156 | printf "0x%08x ", $kgm_psetp->ips_object.io_receiver_name | |
1157 | if ($kgm_psetp->ips_object.io_bits & 0x80000000) | |
1158 | printf "A" | |
1159 | else | |
1160 | printf "D" | |
1161 | end | |
1162 | printf "Set " | |
1163 | printf "%5d ", $kgm_psetp->ips_object.io_references | |
9bccf70c A |
1164 | printf "0x%08x ", $kgm_psetp->ips_object.io_receiver_name |
1165 | set $kgm_setlinksp = &($kgm_psetp->ips_messages.data.set_queue.wqs_setlinks) | |
1166 | set $kgm_wql = (struct wait_queue_link *)$kgm_setlinksp->next | |
1c79356b | 1167 | set $kgm_found = 0 |
9bccf70c A |
1168 | while ( (queue_entry_t)$kgm_wql != (queue_entry_t)$kgm_setlinksp) |
1169 | set $kgm_portp = (struct ipc_port *)((int)($kgm_wql->wql_element->wqe_queue) - ((int)$kgm_portoff)) | |
1c79356b | 1170 | if !$kgm_found |
9bccf70c A |
1171 | set $kgm_destspacep = (struct ipc_space *)0 |
1172 | showportdestproc $kgm_portp | |
1c79356b A |
1173 | showportmemberheader |
1174 | set $kgm_found = 1 | |
1175 | end | |
1176 | showportmember $kgm_portp 0 | |
9bccf70c | 1177 | set $kgm_wql = (struct wait_queue_link *)$kgm_wql->wql_setlinks.next |
1c79356b | 1178 | end |
9bccf70c A |
1179 | if !$kgm_found |
1180 | printf "--n/e--\n" | |
1c79356b A |
1181 | end |
1182 | end | |
1183 | ||
1184 | define showpset | |
1185 | showpsetheader | |
1186 | showpsetint $arg0 1 | |
1187 | end | |
1188 | ||
1189 | define showport | |
1190 | showportheader | |
1191 | showportint $arg0 1 | |
1192 | end | |
1193 | ||
1194 | define showipcobject | |
1195 | set $kgm_object = (ipc_object_t)$arg0 | |
1196 | if ($kgm_objectp->io_bits & 0x7fff0000) | |
1197 | showpset $kgm_objectp | |
1198 | else | |
1199 | showport $kgm_objectp | |
1200 | end | |
1201 | end | |
1202 | ||
1203 | define showmqueue | |
9bccf70c A |
1204 | set $kgm_mqueue = *(struct ipc_mqueue *)$arg0 |
1205 | set $kgm_psetoff = &(((struct ipc_pset *)0)->ips_messages) | |
1206 | set $kgm_portoff = &(((struct ipc_port *)0)->ip_messages) | |
1207 | if ($kgm_mqueue.data.set_queue.wqs_wait_queue.wq_type == 0xf1d1) | |
1c79356b A |
1208 | set $kgm_pset = (((int)$arg0) - ((int)$kgm_psetoff)) |
1209 | showpsetheader | |
1210 | showpsetint $kgm_pset 1 | |
9bccf70c A |
1211 | end |
1212 | if ($kgm_mqueue.data.set_queue.wqs_wait_queue.wq_type == 0xf1d0) | |
1c79356b A |
1213 | showportheader |
1214 | set $kgm_port = (((int)$arg0) - ((int)$kgm_portoff)) | |
1215 | showportint $kgm_port 1 | |
1216 | end | |
1217 | end | |
1218 | ||
1219 | define zprint_one | |
1220 | set $kgm_zone = (struct zone *)$arg0 | |
1221 | ||
1222 | printf "0x%08x ", $kgm_zone | |
1223 | printf "%8d ",$kgm_zone->count | |
1224 | printf "%8x ",$kgm_zone->cur_size | |
1225 | printf "%8x ",$kgm_zone->max_size | |
1226 | printf "%6d ",$kgm_zone->elem_size | |
1227 | printf "%8x ",$kgm_zone->alloc_size | |
1228 | printf "%s ",$kgm_zone->zone_name | |
1229 | ||
1230 | if ($kgm_zone->exhaustible) | |
1231 | printf "H" | |
1232 | end | |
1233 | if ($kgm_zone->collectable) | |
1234 | printf "C" | |
1235 | end | |
1236 | if ($kgm_zone->expandable) | |
1237 | printf "X" | |
1238 | end | |
1239 | printf "\n" | |
1240 | end | |
1241 | ||
1242 | ||
1243 | define zprint | |
1244 | printf "ZONE COUNT TOT_SZ MAX_SZ ELT_SZ ALLOC_SZ NAME\n" | |
1245 | set $kgm_zone_ptr = (struct zone *)first_zone | |
1246 | while ($kgm_zone_ptr != 0) | |
1247 | zprint_one $kgm_zone_ptr | |
1248 | set $kgm_zone_ptr = $kgm_zone_ptr->next_zone | |
1249 | end | |
1250 | printf "\n" | |
1251 | end | |
1252 | document zprint | |
1253 | | Routine to print a summary listing of all the kernel zones | |
1254 | | The following is the syntax: | |
1255 | | (gdb) zprint | |
1256 | end | |
1257 | ||
9bccf70c A |
1258 | set $kdp_act_counter = 0 |
1259 | ||
1260 | define switchtoact | |
1261 | if (machine_slot[0].cpu_type == 18) | |
1262 | if ($kdp_act_counter == 0) | |
1263 | set $kdpstate = (struct savearea *) kdp.saved_state | |
1264 | end | |
1265 | set $kdp_act_counter = $kdp_act_counter + 1 | |
1266 | set $newact = (struct thread_activation *) $arg0 | |
1267 | if (($newact.thread)->kernel_stack == 0) | |
1268 | echo This activation does not have a stack.\n | |
1269 | echo continuation: | |
1270 | output/a $newact.thread.continuation | |
1271 | echo \n | |
1272 | end | |
1273 | set (struct savearea *) kdp.saved_state=$newact->mact->pcb | |
1274 | flush | |
1275 | set $pc=$newact->mact->pcb.save_srr0 | |
1276 | update | |
1277 | else | |
1278 | echo switchtoact not implemented for this architecture.\n | |
1279 | end | |
1280 | end | |
1281 | ||
1282 | document switchtoact | |
1283 | Syntax: switchtoact <address of activation> | |
1284 | | This command allows gdb to examine the execution context and call | |
1285 | | stack for the specified activation. For example, to view the backtrace | |
1286 | | for an activation issue "switchtoact <address>", followed by "bt". | |
1287 | | Before resuming execution, issue a "resetctx" command, to | |
1288 | | return to the original execution context. | |
1289 | end | |
1290 | ||
1291 | define switchtoctx | |
1292 | if (machine_slot[0].cpu_type == 18) | |
1293 | if ($kdp_act_counter == 0) | |
1294 | set $kdpstate = (struct savearea *) kdp.saved_state | |
1295 | end | |
1296 | set $kdp_act_counter = $kdp_act_counter + 1 | |
1297 | set (struct savearea *) kdp.saved_state=(struct savearea *) $arg0 | |
1298 | flush | |
1299 | set $pc=((struct savearea *) $arg0)->save_srr0 | |
1300 | update | |
1301 | else | |
1302 | echo switchtoctx not implemented for this architecture.\n | |
1303 | end | |
1304 | end | |
1305 | ||
1306 | document switchtoctx | |
1307 | Syntax: switchtoctx <address of pcb> | |
1308 | | This command allows gdb to examine an execution context and dump the | |
1309 | | backtrace for this execution context. | |
1310 | | Before resuming execution, issue a "resetctx" command, to | |
1311 | | return to the original execution context. | |
1312 | end | |
1313 | ||
1314 | define resetctx | |
1315 | if (machine_slot[0].cpu_type == 18) | |
1316 | set (struct savearea *)kdp.saved_state=$kdpstate | |
1317 | flush | |
1318 | set $pc=((struct savearea *) kdp.saved_state)->save_srr0 | |
1319 | update | |
1320 | set $kdp_act_counter = 0 | |
1321 | else | |
1322 | echo resetctx not implemented for this architecture.\n | |
1323 | end | |
1324 | end | |
1325 | ||
1326 | document resetctx | |
1327 | | Syntax: resetctx | |
1328 | | Returns to the original execution context. This command should be | |
1329 | | issued if you wish to resume execution after using the "switchtoact" | |
1330 | | or "switchtoctx" commands. | |
1331 | end | |
1332 | ||
1333 | define paniclog | |
1334 | set $kgm_panic_bufptr = debug_buf | |
1335 | set $kgm_panic_bufptr_max = debug_buf+debug_buf_size | |
1336 | while *$kgm_panic_bufptr && $kgm_panic_bufptr < $kgm_panic_bufptr_max | |
1337 | if *(char *)$kgm_panic_bufptr == 10 | |
1338 | printf "\n" | |
1339 | else | |
1340 | printf "%c", *$kgm_panic_bufptr | |
1341 | end | |
1342 | set $kgm_panic_bufptr= (char *)$kgm_panic_bufptr + 1 | |
1343 | end | |
1344 | end | |
1345 | ||
1346 | document paniclog | |
1347 | | Syntax: paniclog | |
1348 | | Display the panic log information | |
1349 | | | |
1350 | end |