]>
Commit | Line | Data |
---|---|---|
2536cf64 LK |
1 | ### |
2 | ### Load debuging information about GNU GRUB 2 modules into GDB | |
3 | ### automatically. Needs readelf, Perl and gmodule.pl script | |
4 | ### | |
80a71213 VS |
5 | ### Has to be launched from the writable and trusted |
6 | ### directory containing *.image and *.module | |
7 | ### | |
2536cf64 LK |
8 | ### $Id: .gdbinit,v 1.1 2006/05/14 11:38:08 lkundrak Exp $ |
9 | ### Lubomir Kundrak <lkudrak@skosi.org> | |
10 | ### | |
11 | ||
12 | # Add section numbers and addresses to .segments.tmp | |
13 | define dump_module_sections | |
14 | set $mod = $arg0 | |
15 | ||
16 | # FIXME: save logging status | |
17 | set logging file .segments.tmp | |
18 | set logging redirect on | |
19 | set logging overwrite off | |
20 | set logging on | |
21 | ||
22 | printf "%s", $mod->name | |
23 | set $segment = $mod->segment | |
24 | while ($segment) | |
dac86b18 | 25 | printf " %i 0x%lx", $segment->section, $segment->addr |
2536cf64 LK |
26 | set $segment = $segment->next |
27 | end | |
28 | printf "\n" | |
29 | ||
30 | set logging off | |
31 | # FIXME: restore logging status | |
32 | end | |
33 | document dump_module_sections | |
34 | Gather information about module whose mod structure was | |
35 | given for use with match_and_load_symbols | |
36 | end | |
37 | ||
38 | # Generate and execute GDB commands and delete temporary files | |
39 | # afterwards | |
40 | define match_and_load_symbols | |
41 | shell perl gmodule.pl <.segments.tmp >.loadsym.gdb | |
42 | source .loadsym.gdb | |
43 | shell rm -f .segments.tmp .loadsym.gdb | |
44 | end | |
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 | |
48 | apropriately | |
49 | end | |
50 | ||
51 | ### | |
52 | ||
53 | define load_module | |
54 | dump_module_sections $arg0 | |
55 | match_and_load_symbols | |
56 | end | |
57 | document load_module | |
58 | Load debugging information for module given as argument. | |
59 | end | |
60 | ||
61 | define load_all_modules | |
62 | set $this = grub_dl_head | |
63 | while ($this != 0) | |
dac86b18 | 64 | dump_module_sections $this |
2536cf64 LK |
65 | set $this = $this->next |
66 | end | |
67 | match_and_load_symbols | |
68 | end | |
69 | document load_all_modules | |
70 | Load debugging information for all loaded modules. | |
71 | end | |
72 | ||
73 | ### | |
74 | ||
75 | set confirm off | |
76 | file kernel.exec | |
77 | target remote :1234 | |
78 | ||
79 | # inform when module is loaded | |
80 | break grub_dl_add | |
81 | commands | |
82 | silent | |
83 | load_module mod | |
84 | cont | |
85 | end |