Messages in this thread Patch in this message | | | Subject | {PATCH] SysRq function to list module load addresses | Date | Thu, 07 Jan 1999 12:13:57 +0000 | From | David Woodhouse <> |
| |
This is a patch to add an extra SysRq function to list the load address of all currently-loaded modules. It should make it far easier to trace oopsen that occur in modules, as long as the system is still responding to SysRq after the oops.
Should I add a sysctl option to print the module list upon every oops, to catch the cases where the oops is fatal?
This is a fairly simple patch which shouldn't have adverse effects, so it'd be nice if it went into 2.2. Especially as I was provoked into writing it by having to debug problems in the pre-2.2 kernels.
Index: drivers/char/sysrq.c =================================================================== RCS file: /cvs/linux/drivers/char/sysrq.c,v retrieving revision 1.1.1.5 diff -u -w -u -r1.1.1.5 sysrq.c --- drivers/char/sysrq.c 1998/10/29 00:07:14 1.1.1.5 +++ drivers/char/sysrq.c 1999/01/07 11:20:47 @@ -70,6 +70,12 @@ printk("Keyboard mode set to XLATE\n"); } break; +#ifdef CONFIG_MODULES + case 'd': /* D -- moDule listing */ + printk("Module list:\n"); + list_modules(); + break; +#endif #ifdef CONFIG_VT case 'k': /* K -- SAK */ printk("SAK\n"); @@ -140,6 +146,9 @@ printk("Boot " #ifdef CONFIG_APM "Off " +#endif +#ifdef CONFIG_MODULES + "moDulelist " #endif "Sync Unmount showPc showTasks showMem loglevel0-8 tErm kIll killalL\n"); /* Don't use 'A' as it's handled specially on the Sparc */ Index: kernel/module.c =================================================================== RCS file: /cvs/linux/kernel/module.c,v retrieving revision 1.1.1.5 diff -u -w -r1.1.1.5 module.c --- kernel/module.c 1999/01/04 10:21:05 1.1.1.5 +++ kernel/module.c 1999/01/07 11:24:52 @@ -971,6 +971,25 @@ return 0; } +/* + * List the load address of all the currently loaded modules, for debugging + * purposes. Perhaps the oops routines should all call this automatically? + */ + +void list_modules() +{ + struct module *mlist = module_list; + + printk(" Name Address\n"); + + while (mlist && mlist->next) /* Don't do the last one */ + { + printk ("%-16s %p\n", mlist->name, + &((char *)mlist)[mlist->size_of_struct] ); + mlist = mlist->next; + } +} + #else /* CONFIG_MODULES */ /* Dummy syscalls for people who don't want modules */ Index: Documentation/sysrq.txt =================================================================== RCS file: /cvs/linux/Documentation/sysrq.txt,v retrieving revision 1.1.1.2 diff -u -w -r1.1.1.2 sysrq.txt --- Documentation/sysrq.txt 1998/10/28 21:44:54 1.1.1.2 +++ Documentation/sysrq.txt 1999/01/07 11:30:40 @@ -58,6 +58,9 @@ 'l' - Send a SIGKILL to all processes, INCLUDING init. (Your system will be non-functional after this.) +'d' - List all the currently-loaded modules, along with the address at + which they are loaded. + * Okay, so what can I use them for? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Well, un'R'aw is very handy when your X server or a svgalib program crashes. @@ -87,6 +90,10 @@ t'E'rm and k'I'll are useful if you have some sort of runaway process you are unable to kill any other way, especially if it's spawning other processes. + +The mo'D'ule listing function is useful if your kernel has just oopsed in a +module - you need to know the address at which each module is loaded in order +to have any more than a whelk's chance in a supernova of tracing the problem. * Sometimes SysRQ seems to get 'stuck' after using it, what can I do? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---- ---- ---- David Woodhouse David.Woodhouse@mvhi.com Office: (+44) 1223 810302 Project Leader, Process Information Systems Mobile: (+44) 976 658355 Axiom (Cambridge) Ltd., Swaffham Bulbeck, Cambridge, CB5 0NA, UK. finger dwmw2@ferret.lmh.ox.ac.uk for PGP key.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |