.. | .. |
---|
15 | 15 | import os |
---|
16 | 16 | import re |
---|
17 | 17 | |
---|
18 | | -from linux import modules |
---|
| 18 | +from linux import modules, utils |
---|
19 | 19 | |
---|
20 | 20 | |
---|
21 | 21 | if hasattr(gdb, 'Breakpoint'): |
---|
.. | .. |
---|
77 | 77 | gdb.write("scanning for modules in {0}\n".format(path)) |
---|
78 | 78 | for root, dirs, files in os.walk(path): |
---|
79 | 79 | for name in files: |
---|
80 | | - if name.endswith(".ko"): |
---|
| 80 | + if name.endswith(".ko") or name.endswith(".ko.debug"): |
---|
81 | 81 | self.module_files.append(root + "/" + name) |
---|
82 | 82 | self.module_files_updated = True |
---|
83 | 83 | |
---|
84 | 84 | def _get_module_file(self, module_name): |
---|
85 | | - module_pattern = ".*/{0}\.ko$".format( |
---|
| 85 | + module_pattern = ".*/{0}\.ko(?:.debug)?$".format( |
---|
86 | 86 | module_name.replace("_", r"[_\-]")) |
---|
87 | 87 | for name in self.module_files: |
---|
88 | 88 | if re.match(module_pattern, name) and os.path.exists(name): |
---|
.. | .. |
---|
117 | 117 | module_file = self._get_module_file(module_name) |
---|
118 | 118 | |
---|
119 | 119 | if module_file: |
---|
| 120 | + if utils.is_target_arch('s390'): |
---|
| 121 | + # Module text is preceded by PLT stubs on s390. |
---|
| 122 | + module_arch = module['arch'] |
---|
| 123 | + plt_offset = int(module_arch['plt_offset']) |
---|
| 124 | + plt_size = int(module_arch['plt_size']) |
---|
| 125 | + module_addr = hex(int(module_addr, 0) + plt_offset + plt_size) |
---|
120 | 126 | gdb.write("loading @{addr}: {filename}\n".format( |
---|
121 | 127 | addr=module_addr, filename=module_file)) |
---|
122 | 128 | cmdline = "add-symbol-file {filename} {addr}{sections}".format( |
---|
.. | .. |
---|
140 | 146 | saved_states.append({'breakpoint': bp, 'enabled': bp.enabled}) |
---|
141 | 147 | |
---|
142 | 148 | # drop all current symbols and reload vmlinux |
---|
| 149 | + orig_vmlinux = 'vmlinux' |
---|
| 150 | + for obj in gdb.objfiles(): |
---|
| 151 | + if obj.filename.endswith('vmlinux'): |
---|
| 152 | + orig_vmlinux = obj.filename |
---|
143 | 153 | gdb.execute("symbol-file", to_string=True) |
---|
144 | | - gdb.execute("symbol-file vmlinux") |
---|
| 154 | + gdb.execute("symbol-file {0}".format(orig_vmlinux)) |
---|
145 | 155 | |
---|
146 | 156 | self.loaded_modules = [] |
---|
147 | 157 | module_list = modules.module_list() |
---|