+set $kdp_act_counter = 0
+
+define switchtoact
+ if (machine_slot[0].cpu_type == 18)
+ if ($kdp_act_counter == 0)
+ set $kdpstate = (struct savearea *) kdp.saved_state
+ end
+ set $kdp_act_counter = $kdp_act_counter + 1
+ set $newact = (struct thread_activation *) $arg0
+ if (($newact.thread)->kernel_stack == 0)
+ echo This activation does not have a stack.\n
+ echo continuation:
+ output/a $newact.thread.continuation
+ echo \n
+ end
+ set (struct savearea *) kdp.saved_state=$newact->mact->pcb
+ flush
+ set $pc=$newact->mact->pcb.save_srr0
+ update
+ else
+ echo switchtoact not implemented for this architecture.\n
+ end
+end
+
+document switchtoact
+Syntax: switchtoact <address of activation>
+| This command allows gdb to examine the execution context and call
+| stack for the specified activation. For example, to view the backtrace
+| for an activation issue "switchtoact <address>", followed by "bt".
+| Before resuming execution, issue a "resetctx" command, to
+| return to the original execution context.
+end
+
+define switchtoctx
+ if (machine_slot[0].cpu_type == 18)
+ if ($kdp_act_counter == 0)
+ set $kdpstate = (struct savearea *) kdp.saved_state
+ end
+ set $kdp_act_counter = $kdp_act_counter + 1
+ set (struct savearea *) kdp.saved_state=(struct savearea *) $arg0
+ flush
+ set $pc=((struct savearea *) $arg0)->save_srr0
+ update
+ else
+ echo switchtoctx not implemented for this architecture.\n
+ end
+end
+
+document switchtoctx
+Syntax: switchtoctx <address of pcb>
+| This command allows gdb to examine an execution context and dump the
+| backtrace for this execution context.
+| Before resuming execution, issue a "resetctx" command, to
+| return to the original execution context.
+end
+
+define resetctx
+ if (machine_slot[0].cpu_type == 18)
+ set (struct savearea *)kdp.saved_state=$kdpstate
+ flush
+ set $pc=((struct savearea *) kdp.saved_state)->save_srr0
+ update
+ set $kdp_act_counter = 0
+ else
+ echo resetctx not implemented for this architecture.\n
+ end
+end
+
+document resetctx
+| Syntax: resetctx
+| Returns to the original execution context. This command should be
+| issued if you wish to resume execution after using the "switchtoact"
+| or "switchtoctx" commands.
+end
+
+define paniclog
+ set $kgm_panic_bufptr = debug_buf
+ set $kgm_panic_bufptr_max = debug_buf+debug_buf_size
+ while *$kgm_panic_bufptr && $kgm_panic_bufptr < $kgm_panic_bufptr_max
+ if *(char *)$kgm_panic_bufptr == 10
+ printf "\n"
+ else
+ printf "%c", *$kgm_panic_bufptr
+ end
+ set $kgm_panic_bufptr= (char *)$kgm_panic_bufptr + 1
+ end
+end
+
+document paniclog
+| Syntax: paniclog
+| Display the panic log information
+|
+end