]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Fix gdb.python/py-corefile.py with m32
authorTom de Vries <tdevries@suse.de>
Mon, 5 Jan 2026 20:56:55 +0000 (21:56 +0100)
committerTom de Vries <tdevries@suse.de>
Mon, 5 Jan 2026 20:56:55 +0000 (21:56 +0100)
With target board unix/-m32 and test-case gdb.python/py-corefile.exp I run
into:
...
FAIL: $exp: test mapped files data: diff input and output one
...
due to differences like 0x0000000008048000 vs 0x08048000.

Fix this in gdb.python/py-corefile.py by detecting and handling the
ptr_size == 4 case.

Tested on x86_64-linux.

Approved-By: Andrew Burgess <aburgess@redhat.com>
PR testsuite/33728
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33728

gdb/testsuite/gdb.python/py-corefile.py

index 421f42d5630ae2b57390ef327a0863a33e64b5e0..43b6408511791f49c719344cc4812d6e9ac401a6 100644 (file)
@@ -41,9 +41,14 @@ class Mapping:
 
 
 def info_proc_mappings():
+    ptr_size = gdb.lookup_type("void").pointer().sizeof
+
     print("Mapped address spaces:")
     print("")
-    format_str = "%-18s %-18s %-18s %-18s %s "
+    if ptr_size == 4:
+        format_str = "%-10s %-10s %-10s %-10s %s "
+    else:
+        format_str = "%-18s %-18s %-18s %-18s %s "
     print(format_str % ("Start Addr", "End Addr", "Size", "Offset", "File"))
 
     core = gdb.selected_inferior().corefile
@@ -57,16 +62,23 @@ def info_proc_mappings():
     result.sort(key=lambda x: x.start)
     for r in result:
         sz = r.end - r.start
-        print(
-            format_str
-            % (
+        if ptr_size == 4:
+            t = (
+                "0x%08x" % r.start,
+                "0x%08x" % r.end,
+                "0x%-8x" % sz,
+                "0x%-8x" % r.offset,
+                "%s" % r.filename,
+            )
+        else:
+            t = (
                 "0x%016x" % r.start,
                 "0x%016x" % r.end,
                 "0x%-16x" % sz,
                 "0x%-16x" % r.offset,
                 "%s" % r.filename,
             )
-        )
+        print(format_str % t)
 
 
 class InfoProcPyMappings(gdb.Command):