2 ### Load debuging information about GNU GRUB 2 modules into GDB
3 ### automatically. Needs readelf, Perl and gmodule.pl script
5 ### Has to be launched from the writable and trusted
6 ### directory containing *.image and *.module
9 ### Lubomir Kundrak <lkudrak@skosi.org>
12 # Add section numbers and addresses to .segments.tmp
13 define dump_module_sections
16 # FIXME: save logging status
17 set logging file .segments.tmp
18 set logging redirect on
19 set logging overwrite off
22 printf "%s", $mod->name
23 set $segment = $mod->segment
25 printf " %i 0x%lx", $segment->section, $segment->addr
26 set $segment = $segment->next
31 # FIXME: restore logging status
33 document dump_module_sections
34 Gather information about module whose mod structure was
35 given for use with match_and_load_symbols
38 # Generate and execute GDB commands and delete temporary files
40 define match_and_load_symbols
41 shell perl gmodule.pl <.segments.tmp >.loadsym.gdb
43 shell rm -f .segments.tmp .loadsym.gdb
45 document match_and_load_symbols
46 Launch script, that matches section names with information
47 generated by dump_module_sections and load debugging info
54 dump_module_sections $arg0
55 match_and_load_symbols
58 Load debugging information for module given as argument.
61 define load_all_modules
62 set $this = grub_dl_head
64 dump_module_sections $this
65 set $this = $this->next
67 match_and_load_symbols
69 document load_all_modules
70 Load debugging information for all loaded modules.
79 # inform when module is loaded