diff --git a/linux-ramdump-parser-v2/parsers/taskdump.py b/linux-ramdump-parser-v2/parsers/taskdump.py old mode 100644 new mode 100755 index 984dae441b3e7366dca0523c7acb0b511217e1c6..e9fa91102c6053aad4a4232c13771947b4936f3f --- a/linux-ramdump-parser-v2/parsers/taskdump.py +++ b/linux-ramdump-parser-v2/parsers/taskdump.py @@ -12,7 +12,8 @@ import string from print_out import print_out_str from parser_util import register_parser, RamParser, cleanupString - +taskhighlight_out = None +highlight_tasks = "\n=====List of all runing and uninterruptable sleep process====\n" def find_panic(ramdump, addr_stack, thread_task_name): if ramdump.arm64: @@ -49,8 +50,9 @@ def find_panic(ramdump, addr_stack, thread_task_name): return True return False - -def dump_thread_group(ramdump, thread_group, task_out, check_for_panic=0): +task_state_name = ["Runing", "ISleep", "DSleep"] +def dump_thread_group(ramdump, thread_group, task_out, taskhighlight_out, check_for_panic=0): + global highlight_tasks offset_thread_group = ramdump.field_offset( 'struct task_struct', 'thread_group') offset_comm = ramdump.field_offset('struct task_struct', 'comm') @@ -85,6 +87,10 @@ def dump_thread_group(ramdump, thread_group, task_out, check_for_panic=0): task_state = ramdump.read_word(next_thread_state) if task_state is None: return + if task_state < 3: + task_state_str = task_state_name[task_state] + else: + task_state_str = task_state task_exit_state = ramdump.read_int(next_thread_exit_state) if task_exit_state is None: return @@ -96,6 +102,24 @@ def dump_thread_group(ramdump, thread_group, task_out, check_for_panic=0): return if not check_for_panic: task_cpu = ramdump.get_task_cpu(next_thread_start, threadinfo) + #thread_line = thread_task_pid + task_cpu + task_state_str+ next_thread_start+thread_task_name + thread_line = "PID %6d cpu %1d state %16s start 0x%x comm %32s\n" %(thread_task_pid, task_cpu, task_state_str, next_thread_start, thread_task_name) + if task_state != 1: + if not first: + highlight_tasks += "*" + thread_line + taskhighlight_out.write("**"+thread_line) + else: + highlight_tasks += " " + thread_line + taskhighlight_out.write(" " + thread_line) + ramdump.unwind.unwind_backtrace( + ramdump.thread_saved_sp(next_thread_start), + ramdump.thread_saved_fp(next_thread_start), + ramdump.thread_saved_pc(next_thread_start), + 0, ' ', taskhighlight_out) + thread_line = '+' + thread_line + else: + thread_line = ' ' + thread_line + if not first: task_out.write('Process: {0}, cpu: {1} pid: {2} start: 0x{3:x}\n'.format( thread_task_name, task_cpu, thread_task_pid, next_thread_start)) @@ -146,11 +170,13 @@ def do_dump_stacks(ramdump, check_for_panic=0): seen_tasks = [] if check_for_panic == 0: task_out = ramdump.open_file('tasks.txt') + taskhighlight_out = ramdump.open_file('tasks_highlight.txt') else: task_out = None + taskhighlight_out = None while True: dump_thread_group(ramdump, init_thread_group, - task_out, check_for_panic) + task_out, taskhighlight_out, check_for_panic) next_task = ramdump.read_word(init_next_task) if next_task is None: init_next_task = init_addr + offset_tasks @@ -203,6 +229,8 @@ def do_dump_stacks(ramdump, check_for_panic=0): break if check_for_panic == 0: task_out.close() + taskhighlight_out.write(highlight_tasks + "\n") + taskhighlight_out.close() print_out_str('---wrote tasks to tasks.txt') def do_dump_task_timestamps(ramdump):