All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Print out load addresses for .text and .data
@ 2021-10-11 18:48 Robbie Harwood
  2021-10-11 18:48 ` [PATCH 1/2] Add grub_qdprintf() - grub_dprintf() without the file+line number Robbie Harwood
  2021-10-11 18:48 ` [PATCH 2/2] Make a "gdb" dprintf that tells us load addresses Robbie Harwood
  0 siblings, 2 replies; 16+ messages in thread
From: Robbie Harwood @ 2021-10-11 18:48 UTC (permalink / raw)
  To: grub-devel; +Cc: Robbie Harwood

Hi,

These patches display (in format that can be copy/pasted to gdb) the virtual
addresses of grub-core/kernel.exec (and any modules it loads).

First patch is prep work - adds a print without numbering.  The second patch
is better with this call, since it makes copy/pasting easier.

(These have been downstream for just over six years now.)

Be well,
--Robbie

Peter Jones (2):
  Add grub_qdprintf() - grub_dprintf() without the file+line number.
  Make a "gdb" dprintf that tells us load addresses.

 grub-core/kern/dl.c       | 50 +++++++++++++++++++++++++++++++++++++++
 grub-core/kern/efi/efi.c  |  4 ++--
 grub-core/kern/efi/init.c | 26 +++++++++++++++++++-
 grub-core/kern/misc.c     | 18 ++++++++++++++
 include/grub/efi/efi.h    |  2 +-
 include/grub/misc.h       |  2 ++
 6 files changed, 98 insertions(+), 4 deletions(-)

-- 
2.33.0



^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] Make a "gdb" dprintf that tells us load addresses.
@ 2021-10-16 17:48 Michael Schierl
  2021-10-18 20:29 ` Glenn Washburn
  0 siblings, 1 reply; 16+ messages in thread
From: Michael Schierl @ 2021-10-16 17:48 UTC (permalink / raw)
  To: grub-devel; +Cc: rharwood, development

Glenn Washburn <development@efficientek.com> writes:
> Robbie Harwood <rharwood@redhat.com> wrote:
>
> They turn on debug=all because they don't know in what conditional(s)
> would give them useful debug information. This will spew a lot of debug
> messages to the screen, including the messages output by this patch.

BTDT.

> message by conditional, allows the user to iteratively pare down debug
> log messages so that the ones of value have a greater likelihood of
> being on the limited screen realestate. This would look like, for
> example:
>
>   set debug=all,-gdb,-disk,-lexer,-alloc

I would second that.

> Now the patch as is does not show the file:line prefix, and wouldn't
> show the conditional after my patch. So the user has no way of knowing
> what conditional should be used to disable the gdb output.

In fact, is there even a sensible scenario where having these messages
included when debug=all is set? I generally use debug=all to get some
first idea about which driver/device may be causing the boot failure,
and module load addresses will never help with that.

Maybe do not trigger this message on debug=all, or use a completely
different environment variable?

I am also unaware how exactly to debug grub in gdb on various platforms,
do you need special build flags for it? If yes, this functionality could
be limited to that build flags. Especially since if I did not miss
anything, this patch only provides value for efi platform (in an obscure
edge case, from my point of view), yet increases core image size for all
platforms.

> On the otherhand, since you're able to copy paste, I'm guessing you're
> on a serial line or VM and not on in the situation I'm describing. In
> which case, without the proposed "\n" modification, having the file:line
> prefix is an extremely minor inconvenience (you'll have to find the
> start of the add-symbol-file, which won't be at the beginning of the
> line). And you can copy-paste, you likely can search that output
> anyway.

I presume that typical GRUB loads will load dozens of modules, resulting
in dozens of debug outputs, which may often end up on adjacent lines. In
case of a line prefix, you would need to use sed (or some block editor
features) to get rid of the prefixes. In case of a newline after the
debug message, one would need to use grep (or remove every second line
from the output).

> Why do I care? I've been that guy trying to figure out a boot issue
> with too much noise in the debug log messages pushing the messages I
> needed to see off the screen (and the source wasn't readily available).
> And no pager is not always an option if you have hundreds of pages of
> log messages to scroll through, it takes forever.

As I have been in the same situation before, too, I second that. I would
also like a feature so that debug messages (or all output) get spewn
into a file (overwriting existing bytes similar to how grub_env works,
acting like a ring buffer on the file). So you could boot some recovery
envionment to create a sufficiently large file, set debug=all, let debug
logs write into that file, and then analyze them after another reboot
into said environment. Or when GRUB is booted from a USB key, the file
can be created/analyzed on another machine.

This may not help if nothing boots on that machine, but in my experience
there is either some non-Linux operating system already installed on
that machine that fails to boot Linux from GRUB, or at least a recovery
environment from another OS can be booted.

> I don't think we need to agree (that is for you to agree that the issue
> I'm describing is something to be concerned about). However, like I
> said, I think we can both be satisfied by not leaving out the file:line
> and to prepend "\n" to "add-symbol-file" so that it will start on a new
> line. So I'll ask again. Is my proposal an acceptable modification for
> the need that you have?

Another way (if possible, I don't know GRUB internals enough) would be
to provide a module similar to lsmod that shows this output for all
loaded modules. Users could load it if they want to use gdb and invoke
it during their debug session. Then copy&paste the output in one single
block.


Regards,


Michael


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

end of thread, other threads:[~2021-10-20  6:44 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-11 18:48 [PATCH 0/2] Print out load addresses for .text and .data Robbie Harwood
2021-10-11 18:48 ` [PATCH 1/2] Add grub_qdprintf() - grub_dprintf() without the file+line number Robbie Harwood
2021-10-12  6:14   ` Glenn Washburn
2021-10-11 18:48 ` [PATCH 2/2] Make a "gdb" dprintf that tells us load addresses Robbie Harwood
2021-10-12  6:29   ` Glenn Washburn
2021-10-14 17:09     ` Robbie Harwood
2021-10-15 20:24       ` Glenn Washburn
2021-10-15 20:55         ` Robbie Harwood
2021-10-16  3:25           ` Glenn Washburn
2021-10-19 21:08             ` Robbie Harwood
2021-10-19 21:57               ` Glenn Washburn
2021-10-20  6:45               ` Thomas Schmitt
  -- strict thread matches above, loose matches on Subject: below --
2021-10-16 17:48 Michael Schierl
2021-10-18 20:29 ` Glenn Washburn
2021-10-18 21:04   ` Michael Schierl
2021-10-19  7:06     ` Glenn Washburn

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.