Skip to content

Commit c219fa6

Browse files
richl9brenns10
authored andcommitted
Add corelens option to print panic bt
Orabug: 38074929 Signed-off-by: Richard Li <[email protected]>
1 parent 58477b3 commit c219fa6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

drgn_tools/bt.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,20 @@ def print_online_bt(
631631
print()
632632

633633

634+
def print_panic_bt(prog: Program) -> None:
635+
"""
636+
Prints the panic task bt
637+
638+
"""
639+
try:
640+
thread = prog.crashed_thread()
641+
except Exception:
642+
pid = cpu_curr(prog, prog["crashing_cpu"]).pid.value_()
643+
thread = prog.thread(pid)
644+
bt(thread)
645+
print()
646+
647+
634648
def print_all_bt(
635649
prog: Program, states: t.Optional[t.Container[str]] = None, **kwargs: t.Any
636650
) -> None:
@@ -688,6 +702,12 @@ def add_args(self, parser: argparse.ArgumentParser) -> None:
688702
nargs="?",
689703
help="A PID, or address of a task_struct to unwind",
690704
)
705+
op.add_argument(
706+
"-p",
707+
"--panic",
708+
action="store_true",
709+
help="Print a backtrace for panic task",
710+
)
691711
op.add_argument(
692712
"-c",
693713
"--cpu",
@@ -725,6 +745,9 @@ def run(self, prog: Program, args: argparse.Namespace) -> None:
725745
print("On-CPU tasks are not supported for /proc/kcore")
726746
else:
727747
bt(prog, cpu=args.cpu, **kwargs)
748+
elif args.panic:
749+
print("Panic task:")
750+
print_panic_bt(prog)
728751
elif args.pid_or_task is not None:
729752
try:
730753
task = prog.thread(int(args.pid_or_task, 10)).object

0 commit comments

Comments
 (0)