> -----Message d'origine----- > De : [EMAIL PROTECTED] [mailto:grub-devel- > [EMAIL PROTECTED] De la part de Tomáš Ebenlendr > Envoyé : jeudi 4 mai 2006 11:24 > À : The development of GRUB 2 > Objet : Re: RE : grub-emu state of the art > > > > - let gdb know about dynamically loaded modules ;-), but I guess it > > won't be the easy part. > > That depends how modules are loaded in grub-emu. With standard libdl it > couldn't be problem.
Of course, they are loaded with kern/dl.c in grub-emu, to comply with what is done in grub2 images. I thought we could add code compiled only with GRUB_UTIL to supply load maps the way libdl does, during the grub_load_segments(), etc. process and merely call _dl_debug_state() for gdb to know about newly loaded symbols before the call to mod->init(mod) is done. But that's a lot to do and I was wondering if someone reading us just didn't do that yet in another lifetime. > But I remember a situation when we run gdb on UML(user mode linux) kernel. > When we loaded a kernel module there (using kernel dynamic loader), gdb > was able to print adress where it is loaded, and also it was able to load > symbol table with given memory offset. But we had to read the address > by our eyes and type the offset (exactly same number) to gdb by hand. > Later we used expect script to do this. > That's about just what I am doing right now. There is a difference of importance : grub's modules are relocated ELF file, not shared ELF file (.so) and my gdb just *don't* load symbol table from relocated ELF file (why has it to be so dummy, that still question me, anyway shared ELF files contains more info for gdb to use apparently, including source lines references). So believe it or not, this ended up to this for now (in case someone would be interested) : - I have added debug lines in the code (set debug=symbols to activate) to read the address of loaded segments. - I relink modules I debug with the -shared option instead of the -r option of ld to produce module.mod + "same" module.so files. - I command gdb to read symbols from .so files at startup (add-symbol-file commands with the correct addresses for .text, .rodata, .data and .bss segments) and that's it, ready to go. Next step would be to automate the all process. You can then loads modules and debug them without the need to change Makefiles to include modules in the main kernel. Eric Salomé - Paris, France _______________________________________________ Grub-devel mailing list [email protected] http://lists.gnu.org/mailman/listinfo/grub-devel
