* [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* Re: [PATCH][RFC] gdb support in GRUB build system
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 20:14 ` Robert Millan
1 sibling, 1 reply; 12+ messages in thread
From: Felix Zielcke @ 2008-08-05 15:05 UTC (permalink / raw)
To: The development of GRUB 2
Am Dienstag, den 05.08.2008, 07:42 -0700 schrieb Colin D Bennett:
> 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).
>
Well I already brought this wiki page up on here, but nobody really
cared about updating this.
I even did the same as you updateing that patch to current SVN ;)
See here:
http://lists.gnu.org/archive/html/grub-devel/2008-07/msg00585.html
http://lists.gnu.org/archive/html/grub-devel/2008-08/msg00037.html
> Let me know what you all think. Thanks!
Thanks that at least you try to that GDB + Qemu stuff easier.
Even with the patches from Lubomir from May I wasn't able to get the
symbols of the loaded modules.
I have used that load_modules function which is in the new gdb-macro
patch but it didn't work.
And the gdb-stub didn't apply and I was unsure if it was safe to just
adjust the values in the header file which was changed.
I think I'm not that good in this stuff to get it working, so it's very
nice that you want to do it now :)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][RFC] gdb support in GRUB build system
2008-08-05 15:05 ` Felix Zielcke
@ 2008-08-05 15:11 ` Colin D Bennett
2008-08-05 15:23 ` Felix Zielcke
0 siblings, 1 reply; 12+ messages in thread
From: Colin D Bennett @ 2008-08-05 15:11 UTC (permalink / raw)
To: The development of GRUB 2; +Cc: fzielcke
On Tue, 05 Aug 2008 17:05:57 +0200
Felix Zielcke <fzielcke@z-51.de> wrote:
> Am Dienstag, den 05.08.2008, 07:42 -0700 schrieb Colin D Bennett:
> > 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).
> >
> Well I already brought this wiki page up on here, but nobody really
> cared about updating this.
> I even did the same as you updateing that patch to current SVN ;)
>
> See here:
> http://lists.gnu.org/archive/html/grub-devel/2008-07/msg00585.html
> http://lists.gnu.org/archive/html/grub-devel/2008-08/msg00037.html
>
> > Let me know what you all think. Thanks!
>
> Thanks that at least you try to that GDB + Qemu stuff easier.
>
> Even with the patches from Lubomir from May I wasn't able to get the
> symbols of the loaded modules.
> I have used that load_modules function which is in the new gdb-macro
> patch but it didn't work.
> And the gdb-stub didn't apply and I was unsure if it was safe to just
> adjust the values in the header file which was changed.
>
> I think I'm not that good in this stuff to get it working, so it's
> very nice that you want to do it now :)
Interesting. Well, I think I used the 'load_all_modules' function
instead of just 'load_modules'. And IIRC, I first used the GRUB legacy
floppy image that was provided to chainload GRUB 2 over QEMU's built-in
tftp, but I think that directly booting GRUB 2 in QEMU for debugging
did not work... I'll have to try it again to verify that.
Cheers,
Colin
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][RFC] gdb support in GRUB build system
2008-08-05 15:11 ` Colin D Bennett
@ 2008-08-05 15:23 ` Felix Zielcke
0 siblings, 0 replies; 12+ messages in thread
From: Felix Zielcke @ 2008-08-05 15:23 UTC (permalink / raw)
To: The development of GRUB 2
Am Dienstag, den 05.08.2008, 08:11 -0700 schrieb Colin D Bennett:
>
> Interesting. Well, I think I used the 'load_all_modules' function
> instead of just 'load_modules'. And IIRC, I first used the GRUB legacy
> floppy image that was provided to chainload GRUB 2 over QEMU's built-in
> tftp, but I think that directly booting GRUB 2 in QEMU for debugging
> did not work... I'll have to try it again to verify that.
>
The gdb-macros patch on his fedora page[0] has only load_modules where
the help text of it says it loads all symbols.
I didn't try the chainload grub2 with tftp way.
I have used directly a grub2 floppy img for that and it did work for the
functions not in a module.
I didn't make anything special, just recompiled grub2 with that page, we
both updated, and CFLAGS="-O0 -g3"
and then created the grub2_floppy.img
[0] http://fedorapeople.org/~lkundrak/grub2/
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][RFC] gdb support in GRUB build system
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 20:14 ` Robert Millan
2008-08-05 20:50 ` Colin D Bennett
1 sibling, 1 reply; 12+ messages in thread
From: Robert Millan @ 2008-08-05 20:14 UTC (permalink / raw)
To: The development of GRUB 2
On Tue, Aug 05, 2008 at 07:42:29AM -0700, Colin D Bennett wrote:
>
> 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.
I'd favour the --enable-debug. Even if it's a small overhead, it becomes a
big problem when you are out of space and need to start looking around to see
what can be shaved off.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][RFC] gdb support in GRUB build system
2008-08-05 20:14 ` Robert Millan
@ 2008-08-05 20:50 ` Colin D Bennett
2008-08-05 21:54 ` Robert Millan
0 siblings, 1 reply; 12+ messages in thread
From: Colin D Bennett @ 2008-08-05 20:50 UTC (permalink / raw)
To: grub-devel
On Tue, 5 Aug 2008 22:14:03 +0200
Robert Millan <rmh@aybabtu.com> wrote:
> On Tue, Aug 05, 2008 at 07:42:29AM -0700, Colin D Bennett wrote:
> >
> > 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.
>
> I'd favour the --enable-debug. Even if it's a small overhead, it
> becomes a big problem when you are out of space and need to start
> looking around to see what can be shaved off.
In that case, should --enable-debug be the default, or --disable-debug?
Colin
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][RFC] gdb support in GRUB build system
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
0 siblings, 2 replies; 12+ messages in thread
From: Robert Millan @ 2008-08-05 21:54 UTC (permalink / raw)
To: The development of GRUB 2
On Tue, Aug 05, 2008 at 01:50:21PM -0700, Colin D Bennett wrote:
> On Tue, 5 Aug 2008 22:14:03 +0200
> Robert Millan <rmh@aybabtu.com> wrote:
>
> > On Tue, Aug 05, 2008 at 07:42:29AM -0700, Colin D Bennett wrote:
> > >
> > > 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.
> >
> > I'd favour the --enable-debug. Even if it's a small overhead, it
> > becomes a big problem when you are out of space and need to start
> > looking around to see what can be shaved off.
>
> In that case, should --enable-debug be the default, or --disable-debug?
I'd prefer to disable debug as default. What do others think?
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][RFC] gdb support in GRUB build system
2008-08-05 21:54 ` Robert Millan
@ 2008-08-07 0:26 ` Isaac Dupree
2008-08-07 7:37 ` Felix Zielcke
1 sibling, 0 replies; 12+ messages in thread
From: Isaac Dupree @ 2008-08-07 0:26 UTC (permalink / raw)
To: The development of GRUB 2
>> In that case, should --enable-debug be the default, or --disable-debug?
>
> I'd prefer to disable debug as default. What do others think?
It only creates extra files in the build, unless something
is done with them? It's not the /boot or core.img getting
expanded here. Also, if users need debugging info, it's
much more reliable to fall back on files of debugging
symbols that are already generated and match the installed
grub binary compile. Or did I get confused? I didn't think
they were incredibly huge size files either, so I'd say
enable them by default.
-Isaac
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][RFC] gdb support in GRUB build system
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
1 sibling, 1 reply; 12+ messages in thread
From: Felix Zielcke @ 2008-08-07 7:37 UTC (permalink / raw)
To: The development of GRUB 2
Am Dienstag, den 05.08.2008, 23:54 +0200 schrieb Robert Millan:
> On Tue, Aug 05, 2008 at 01:50:21PM -0700, Colin D Bennett wrote:
> > In that case, should --enable-debug be the default, or --disable-debug?
>
> I'd prefer to disable debug as default. What do others think?
>
Have it disabled by default.
I don't think it's useful to have them for everyone i.e. the average
user.
What do they gain with it?
If you want to debug real grub you need qemu/bochs and gdb isn't that
easy (for the avera users)
Ok maybe I think still more like a Windows guy and not a Linux one, but
with Opensuse and Ubuntu I think Linux gets more attractive to people
who aren't that experts as we are here on the list :)
Why should we waste a bit of space by default for every Linux
distribution?
I doubt they all figure out that they can just disable it on creating
there .rpm etc.
And I doubt Robert is disabling this for the Debian build if it's by
default enabled on upstream ;)
For debugging it's always the best if you compile with -O0 too and this
shouldn't really be the default.
For the few people who need to debug real grub it shouldn't be too hard
to just recompile it with `CFLAGS="-g3 -O0" ./configure --enable-debug'
Having debug symbols in the userland tools could be maybe a bit useful
for example in the case of the grub-probe segfault I experienced on my
mdraid experiments.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][RFC] gdb support in GRUB build system
2008-08-07 7:37 ` Felix Zielcke
@ 2008-08-07 15:50 ` Colin D Bennett
2008-08-07 16:07 ` Robert Millan
0 siblings, 1 reply; 12+ messages in thread
From: Colin D Bennett @ 2008-08-07 15:50 UTC (permalink / raw)
To: grub-devel
On Thu, 07 Aug 2008 09:37:22 +0200
Felix Zielcke <fzielcke@z-51.de> wrote:
> Am Dienstag, den 05.08.2008, 23:54 +0200 schrieb Robert Millan:
> > On Tue, Aug 05, 2008 at 01:50:21PM -0700, Colin D Bennett wrote:
> > > In that case, should --enable-debug be the default, or
> > > --disable-debug?
> >
> > I'd prefer to disable debug as default. What do others think?
> >
> Have it disabled by default.
> I don't think it's useful to have them for everyone i.e. the average
> user.
I agree that having debug info for the installed GRUB is not helpful,
especially for the general end-user. So files installed by the GRUB
install process certainly don't need debugging symbols.
My concern was only to generate the required symbol information at
build time, not to install it for a real GRUB install, or to package
these files for distribution in .rpm, .deb, etc.
I don't really care if it's the default or not since I can simply
choose my configure options as necessary for the task at hand. If I
have a debugging situation, then I can rebuild with debug info, since
I'd have to re-start the GRUB/QEMU session anyway to begin debugging.
(And I don't use the ridiculously slow QEMU for most stuff anyway.)
> Having debug symbols in the userland tools could be maybe a bit useful
> for example in the case of the grub-probe segfault I experienced on my
> mdraid experiments.
True, in that case it makes sense to include debug info (if a
distro's other packages include it), since a core dump could be used to
debug, or if core dumps aren't enabled, then you could simply re-run it
with 'gdb grub-probe' to try to recreate the problem. This doesn't
require the whole QEMU virtual machine situation that debugging the
GRUB boot loader itself requires.
Regards,
Colin
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][RFC] gdb support in GRUB build system
2008-08-07 15:50 ` Colin D Bennett
@ 2008-08-07 16:07 ` Robert Millan
2008-08-07 17:43 ` Colin D Bennett
0 siblings, 1 reply; 12+ messages in thread
From: Robert Millan @ 2008-08-07 16:07 UTC (permalink / raw)
To: The development of GRUB 2
On Thu, Aug 07, 2008 at 08:50:45AM -0700, Colin D Bennett wrote:
> > Having debug symbols in the userland tools could be maybe a bit useful
> > for example in the case of the grub-probe segfault I experienced on my
> > mdraid experiments.
>
> True, in that case it makes sense to include debug info
Agreed. Furthermore, Debian packaging environment _expects_ packages to
include debug info by default; this allows us (Debian) to define a common
variable interface to enable/disable debug symbols by toggling the scripts
that run strip after the build.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH][RFC] gdb support in GRUB build system
2008-08-07 16:07 ` Robert Millan
@ 2008-08-07 17:43 ` Colin D Bennett
0 siblings, 0 replies; 12+ messages in thread
From: Colin D Bennett @ 2008-08-07 17:43 UTC (permalink / raw)
To: grub-devel
On Thu, 7 Aug 2008 18:07:43 +0200
Robert Millan <rmh@aybabtu.com> wrote:
> On Thu, Aug 07, 2008 at 08:50:45AM -0700, Colin D Bennett wrote:
> > > Having debug symbols in the userland tools could be maybe a bit
> > > useful for example in the case of the grub-probe segfault I
> > > experienced on my mdraid experiments.
> >
> > True, in that case it makes sense to include debug info
>
> Agreed. Furthermore, Debian packaging environment _expects_ packages
> to include debug info by default; this allows us (Debian) to define
> a common variable interface to enable/disable debug symbols by
> toggling the scripts that run strip after the build.
Also, also Gentoo does the same thing -- the Gentoo ebuild system does
the stripping based on certain flags are set in the FEATURES variable
('nostrip' or 'splitdebug').
Regards,
Colin
^ 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.