[PATCH 8/8] gdb: Get correct mod variable value

2022-02-13 Thread Glenn Washburn
For some reason, GDB is breaking on grub_dl_add() before the function has setup its stack frame, but GDB thinks it has. So the value of mod is bogus. To get the correct value, create a one-time break on grub_dl_get(), which is the first line of grub_dl_add(). When this break point hits, grub_dl_add

[PATCH 5/8] gdb: Add functions to make loading from dynamically positioned targets easier

2022-02-13 Thread Glenn Washburn
Many targets, such as EFI, load GRUB at addresses that are determined at runtime. So the load addresses in kernel.exec will almost certainly be wrong. Given the address of the start of the text and data segments, these functions will tell GDB to load the symbols at the proper locations. It is left

[PATCH 7/8] gdb: Conditionally run GDB script logic for dynamically or statically positioned GRUB

2022-02-13 Thread Glenn Washburn
There are broadly two classes of targets to consider when loading symbols for GRUB, targets that determine where to load GRUB at runtime (dynamically positioned) and those that do not (statically positioned). For statically poisitioned targets, symbol loading is determined at link time, so nothing

[PATCH 6/8] gdb: If enabled, print line used to load EFI kernel symbols when using gdb_grub script

2022-02-13 Thread Glenn Washburn
If the macro PRINT_GDB_SYM_LOAD_CMD is non-zero, compile code which will print the command needed to load symbols for the GRUB EFI kernel. This is needed because EFI firmware determines where to load the GRUB EFI at runtime, and so the relevant addresses are not known ahead of time. The command is

[PATCH 2/8] gdb: If no modules have been loaded, do not try to load module symbols

2022-02-13 Thread Glenn Washburn
This prevents load_all_modules from failing when called before any modules have been loaded. Failures in GDB user-defined functions cause any function which called them to also fail. Signed-off-by: Glenn Washburn --- grub-core/gdb_grub.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)

[PATCH 4/8] gdb: Prevent wrapping when writing to .segments.tmp

2022-02-13 Thread Glenn Washburn
GDB logging is redirected to write .segments.tmp, which means that GDB will wrap lines longer than what it thinks is the screen width (typically 80 characters). When wrapping does occur it causes gmodule.pl to misbehave. So disable line wrapping. Signed-off-by: Glenn Washburn --- grub-core/gdb_g

[PATCH 3/8] gdb: Do not lazy load module symbols

2022-02-13 Thread Glenn Washburn
When loading module symbols, tell GDB to load them all right away. GDB by default will lazy load symbols as needed in the background. However, this process will output to GDB's stdout some messages. This fixes a bug where output from the loading process gets printed to the .segments.tmp file causin

[PATCH 0/8] GDB script fixes and improvements

2022-02-13 Thread Glenn Washburn
This is a collection of fixes and improvements mostly to the GDB script, gdb_grub. I don't think the first 4 need commnt. A major benefit added in patch #5 is the ability to properly load symbols on EFI targets given the load address for the text and data segments. This is written as a shell scrip

[PATCH 1/8] gdb: Move runtime module loading into runtime_load_module

2022-02-13 Thread Glenn Washburn
Signed-off-by: Glenn Washburn --- grub-core/gdb_grub.in | 20 +--- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/grub-core/gdb_grub.in b/grub-core/gdb_grub.in index e322d3dc1..b0e8d1ed1 100644 --- a/grub-core/gdb_grub.in +++ b/grub-core/gdb_grub.in @@ -70,16 +70,2