[PATCH 2/3] scripts/gdb: add lx_lowcore convenience function on s390

Jens Remus posted 3 patches 2 months ago
[PATCH 2/3] scripts/gdb: add lx_lowcore convenience function on s390
Posted by Jens Remus 2 months ago
lx_lowcore is a convenience function to retrieve the lowcore of the
active context or a specific CPU on s390.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
 scripts/gdb/linux/cpus.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py
index 12bf37d6a4e5..3e17550cd577 100644
--- a/scripts/gdb/linux/cpus.py
+++ b/scripts/gdb/linux/cpus.py
@@ -258,3 +258,20 @@ def s390_lowcore(cpu):
 
     lowcore_ptr_type = gdb.lookup_type("struct lowcore").pointer()
     return lowcore.cast(lowcore_ptr_type)
+
+
+class LxLowcoreFunc(gdb.Function):
+    """Return current s390 lowcore.
+
+$lx_lowcore([CPU]): Return the s390 lowcore for the given CPU number.
+If CPU is omitted, the CPU of the current context is used."""
+
+    def __init__(self):
+        super(LxLowcoreFunc, self).__init__("lx_lowcore")
+
+    def invoke(self, cpu=-1):
+        return s390_lowcore(cpu)
+
+
+if constants.LX_CONFIG_S390:
+    LxLowcoreFunc()
-- 
2.51.0