Skip to content

GDB script fixes and improvements

Glenn Washburn grub-devel 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest14 patches 3 repliesIn review
  2. v514 patches 0 repliesSuperseded
  3. v415 patches 15 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v315 patches0 repliesSuperseded
v215 patches2 repliesSuperseded
v18 patches0 repliesSuperseded

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14gdb: Fix redirection issue in dump_module_sectionsgrub-core/gdb_grub.in+5 -100 replies
2/14gdb: Prevent wrapping when writing to .segments.tmpgrub-core/gdb_grub.in+4 -00 replies
3/14gdb: If no modules have been loaded, do not try to load module symbolsgrub-core/gdb_grub.in+3 -10 replies
4/14gdb: Move runtime module loading into runtime_load_modulegrub-core/gdb_grub.in+13 -70 replies
5/14gdb: Conditionally run GDB script logic for dynamically or statically positioned GRUBgrub-core/gdb_grub.in+16 -30 replies
6/14gdb: Only connect to remote target once when first sourcedgrub-core/gdb_grub.in+11 -80 replies
7/14gdb: Replace module symbol loading implementation with Python onegrub-core/Makefile.core.def grub-core/gdb_grub.in grub-core/gdb_helper.py.in +1 more+87 -830 replies
8/14gdb: Add functions to make loading from dynamically positioned targets easiergrub-core/gdb_grub.in grub-core/gdb_helper.py.in+107 -10 replies
9/14gdb: Add more support for debugging on EFI platformsconfig.h.in configure.ac grub-core/Makefile.core.def +5 more+107 -43 replies
10/14gdb: Allow running user-defined commands at GRUB startgrub-core/gdb_grub.in+30 -00 replies
11/14gdb: Fix issue with breakpoints defined before the GRUB image is loadedgrub-core/gdb_grub.in+27 -60 replies
12/14gdb: Add extra early initialization symbols for i386-pcgrub-core/gdb_grub.in+6 -00 replies
13/14gdb: Modify gdb prompt when running gdb_grub scriptgrub-core/gdb_helper.py.in+4 -00 replies
14/14docs: Add debugging chapter to development documentationdocs/grub-dev.texi+233 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v6 yet.

Read the v6 thread

Cover letter [PATCH v6 00/14] GDB script fixes and improvements

Update since v5:
* Need to declare grub_efi_print_gdb_info() as static and inline, which fixes a compiler error.

This series has been substantially rewritten since v4, although a large minority of the patches haven't changed much. The biggest change is that the implementation has been converted to Python instead of what was done in shell script. I have always felt it should be done in Python, but it seemed daunting to learn the Python-GDB API, so the shell script seemed the path of least resistance. I decided to give it a second look and was surprised it wasn't as bad as I thought it would be. Because the python API is so tightly integrated into GDB, there are things you can do with it that either aren't possible or which look like ugly hacks when attempting with the native script.

The other big change is that there is a new --enable-efi-debug option to configure which enables the printing of the gdb command for loading the GRUB kernel symbols. This is disallowed when booting with Secure Boot on. There are two ways the GDB command is printed: (1) in early EFI setup and
(2) on-demand by a user using the gdbinfo command.

There are a couple new features to the GDB script, like a trivial one that changes the gdb prompt and another that allows for software breakpoints to be set before the GRUB image is loaded.

This series also incorporates suggestions given for v4 and adds more to the documentation.

Glenn

Glenn Washburn (14):
gdb: Fix redirection issue in dump_module_sections
gdb: Prevent wrapping when writing to .segments.tmp
gdb: If no modules have been loaded, do not try to load module symbols
gdb: Move runtime module loading into runtime_load_module
gdb: Conditionally run GDB script logic for dynamically or statically
positioned GRUB
gdb: Only connect to remote target once when first sourced
gdb: Replace module symbol loading implementation with Python one
gdb: Add functions to make loading from dynamically positioned targets
easier
gdb: Add more support for debugging on EFI platforms
gdb: Allow running user-defined commands at GRUB start
gdb: Fix issue with breakpoints defined before the GRUB image is
loaded
gdb: Add extra early initialization symbols for i386-pc
gdb: Modify gdb prompt when running gdb_grub script
docs: Add debugging chapter to development documentation

 config.h.in                 |   3 +
 configure.ac                |  11 ++
 docs/grub-dev.texi          | 233 ++++++++++++++++++++++++++++++++++++
 grub-core/Makefile.core.def |   5 +-
 grub-core/gdb_grub.in       | 159 +++++++++++++++---------
 grub-core/gdb_helper.py.in  | 173 ++++++++++++++++++++++++++
 grub-core/gmodule.pl.in     |  30 -----
 grub-core/kern/efi/debug.c  |  40 +++++++
 grub-core/kern/efi/efi.c    |   4 +-
 grub-core/kern/efi/init.c   |   7 +-
 include/grub/efi/debug.h    |  43 +++++++
 include/grub/efi/efi.h      |   2 +-
 12 files changed, 620 insertions(+), 90 deletions(-)
 create mode 100644 grub-core/gdb_helper.py.in
 delete mode 100644 grub-core/gmodule.pl.in
 create mode 100644 grub-core/kern/efi/debug.c
 create mode 100644 include/grub/efi/debug.h

Range-diff against v5:

 1:  9f273b8fa5 =  1:  ef2b93c7df gdb: Fix redirection issue in dump_module_sections
 2:  85f68a8369 =  2:  fafc15ba07 gdb: Prevent wrapping when writing to .segments.tmp
 3:  88b3973cdb =  3:  9a8bc8c099 gdb: If no modules have been loaded, do not try to load module symbols
 4:  3037c1da91 =  4:  81eef1558d gdb: Move runtime module loading into runtime_load_module
 5:  f6288016f6 =  5:  835f19b2a3 gdb: Conditionally run GDB script logic for dynamically or statically positioned GRUB
 6:  da13fbe653 =  6:  ea32a6d83e gdb: Only connect to remote target once when first sourced
 7:  8e6059955a =  7:  13a5e05cd9 gdb: Replace module symbol loading implementation with Python one
 8:  878900d69b =  8:  c918d24d35 gdb: Add functions to make loading from dynamically positioned targets easier
 9:  036549604d !  9:  fd6d2a3ffd gdb: Add more support for debugging on EFI platforms
    @@ include/grub/efi/debug.h (new)
     +
     +void grub_efi_register_debug_commands (void);
     +
    -+void
    ++static inline void
     +grub_efi_print_gdb_info (void)
     +{
     +#if PRINT_GDB_SYM_LOAD_CMD
10:  0000959b2f = 10:  649bfc0a4d gdb: Allow running user-defined commands at GRUB start
11:  ac9f52b1d9 = 11:  8e9148a32b gdb: Fix issue with breakpoints defined before the GRUB image is loaded
12:  eac4405ffb = 12:  eb5f1b5d89 gdb: Add extra early initialization symbols for i386-pc
13:  e58715e227 = 13:  0e85de3667 gdb: Modify gdb prompt when running gdb_grub script
14:  1979dc664e = 14:  d78a1b27f0 docs: Add debugging chapter to development documentation
Signature · 1 line
2.34.1