hc
2024-09-20 a36159eec6ca17402b0e146b86efaf76568dc353
kernel/scripts/gdb/linux/symbols.py
....@@ -15,7 +15,7 @@
1515 import os
1616 import re
1717
18
-from linux import modules
18
+from linux import modules, utils
1919
2020
2121 if hasattr(gdb, 'Breakpoint'):
....@@ -77,12 +77,12 @@
7777 gdb.write("scanning for modules in {0}\n".format(path))
7878 for root, dirs, files in os.walk(path):
7979 for name in files:
80
- if name.endswith(".ko"):
80
+ if name.endswith(".ko") or name.endswith(".ko.debug"):
8181 self.module_files.append(root + "/" + name)
8282 self.module_files_updated = True
8383
8484 def _get_module_file(self, module_name):
85
- module_pattern = ".*/{0}\.ko$".format(
85
+ module_pattern = ".*/{0}\.ko(?:.debug)?$".format(
8686 module_name.replace("_", r"[_\-]"))
8787 for name in self.module_files:
8888 if re.match(module_pattern, name) and os.path.exists(name):
....@@ -117,6 +117,12 @@
117117 module_file = self._get_module_file(module_name)
118118
119119 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)
120126 gdb.write("loading @{addr}: {filename}\n".format(
121127 addr=module_addr, filename=module_file))
122128 cmdline = "add-symbol-file {filename} {addr}{sections}".format(
....@@ -140,8 +146,12 @@
140146 saved_states.append({'breakpoint': bp, 'enabled': bp.enabled})
141147
142148 # 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
143153 gdb.execute("symbol-file", to_string=True)
144
- gdb.execute("symbol-file vmlinux")
154
+ gdb.execute("symbol-file {0}".format(orig_vmlinux))
145155
146156 self.loaded_modules = []
147157 module_list = modules.module_list()