Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Module kdb support
0004  *
0005  * Copyright (C) 2010 Jason Wessel
0006  */
0007 
0008 #include <linux/module.h>
0009 #include <linux/kdb.h>
0010 #include "internal.h"
0011 
0012 /*
0013  * kdb_lsmod - This function implements the 'lsmod' command.  Lists
0014  *  currently loaded kernel modules.
0015  *  Mostly taken from userland lsmod.
0016  */
0017 int kdb_lsmod(int argc, const char **argv)
0018 {
0019     struct module *mod;
0020 
0021     if (argc != 0)
0022         return KDB_ARGCOUNT;
0023 
0024     kdb_printf("Module                  Size  modstruct     Used by\n");
0025     list_for_each_entry(mod, &modules, list) {
0026         if (mod->state == MODULE_STATE_UNFORMED)
0027             continue;
0028 
0029         kdb_printf("%-20s%8u", mod->name, mod->core_layout.size);
0030 #ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC
0031         kdb_printf("/%8u", mod->data_layout.size);
0032 #endif
0033         kdb_printf("  0x%px ", (void *)mod);
0034 #ifdef CONFIG_MODULE_UNLOAD
0035         kdb_printf("%4d ", module_refcount(mod));
0036 #endif
0037         if (mod->state == MODULE_STATE_GOING)
0038             kdb_printf(" (Unloading)");
0039         else if (mod->state == MODULE_STATE_COMING)
0040             kdb_printf(" (Loading)");
0041         else
0042             kdb_printf(" (Live)");
0043         kdb_printf(" 0x%px", mod->core_layout.base);
0044 #ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC
0045         kdb_printf("/0x%px", mod->data_layout.base);
0046 #endif
0047 
0048 #ifdef CONFIG_MODULE_UNLOAD
0049         {
0050             struct module_use *use;
0051 
0052             kdb_printf(" [ ");
0053             list_for_each_entry(use, &mod->source_list,
0054                         source_list)
0055                 kdb_printf("%s ", use->target->name);
0056             kdb_printf("]\n");
0057         }
0058 #endif
0059     }
0060 
0061     return 0;
0062 }