Skip to contentSkip to conversation

mdb: add export function to module.c

PATCH In review [email protected] 1 participant 1 message Aug 16, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 24/28 mdb: add export function to module.c

add the ability to scan and display the loaded module list inside the debugger.

kernel/module.c +33 -0
@@ -2503,6 +2503,39 @@
 	return 0;
 }
 
+#if defined(CONFIG_MDB) || defined(CONFIG_MDB_MODULE)
+int mdb_modules(char *str, int (*print)(char *s, ...))
+{
+	struct module *mod;
+	struct module_use *use;
+
+        if (!print)
+           return 0;
+
+	list_for_each_entry(mod, &modules, list)
+        {
+           if (str && *str && !strstr(mod->name, str))
+              continue;
+
+	   print(" 0x%08p ", mod->module_core);
+	   print("%s", mod->name);
+	   print(" %lu %02u ", mod->init_size + mod->core_size,
+                 module_refcount(mod));
+	   list_for_each_entry(use, &mod->modules_which_use_me, list)
+		print("%s,", use->module_which_uses->name);
+	   if (mod->init != NULL && mod->exit == NULL)
+	      print("[permanent],");
+	   print(" %s ", mod->state == MODULE_STATE_GOING ? "Unloading":
+	                mod->state == MODULE_STATE_COMING ? "Loading":
+		        "Live");
+	   if (print("\n"))
+              return 1;
+	}
+        return 0;
+}
+EXPORT_SYMBOL_GPL(mdb_modules);
+#endif
+
 /* Look for this name: can be of form module:name. */
 unsigned long module_kallsyms_lookup_name(const char *name)
 {