def invoke(self, arg, from_tty): """ Can get as argument pointer to task or pointer to space""" if sys_info.is_in_kernel_space() is False: gdb.write("\nYou are currently in user space, " "this functionality is not available here.\n\n") return try: argv = gdb.string_to_argv(arg) if len(argv) == 2 and sys_info.is_valid_ptr(int(argv[1], 0)): if argv[0] == "-task": task = int(argv[1], 0) if not types.is_task_exist(task): gdb.write(f"\nRequested task {argv[1]} do not exist in the tasks" f"list of the system!\n\n\n") self.print_ipc_space_table(types.Task(task).ipc_space) elif argv[0] == "-space": space = int(argv[1], 0) self.print_ipc_space_table(space) else: gdb.write( "\nUsage: xnu-ipc_entry-list -task/space" " ${TASK_PTR}/${SPACE_PTR}\n") else: gdb.write("\nUsage: xnu-ipc_entry-list -task/space" " ${TASK_PTR}/${SPACE_PTR}\n") except Exception: raise gdb.GdbError(traceback.format_exc())
def __init__(self, address): if sys_info.is_valid_ptr(address): self.entry = IPCSpace(address).is_table self.size = IPCSpace(address).is_table_size self.index = 0 else: raise gdb.GdbError(f"Wrong ipc_entry pointer {address}")
def invoke(self, arg, from_tty): """ Parsing arguments, invoking printing. You can print all theeads of current task (no argument to command), All user threads - xnu-threads user All threads whithin the system - xnu-threads global All threads of specific task - xnu-threads ${task_ptr} """ try: argv = gdb.string_to_argv(arg) if len(argv) == 0: self.print_all_threads() elif len(argv) == 1: if argv[0] == "user": self.print_all_threads(user_only=True, is_global=True) elif argv[0] == "global": self.print_all_threads(is_global=True) else: try: requested_task = int(argv[0], 0) if sys_info.is_valid_ptr(requested_task): if not types.is_task_exist(requested_task): gdb.write( f"\nRequested task {argv[0]} do not exist" f" in the tasks list of the system!\n\n\n") self.print_all_threads(task=requested_task) except Exception: gdb.GdbError(gdb.GdbError("wrong args")) else: raise gdb.GdbError("wrong args") except Exception: raise gdb.GdbError(traceback.format_exc())
def invoke(self, arg, from_tty): """ print info """ try: argv = gdb.string_to_argv(arg) if len(argv) == 1 and sys_info.is_valid_ptr(int(argv[0], 0)): ipc_port = int(argv[0], 0) gdb.write(types.IPCPort(ipc_port).print_ipc_port_info() + '\n') else: gdb.write("wrong args\n") except Exception: raise gdb.GdbError(traceback.format_exc())
def invoke(self, arg, from_tty): try: argv = gdb.string_to_argv(arg) if len(argv) == 1 and sys_info.is_valid_ptr(int(argv[0], 0)): voucher = int(argv[0], 0) gdb.write( types.ThreadVoucher(voucher).print_voucher_info() + '\n') else: gdb.write("wrong args\n") except Exception: raise gdb.GdbError(traceback.format_exc())
def invoke(self, arg, from_tty): """ print info """ if sys_info.is_in_kernel_space() is False: gdb.write("\nYou are currently in user space, " "this functionality is not available here.\n\n") return try: argv = gdb.string_to_argv(arg) if len(argv) == 1 and sys_info.is_valid_ptr(int(argv[0], 0)): ipc_port = int(argv[0], 0) gdb.write(types.IPCPort(ipc_port).print_ipc_port_info()+'\n') else: gdb.write("\nUsage: xnu-ipc-port-info ${IPC_PORT_PTR}\n") except Exception: raise gdb.GdbError(traceback.format_exc())
def invoke(self, arg, from_tty): if sys_info.is_in_kernel_space() is False: gdb.write("\nYou are currently in user space, " "this functionality is not available here.\n\n") return try: argv = gdb.string_to_argv(arg) if len(argv) == 1 and sys_info.is_valid_ptr(int(argv[0], 0)): voucher = int(argv[0], 0) gdb.write(types.ThreadVoucher(voucher).print_voucher_info()+'\n') else: gdb.write("\nUsage: xnu-voucher-info ${THREAD_PTR} " "(maybe wrong pointer?)\n") except Exception: raise gdb.GdbError(traceback.format_exc())
def invoke(self, arg, from_tty): """ print info of given task, checking if exist""" try: argv = gdb.string_to_argv(arg) if len(argv) == 1: task = int(argv[0], 0) #convert to integer if sys_info.is_valid_ptr(task): if not types.is_task_exist(task): gdb.write( f"\nRequested task {argv[0]} do not exist in the task " f"list of the system!\n\n\n") gdb.write(types.Task(task).print_task_info_long() + '\n') else: gdb.write("Given task do not exist\n") else: gdb.write("wrong args\n") except Exception: raise gdb.GdbError(traceback.format_exc())
def invoke(self, arg, from_tty): """ print info of given task, checking if exist""" if sys_info.is_in_kernel_space() is False: gdb.write("\nYou are currently in user space, " "this functionality is not available here.\n\n") return try: argv = gdb.string_to_argv(arg) if len(argv) == 1: """convert to integer""" task = int(argv[0], 0) if sys_info.is_valid_ptr(task): if not types.is_task_exist(task): gdb.write(f"\nRequested task {argv[0]} do not exist in the task " f"list of the system!\n\n\n") gdb.write(types.Task(task).print_task_info_long()+'\n') else: gdb.write("Given task do not exist\n") else: gdb.write("\nUsage: xnu-task-info ${TASK_PTR}\n") except Exception: raise gdb.GdbError(traceback.format_exc())
def invoke(self, arg, from_tty): """ Can get as argument pointer to task or pointer to space""" try: argv = gdb.string_to_argv(arg) if len(argv) == 2 and sys_info.is_valid_ptr(int(argv[1], 0)): if argv[0] == "-task": task = int(argv[1], 0) if not types.is_task_exist(task): gdb.write( f"\nRequested task {argv[1]} do not exist in the tasks" f"list of the system!\n\n\n") self.print_ipc_space_table(types.Task(task).ipc_space) elif argv[0] == "-space": space = int(argv[1], 0) self.print_ipc_space_table(space) else: gdb.write( "wrong args, usage $ xnu-ipc_entry-list -task/table {PTR} \n" ) else: gdb.write(f"wrong args\n") except Exception: raise gdb.GdbError(traceback.format_exc())
def invoke(self, arg, from_tty): """ Parsing arguments, invoking printing. You can print all theeads of current task (no argument to command), All threads of current task xnu-threads current All user threads - xnu-threads user All threads whithin the system - xnu-threads All threads of specific task - xnu-threads ${task_ptr} """ if sys_info.is_in_kernel_space() is False: gdb.write("\nYou are currently in user space, " "this functionality is not available here.\n\n") return try: argv = gdb.string_to_argv(arg) if len(argv) == 0: self.print_all_threads(is_global=True) elif len(argv) == 1: if argv[0] == "user": self.print_all_threads(user_only=True, is_global=True) elif argv[0] == "current": task = sys_info.get_current_task_ptr() self.print_all_threads(task=task) else: try: requested_task = int(argv[0], 0) if sys_info.is_valid_ptr(requested_task): if not types.is_task_exist(requested_task): gdb.write(f"\nRequested task {argv[0]} do not exist" f" in the tasks list of the system!\n\n\n") self.print_all_threads(task=requested_task) except Exception: gdb.write("\nUsage: xnu-threads ${TASK_PTR}\n") else: gdb.write("\nUsage: xnu-threads ${TASK_PTR}\n") except Exception: raise gdb.GdbError(traceback.format_exc())