1 # SPDX-License-Identifier: GPL-2.0 2 # 3 # Copyright (c) NXP 2019 4 5 import gdb 6 import sys 7 8 from linux import utils, lists, constants 9 10 clk_core_type = utils.CachedType("struct clk_c 11 12 13 def clk_core_for_each_child(hlist_head): 14 return lists.hlist_for_each_entry(hlist_he 15 clk_core_type.get_type().pointer() 16 17 18 class LxClkSummary(gdb.Command): 19 """Print clk tree summary 20 21 Output is a subset of /sys/kernel/debug/clk/cl 22 23 No calls are made during printing, instead a ( 24 are cached and potentially out of date""" 25 26 def __init__(self): 27 super(LxClkSummary, self).__init__("lx 28 29 def show_subtree(self, clk, level): 30 gdb.write("%*s%-*s %7d %8d %8d %11lu%s 31 level * 3 + 1, "", 32 30 - level * 3, 33 clk['name'].string(), 34 clk['enable_count'], 35 clk['prepare_count'], 36 clk['protect_count'], 37 clk['rate'], 38 '(c)' if clk['flags'] & consta 39 40 for child in clk_core_for_each_child(c 41 self.show_subtree(child, level + 1 42 43 def invoke(self, arg, from_tty): 44 if utils.gdb_eval_or_none("clk_root_li 45 raise gdb.GdbError("No clocks regi 46 gdb.write(" 47 gdb.write(" clock 48 gdb.write("--------------------------- 49 for clk in clk_core_for_each_child(gdb 50 self.show_subtree(clk, 0) 51 for clk in clk_core_for_each_child(gdb 52 self.show_subtree(clk, 0) 53 54 55 LxClkSummary() 56 57 58 class LxClkCoreLookup(gdb.Function): 59 """Find struct clk_core by name""" 60 61 def __init__(self): 62 super(LxClkCoreLookup, self).__init__( 63 64 def lookup_hlist(self, hlist_head, name): 65 for child in clk_core_for_each_child(h 66 if child['name'].string() == name: 67 return child 68 result = self.lookup_hlist(child[' 69 if result: 70 return result 71 72 def invoke(self, name): 73 name = name.string() 74 return (self.lookup_hlist(gdb.parse_an 75 self.lookup_hlist(gdb.parse_an 76 77 78 LxClkCoreLookup()
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.