]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scripts/gdb/symbols: factor out pagination_off()
authorIlya Leoshkevich <iii@linux.ibm.com>
Thu, 15 May 2025 15:52:12 +0000 (17:52 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 21 May 2025 17:48:24 +0000 (10:48 -0700)
Move the code that turns off pagination into a separate function.  It will
be useful later in order to prevent hangs when loading symbols for kernel
image in physical memory during s390 early boot.

Link: https://lkml.kernel.org/r/20250515155811.114392-3-iii@linux.ibm.com
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
scripts/gdb/linux/symbols.py
scripts/gdb/linux/utils.py

index 25c4627c60e5e17f339494dda54f4c5db30bfcf9..0c7af712c44c7f32d22fa0d70f46062b0fc25340 100644 (file)
@@ -38,19 +38,13 @@ if hasattr(gdb, 'Breakpoint'):
             # Disable pagination while reporting symbol (re-)loading.
             # The console input is blocked in this context so that we would
             # get stuck waiting for the user to acknowledge paged output.
-            show_pagination = gdb.execute("show pagination", to_string=True)
-            pagination = show_pagination.endswith("on.\n")
-            gdb.execute("set pagination off")
-
-            if module_name in cmd.loaded_modules:
-                gdb.write("refreshing all symbols to reload module "
-                          "'{0}'\n".format(module_name))
-                cmd.load_all_symbols()
-            else:
-                cmd.load_module_symbols(module)
-
-            # restore pagination state
-            gdb.execute("set pagination %s" % ("on" if pagination else "off"))
+            with utils.pagination_off():
+                if module_name in cmd.loaded_modules:
+                    gdb.write("refreshing all symbols to reload module "
+                              "'{0}'\n".format(module_name))
+                    cmd.load_all_symbols()
+                else:
+                    cmd.load_module_symbols(module)
 
             return False
 
index 6e125830d3f237b2bc8f2163e32d99f8683b0e79..e11f6f67961a6b4199824eda4a9f256b3574b763 100644 (file)
@@ -260,3 +260,14 @@ def get_vmlinux():
             obj.filename.endswith('vmlinux.debug')):
             vmlinux = obj.filename
     return vmlinux
+
+
+@contextlib.contextmanager
+def pagination_off():
+    show_pagination = gdb.execute("show pagination", to_string=True)
+    pagination = show_pagination.endswith("on.\n")
+    gdb.execute("set pagination off")
+    try:
+        yield
+    finally:
+        gdb.execute("set pagination %s" % ("on" if pagination else "off"))