def show_sched_features(options): sched_feat_keys = readSymbol("sched_feat_keys") sched_feat_names = readSymbol("sched_feat_names") enable_str = crashcolor.get_color(crashcolor.BLUE) + "enabled" disable_str = crashcolor.get_color(crashcolor.RED) + "disabled" for i in range(0, len(sched_feat_keys)): print("%-20s : %s" % (sched_feat_names[i], enable_str if sched_feat_keys[i].enabled.counter > 0 else disable_str)) crashcolor.set_color(crashcolor.RESET)
def show_manual_module_detail(options, module): # Not using at the moment syms = module.syms num_syms = module.num_syms num_gpl_syms = module.num_gpl_syms # symtab and core_symtab are same if member_offset("struct module", "core_kallsyms") >= 0: symtab = module.core_kallsyms.symtab num_symtab = module.core_kallsyms.num_symtab else: symtab = module.symtab num_symtab = module.num_symtab strtab = get_strtab_dict(options, module) symtab_per_type = {} for i in range(0, num_symtab): symtab_type = symtab[i].st_info & 0xf if symtab_type not in symtab_per_type: symtab_dict = {} symtab_per_type[symtab_type] = symtab_dict else: symtab_dict = symtab_per_type[symtab_type] symtab_dict[strtab[symtab[i].st_name]] = symtab[i] print() print("=+" * 30) reset_color = crashcolor.get_color(crashcolor.RESET) for sym_type in symtab_per_type: sym_type_str = get_sym_type_str(sym_type) print("[[[ %s ]]]" % (sym_type_str)) symtab_dict = symtab_per_type[sym_type] if sym_type_str == "FUNCTION": sym_color = crashcolor.get_color(crashcolor.BLUE) elif sym_type_str == "DATA": sym_color = crashcolor.get_color(crashcolor.GREEN) else: sym_color = crashcolor.get_color(crashcolor.YELLOW) for sym_name in symtab_dict: sym_data = symtab_dict[sym_name] print("0x%x (%s%s%s) for %d bytes" % (sym_data.st_value, sym_color, sym_name, reset_color, sym_data.st_size)) if options.show_contents or options.reverse_disasm: show_symbol_detail(options, sym_type, sym_data) print("--" * 30) print()
def print_bt_search(bt_str, include_list): reset_color = crashcolor.get_color(crashcolor.RESET) reset_len = len(reset_color) bt_str_list = bt_str.splitlines() highlight_len_list = [] for hc_str in highlight_color_list: highlight_len_list.append(len(hc_str)) highlight_max = len(highlight_color_list) print("") for line in bt_str_list: idx = 0 for include_str in include_list: pos = line.find(include_str) highlight_color = highlight_color_list[idx] highlight_len = highlight_len_list[idx] while pos >= 0: line = line[:pos] + highlight_color + line[pos:pos + len(include_str)] +\ reset_color + line[pos + len(include_str):] pos = line.find( include_str, pos + len(include_str) + highlight_len + reset_len) idx = idx + 1 if (idx >= highlight_max): idx = 0 print(line)
def show_slabdetail(options): result = exec_crash_command("kmem -S %s" % options.slabdetail) result_lines = result.splitlines(True) slab_list = {} result_len = len(result_lines) objsize = 0 content_count = {} blue_color = crashcolor.get_color(crashcolor.BLUE) red_color = crashcolor.get_color(crashcolor.RED) reset_color = crashcolor.get_color(crashcolor.RESET) print("CACHE OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME") for i in range(1, result_len - 1): if result_lines[i].startswith("kmem: "): # error message continue result_line = result_lines[i].split() if objsize == 0: objsize = int(result_line[1]) print(result_lines[i], end="") if result_line[0].startswith("["): content = exec_crash_command( "rd 0x%s %d" % (result_line[0][1:-1], objsize / sys_info.pointersize)) content_lines = content.splitlines(True) for line in content_lines: words = line.split() output_string = words[0] for cnt_pos in range(1, 3): word = words[cnt_pos] if word not in content_count: content_count[word] = 1 else: content_count[word] = content_count[word] + 1 if options.details == False: continue if content_count[word] > 10: output_string = output_string + blue_color +\ " " + word + reset_color elif content_count[word] > 20: output_string = output_string + red_color +\ " " + word + reset_color else: output_string = output_string + " " + word if len(words) > 3: output_string = output_string + " " + line[ line.index(words[3]):] print("\t%s" % output_string, end="") sorted_content = sorted(content_count.items(), key=operator.itemgetter(1), reverse=True) min_number = 10 print("\n\t%s%s%s" % (blue_color, "Mostly appeared contents", reset_color)) print("\t%s" % ("-" * 40)) for i in range(0, min(len(sorted_content) - 1, min_number)): ascii_str = exec_crash_command("ascii %s" % sorted_content[i][0]) print("\t%s %5d %s" % (sorted_content[i][0], sorted_content[i][1], ascii_str[ascii_str.index(":") + 2:]), end="")
return result_str def search_one_task(bt_str, include_list, exclude_list): for exclude_str in exclude_list: if exclude_str != '' and bt_str.find(exclude_str) >= 0: return False for include_str in include_list: if include_str != '' and bt_str.find(include_str) >= 0: return True return False highlight_color_list = [ crashcolor.get_color(crashcolor.LIGHTRED), crashcolor.get_color(crashcolor.LIGHTBLUE), crashcolor.get_color(crashcolor.LIGHTYELLOW), crashcolor.get_color(crashcolor.LIGHTMAGENTA), crashcolor.get_color(crashcolor.LIGHTCYAN), ] def print_bt_search(bt_str, include_list): reset_color = crashcolor.get_color(crashcolor.RESET) reset_len = len(reset_color) bt_str_list = bt_str.splitlines() highlight_len_list = [] for hc_str in highlight_color_list: highlight_len_list.append(len(hc_str)) highlight_max = len(highlight_color_list)