I following the GRUB 2 gdb debugging instructions this week and I was successful in using QEMU and gdb to debug GRUB. I wondered if we could make this a bit easier -- primarily by making GRUB's build system generate the '.elf' files with full symbol info without requiring a patch. Attached is a patch against GRUB 2 trunk (this is the one from the GRUB 2 debugging guide, just fixed to apply on the latest GRUB sources).
We could make it a 'configure' option like '--enable-debug' or something, but it seems like minimal overhead to generate the .elf files for gdb in addition to "real" GRUB files. Let me know what you all think. Thanks! Regards, Colin
=== modified file 'genmk.rb'
--- genmk.rb 2008-07-28 21:35:40 +0000
+++ genmk.rb 2008-08-05 14:36:06 +0000
@@ -101,10 +101,11 @@
mod_obj = mod_src.suffix('o')
defsym = 'def-' + @name.suffix('lst')
undsym = 'und-' + @name.suffix('lst')
+ exec = @name.suffix('elf')
mod_name = File.basename(@name, '.mod')
symbolic_name = mod_name.sub(/\.[^\.]*$/, '')
- "CLEANFILES += [EMAIL PROTECTED] #{mod_obj} #{mod_src} #{pre_obj} #{objs_str} #{undsym}
+ "CLEANFILES += [EMAIL PROTECTED] #{mod_obj} #{mod_src} #{pre_obj} #{objs_str} #{undsym} #{exec}
ifneq ($(#{prefix}_EXPORTS),no)
CLEANFILES += #{defsym}
DEFSYMFILES += #{defsym}
@@ -112,11 +113,14 @@
MOSTLYCLEANFILES += #{deps_str}
UNDSYMFILES += #{undsym}
[EMAIL PROTECTED]: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF)
[EMAIL PROTECTED]: #{exec}
+ -rm -f $@
+ $(OBJCOPY) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $^ $@
+
+#{exec}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF)
-rm -f $@
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) $(MODULE_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj} #{mod_obj}
if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
- $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@
#{pre_obj}: $(#{prefix}_DEPENDENCIES) #{objs_str}
-rm -f $@
=== modified file 'kern/main.c'
--- kern/main.c 2008-08-04 21:54:06 +0000
+++ kern/main.c 2008-08-05 14:36:06 +0000
@@ -122,6 +122,9 @@
grub_print_error ();
}
+void
+main (void) __attribute__ ((alias("grub_main")));
+
/* The main routine. */
void
grub_main (void)
signature.asc
Description: PGP signature
_______________________________________________ Grub-devel mailing list [email protected] http://lists.gnu.org/mailman/listinfo/grub-devel
