All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][RFC] gdb support in GRUB build system
@ 2008-08-05 14:42 Colin D Bennett
  2008-08-05 15:05 ` Felix Zielcke
  2008-08-05 20:14 ` Robert Millan
  0 siblings, 2 replies; 12+ messages in thread
From: Colin D Bennett @ 2008-08-05 14:42 UTC (permalink / raw)
  To: grub-devel


[-- Attachment #1.1: Type: text/plain, Size: 677 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: grub-gdb.patch --]
[-- Type: text/x-patch; name=grub-gdb.patch, Size: 1673 bytes --]

=== 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 += #{@name} #{mod_obj} #{mod_src} #{pre_obj} #{objs_str} #{undsym}
+    "CLEANFILES += #{@name} #{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}
 
-#{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF)
+#{@name}: #{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)


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-08-07 17:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-05 14:42 [PATCH][RFC] gdb support in GRUB build system Colin D Bennett
2008-08-05 15:05 ` Felix Zielcke
2008-08-05 15:11   ` Colin D Bennett
2008-08-05 15:23     ` Felix Zielcke
2008-08-05 20:14 ` Robert Millan
2008-08-05 20:50   ` Colin D Bennett
2008-08-05 21:54     ` Robert Millan
2008-08-07  0:26       ` Isaac Dupree
2008-08-07  7:37       ` Felix Zielcke
2008-08-07 15:50         ` Colin D Bennett
2008-08-07 16:07           ` Robert Millan
2008-08-07 17:43             ` Colin D Bennett

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.