A Total Overhaul on the Lunaix's Virtual Memory Model (#26)
[lunaix-os.git] / lunaix-os / scripts / gdb / lunadbg / sched_dump.py
1 import gdb
2 from .utils import pid_argument, llist_foreach
3 from .pp import MyPrettyPrinter
4 from .structs.pcb import ProcInfo
5 from .structs.scheduler import Scheduler
6 from .commands import LunadbgCommand
7        
8 class ProcessDump(LunadbgCommand):
9     """Dump the state of Lunaix PCB"""
10     def __init__(self) -> None:
11         super().__init__("proc")
12
13     def execute(self, parsed, gdb_args, from_tty):
14         pp = MyPrettyPrinter()
15         ProcInfo.process_at(gdb_args).print_detailed(pp)
16
17
18 class SchedulerDump(LunadbgCommand):
19     """Dump the state of Lunaix process table"""
20     def __init__(self) -> None:
21         super().__init__("sched")
22         self._parser.add_argument("print_type")
23         self._parser.add_argument("-l", "--long-list", 
24                                   required=False, default=False, action='store_true')
25
26     def on_execute(self, args, gdb_args, from_tty):
27         sched_context = gdb.parse_and_eval("&sched_ctx")
28         sched = Scheduler(sched_context)
29
30         sched.print_detailed(MyPrettyPrinter(), args.print_type, args.long_list)