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

TOMOYO Linux Cross Reference
Linux/scripts/gdb/linux/modules.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/modules.py (Version linux-6.12-rc7) and /scripts/gdb/linux/modules.py (Version linux-3.10.108)


  1 #                                                 
  2 # gdb helper commands and functions for Linux     
  3 #                                                 
  4 #  module tools                                   
  5 #                                                 
  6 # Copyright (c) Siemens AG, 2013                  
  7 #                                                 
  8 # Authors:                                        
  9 #  Jan Kiszka <jan.kiszka@siemens.com>             
 10 #                                                 
 11 # This work is licensed under the terms of the    
 12 #                                                 
 13                                                   
 14 import gdb                                        
 15                                                   
 16 from linux import cpus, utils, lists, constant    
 17                                                   
 18                                                   
 19 module_type = utils.CachedType("struct module"    
 20                                                   
 21                                                   
 22 def module_list():                                
 23     global module_type                            
 24     modules = utils.gdb_eval_or_none("modules"    
 25     if modules is None:                           
 26         return                                    
 27                                                   
 28     module_ptr_type = module_type.get_type().p    
 29                                                   
 30     for module in lists.list_for_each_entry(mo    
 31         yield module                              
 32                                                   
 33                                                   
 34 def find_module_by_name(name):                    
 35     for module in module_list():                  
 36         if module['name'].string() == name:       
 37             return module                         
 38     return None                                   
 39                                                   
 40                                                   
 41 class LxModule(gdb.Function):                     
 42     """Find module by name and return the modu    
 43                                                   
 44 $lx_module("MODULE"): Given the name MODULE, i    
 45 of the target and return that module variable     
 46                                                   
 47     def __init__(self):                           
 48         super(LxModule, self).__init__("lx_mod    
 49                                                   
 50     def invoke(self, mod_name):                   
 51         mod_name = mod_name.string()              
 52         module = find_module_by_name(mod_name)    
 53         if module:                                
 54             return module.dereference()           
 55         else:                                     
 56             raise gdb.GdbError("Unable to find    
 57                                                   
 58                                                   
 59 LxModule()                                        
 60                                                   
 61                                                   
 62 class LxLsmod(gdb.Command):                       
 63     """List currently loaded modules."""          
 64                                                   
 65     _module_use_type = utils.CachedType("struc    
 66                                                   
 67     def __init__(self):                           
 68         super(LxLsmod, self).__init__("lx-lsmo    
 69                                                   
 70     def invoke(self, arg, from_tty):              
 71         gdb.write(                                
 72             "Address{0}    Module                 
 73                 "        " if utils.get_long_t    
 74                                                   
 75         for module in module_list():              
 76             text = module['mem'][constants.LX_    
 77             text_addr = str(text['base']).spli    
 78             total_size = 0                        
 79                                                   
 80             for i in range(constants.LX_MOD_TE    
 81                 total_size += module['mem'][i]    
 82                                                   
 83             gdb.write("{address} {name:<19} {s    
 84                 address=text_addr,                
 85                 name=module['name'].string(),     
 86                 size=str(total_size),             
 87                 ref=str(module['refcnt']['coun    
 88                                                   
 89             t = self._module_use_type.get_type    
 90             first = True                          
 91             sources = module['source_list']       
 92             for use in lists.list_for_each_ent    
 93                 gdb.write("{separator}{name}".    
 94                     separator=" " if first els    
 95                     name=use['source']['name']    
 96                 first = False                     
 97                                                   
 98             gdb.write("\n")                       
 99                                                   
100 LxLsmod()                                         
101                                                   
102 def help():                                       
103     t = """Usage: lx-getmod-by-textaddr [Hexim    
104     Example: lx-getmod-by-textaddr 0xffff80000    
105     gdb.write("Unrecognized command\n")           
106     raise gdb.GdbError(t)                         
107                                                   
108 class LxFindTextAddrinMod(gdb.Command):           
109     '''Look up loaded kernel module by text ad    
110                                                   
111     def __init__(self):                           
112         super(LxFindTextAddrinMod, self).__ini    
113                                                   
114     def invoke(self, arg, from_tty):              
115         args = gdb.string_to_argv(arg)            
116                                                   
117         if len(args) != 1:                        
118             help()                                
119                                                   
120         addr = gdb.Value(int(args[0], 16)).cas    
121         for mod in module_list():                 
122             mod_text_start = mod['mem'][consta    
123             mod_text_end = mod_text_start + mo    
124                                                   
125             if addr >= mod_text_start and addr    
126                 s = "0x%x" % addr + " is in "     
127                 gdb.write(s)                      
128                 return                            
129         gdb.write("0x%x is not in any module t    
130                                                   
131 LxFindTextAddrinMod()                             
                                                      

~ [ 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