[Crash-utility] Fix for kmem -p

David Wilder dwilder at us.ibm.com
Fri Feb 17 19:30:27 UTC 2006


The struct page has been changed to use an unnamed struct inside a 
union.  Gdb can't determine the offset of members of this unnamed 
structure.  This broke the kmem -p command in crash.    I am pursuing a 
fix from the gdb folks, but I am not convinced they will accept this as 
a bug:)   In this patch, if the offset of page->mapping can't be found 
directly I calculate it.  If the order of the elements in struct page 
should change this will break again, but I cant figure out what else to do.

-------------
gdb has a problem with unnamed structures in a union.  The offset for 
page->mapping can't be found breaking the "kmem -p" command.  I use a 
alternate way to find the offset.  Ugly, but works.

Signed-off-by: David Wilder <dwilder at us.ibm.com>
--- memory.c.orig       2006-02-16 16:03:17.000000000 -0800
+++ memory.c    2006-02-16 17:30:01.000000000 -0800
@@ -236,6 +236,14 @@
                MEMBER_OFFSET_INIT(page_count, "page", "_count");
        MEMBER_OFFSET_INIT(page_flags, "page", "flags");
         MEMBER_OFFSET_INIT(page_mapping, "page", "mapping");
+       /* gdb is having a problem with unnamed structures in a union
+         * The following "hack" works around this problem. */
+       if ( !VALID_MEMBER(page_mapping) ){
+               MEMBER_OFFSET_INIT(page_mapping, "page", "_mapcount");
+               ASSIGN_OFFSET(page_mapping) =
+                       MEMBER_OFFSET("page","_mapcount") +
+                       MEMBER_SIZE("struct page","_mapcount");
+       }
         MEMBER_OFFSET_INIT(page_index, "page", "index");
         MEMBER_OFFSET_INIT(page_buffers, "page", "buffers");
        MEMBER_OFFSET_INIT(page_lru, "page", "lru");

-------------------------


-- 
David Wilder
IBM Linux Technology Center
Beaverton, Oregon, USA 
dwilder at us.ibm.com
(503)578-3789




More information about the Crash-utility mailing list