~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/scripts/gdb/linux/radixtree.py

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /scripts/gdb/linux/radixtree.py (Version linux-6.12-rc7) and /scripts/gdb/linux/radixtree.py (Version linux-4.16.18)


  1 # SPDX-License-Identifier: GPL-2.0                
  2 #                                                 
  3 #  Radix Tree Parser                              
  4 #                                                 
  5 # Copyright (c) 2016 Linaro Ltd                   
  6 # Copyright (c) 2023 Broadcom                     
  7 #                                                 
  8 # Authors:                                        
  9 #  Kieran Bingham <kieran.bingham@linaro.org>      
 10 #  Florian Fainelli <f.fainelli@gmail.com>         
 11                                                   
 12 import gdb                                        
 13                                                   
 14 from linux import utils                           
 15 from linux import constants                       
 16                                                   
 17 radix_tree_root_type = utils.CachedType("struc    
 18 radix_tree_node_type = utils.CachedType("struc    
 19                                                   
 20 def is_internal_node(node):                       
 21     long_type = utils.get_long_type()             
 22     return ((node.cast(long_type) & constants.    
 23                                                   
 24 def entry_to_node(node):                          
 25     long_type = utils.get_long_type()             
 26     node_type = node.type                         
 27     indirect_ptr = node.cast(long_type) & ~con    
 28     return indirect_ptr.cast(radix_tree_node_t    
 29                                                   
 30 def node_maxindex(node):                          
 31     return (constants.LX_RADIX_TREE_MAP_SIZE <    
 32                                                   
 33 def lookup(root, index):                          
 34     if root.type == radix_tree_root_type.get_t    
 35         node = root.dereference()                 
 36     elif root.type != radix_tree_root_type.get    
 37         raise gdb.GdbError("must be {} not {}"    
 38                            .format(radix_tree_    
 39                                                   
 40     node = root['xa_head']                        
 41     if node == 0:                                 
 42         return None                               
 43                                                   
 44     if not (is_internal_node(node)):              
 45         if (index > 0):                           
 46             return None                           
 47         return node                               
 48                                                   
 49     node = entry_to_node(node)                    
 50     maxindex = node_maxindex(node)                
 51                                                   
 52     if (index > maxindex):                        
 53         return None                               
 54                                                   
 55     shift = node['shift'] + constants.LX_RADIX    
 56                                                   
 57     while True:                                   
 58         offset = (index >> node['shift']) & co    
 59         slot = node['slots'][offset]              
 60                                                   
 61         if slot == 0:                             
 62             return None                           
 63                                                   
 64         node = slot.cast(node.type.pointer()).    
 65         if node == 0:                             
 66             return None                           
 67                                                   
 68         shift -= constants.LX_RADIX_TREE_MAP_S    
 69         if (shift <= 0):                          
 70             break                                 
 71                                                   
 72     return node                                   
 73                                                   
 74 class LxRadixTree(gdb.Function):                  
 75     """ Lookup and return a node from a RadixT    
 76                                                   
 77 $lx_radix_tree_lookup(root_node [, index]): Re    
 78 If index is omitted, the root node is derefere    
 79                                                   
 80     def __init__(self):                           
 81         super(LxRadixTree, self).__init__("lx_    
 82                                                   
 83     def invoke(self, root, index=0):              
 84         result = lookup(root, index)              
 85         if result is None:                        
 86             raise gdb.GdbError("No entry in tr    
 87                                                   
 88         return result                             
 89                                                   
 90 LxRadixTree()                                     
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php