Olivier Daudel wrote:
Hi Dave,
1) With this new patch, i think we are not far from your goals.
But i understand that to change somthing in struct, union, etc. is rather
"dangerous".
Perhaps it would be preferable to implement this attempt in an independent
module ?

The command cmd_struct(), cmd_union() and cmd_pointer() have been unified
and also "*" supports -l now.
It was not the case before (i missed something ?).
To take care of the differences between struct, union and *, we have mainely
one instruction.

2) Nothing to do with the patch, but may be there is still something wrong
with struct -o (in standard 3.8 and also in my new version):

crash> struct -o ipc_id_ary
struct ipc_id_ary {
  [0] int size;
  [4] struct kern_ipc_perm *p[0];
}
SIZE: 4

We should have SIZE greater than 4 ?
 

When the array dimension is 0, it doesn't take up any space:
 

  // -------------------- junk.c ------------------------

  #include <stdio.h>

  struct junk {
          int a;
          long b;
          char *c;
  };

  struct container {
          long size;
          struct junk *empty[0];
  } example;

  main()
  {
          printf("sizeof(long): %d\n", sizeof(long));
          printf("sizeof(struct junk): %d\n", sizeof(struct junk));
          printf("sizeof(struct container): %d\n", sizeof(struct container));
          printf("sizeof(example): %d\n", sizeof(example));
  }
 

  # ./junk
  sizeof(long): 4
  sizeof(struct junk): 12
  sizeof(struct container): 4
  sizeof(example): 4
  #
 

When the kernel does its initialization, it does this in order
to allocate enough space for a variable number of kern_ipc_perm
structure pointers:

   ids->entries = ipc_rcu_alloc(sizeof(struct kern_ipc_perm *)*size +
                                sizeof(struct ipc_id_ary));

Anyway, I'll take a look at your patch, and if it looks
safe/sane and tests OK, I'll consider folding it in.

Thanks,
  Dave
 

Olivier

crash> struct inode.i_uid,i_gid,i_alloc_sem f605b31c
  i_uid = 0,
  i_gid = 5,
  i_alloc_sem = {
    count = 0,
    wait_lock = {
      slock = 1,
      magic = 3735899821,
      break_lock = 0
    },
    wait_list = {
      next = 0xf605b3c4,
      prev = 0xf605b3c4
    }
  },

I don't think, it would be very easy to have this result with grep and we
don't have the -R option
as in task... (if i am correct).

crash> struct inode.i_uid,i_gid,i_alloc_sem f605b31c 3
  i_uid = 0,
  i_gid = 5,
  i_alloc_sem = {
    count = 0,
    wait_lock = {
      slock = 1,
      magic = 3735899821,
      break_lock = 0
    },
    wait_list = {
      next = 0xf605b3c4,
      prev = 0xf605b3c4
    }
  },

  i_uid = 0,
  i_gid = 0,
  i_alloc_sem = {
    count = 0,
    wait_lock = {
      slock = 1,
      magic = 3735899821,
      break_lock = 0
    },
    wait_list = {
      next = 0xf605b53c,
      prev = 0xf605b53c
    }
  },

  i_uid = 0,
  i_gid = 0,
  i_alloc_sem = {
    count = 0,
    wait_lock = {
      slock = 1,
      magic = 3735899821,
      break_lock = 0
    },
    wait_list = {
      next = 0xf605b6b4,
      prev = 0xf605b6b4
    }
  },

crash> struct inode.i_list  f605b31c 3
  i_list = {
    next = 0xf605b49c,
    prev = 0xf7b4e1cc
  },

  i_list = {
    next = 0xf60cadb8,
    prev = 0xf605b324
  },

  i_list = {
    next = 0xf60e6458,
    prev = 0xf60e6278
  },

crash> struct inode -r  f605b31c 3
f605b31c:  00000000 00000000 f605b49c f7b4e1cc   ................
f605b32c:  f7d76bfc f6b6903c f6d8ea60 f6d8ea60   .k..<...`...`...
f605b33c:  00000002 00000001 00002190 00000001   .........!......
f605b34c:  00000000 00000005 08800000 00000000   ................
f605b35c:  00000000 453bb0ec 0606fb28 453bb0ec   ......;E(.....;E
f605b36c:  0606fb28 453ba008 2330b3e8 0000000a   (.....;E..0#....
f605b37c:  00000400 00000000 00000000 00000000   ................
f605b38c:  00000001 dead4ead 00000000 00000001   .....N..........
f605b39c:  00000000 00000001 dead4ead 00000000   .........N......
f605b3ac:  f605b3ac f605b3ac 00000000 00000001   ................
f605b3bc:  dead4ead 00000000 f605b3c4 f605b3c4   .N..............
f605b3cc:  c036d760 c036a7a0 f7d72200 00000000   `.6...6.."......
f605b3dc:  f605b3e0 f605b31c 00000000 00000220   ............ ...
f605b3ec:  00000000 01000000 deaf1eed 00000000   ................
f605b3fc:  00000000 00000000 00010001 f605b408   ................
f605b40c:  f605b408 00000001 dead4ead 00000000   .........N......
f605b41c:  00000000 00000000 00000000 c0485540   ............@UH.
f605b42c:  000000d2 c0369b88 00000001 dead4ead   ......6......N..
f605b43c:  00000000 f605b440 f605b440 00000000   ....@...@.......
f605b44c:  00000000 00000000 f7da1440 f6b69164   ........@...d...
f605b45c:  00000000 00000000 f7da1404 00000000   ................
f605b46c:  00000000 00000000 00000000 00000000   ................
f605b47c:  00000000 00000000 00000001 00000000   ................
f605b48c:  f60f9000 00000000                     ........

f605b494:  00000000 00000000 f60cadb8 f605b324   ............$...
f605b4a4:  f674832c f6b6990c f60493ac f60493ac   ,.t.............
f605b4b4:  00002544 00000001 00001180 00000001   D%..............
f605b4c4:  00000000 00000000 00000000 00000000   ................
f605b4d4:  00000000 453ba008 20ce71a8 453ba008   ......;E.q. ..;E
f605b4e4:  20ce71a8 453ba008 20ce71a8 0000000a   .q. ..;E.q. ....
f605b4f4:  00001000 00000000 00000000 00000000   ................
f605b504:  00000001 dead4ead 00000000 00000001   .....N..........
f605b514:  00000000 00000001 dead4ead 00000000   .........N......
f605b524:  f605b524 f605b524 00000000 00000001   $...$...........
f605b534:  dead4ead 00000000 f605b53c f605b53c   .N......<...<...
f605b544:  c04854e0 c036ab40 f7fcf200 00000000   .TH.@.6.........
f605b554:  f605b558 f605b494 00000000 00000220   X........... ...
f605b564:  00000000 01000000 deaf1eed 00000000   ................
f605b574:  00000000 00000000 00010001 f605b580   ................
f605b584:  f605b580 00000001 dead4ead 00000000   .........N......
f605b594:  00000000 00000000 00000000 c0485540   ............@UH.
f605b5a4:  000000d2 c0369b88 00000001 dead4ead   ......6......N..
f605b5b4:  00000000 f605b5b8 f605b5b8 00000000   ................
f605b5c4:  00000000 00000000 f605b5cc f605b5cc   ................
f605b5d4:  f7aa7400 00000000 00000000 00000000   .t..............
f605b5e4:  00000000 00000000 00000000 00000007   ................
f605b5f4:  00000000 00000000 00000000 00000000   ................
f605b604:  00000000 00000000                     ........

f605b60c:  00000000 00000000 f60e6458 f60e6278   ........Xd..xb..
f605b61c:  f605b794 f609e3ac f6067430 f6067430   ........0t..0t..
f605b62c:  000022db 00000001 00008124 00000001   ."......$.......
f605b63c:  00000000 00000000 00000000 00001000   ................
f605b64c:  00000000 453b9fe3 292fe200 453b9fe3   ......;E../)..;E
f605b65c:  292fe200 453b9fe3 292fe200 0000000c   ../)..;E../)....
f605b66c:  00001000 00000000 00000000 00000000   ................
f605b67c:  00000001 dead4ead 00000000 00000001   .....N..........
f605b68c:  00000000 00000001 dead4ead 00000000   .........N......
f605b69c:  f605b69c f605b69c 00000000 00000001   ................
f605b6ac:  dead4ead 00000000 f605b6b4 f605b6b4   .N..............
f605b6bc:  c04854e0 c036d400 f7eaf400 00000000   .TH...6.........
f605b6cc:  f605b6d0 f605b60c 00000000 00000220   ............ ...
f605b6dc:  00000000 01000000 deaf1eed 00000000   ................
f605b6ec:  00000000 00000000 00010001 f605b6f8   ................
f605b6fc:  f605b6f8 00000001 dead4ead 00000000   .........N......
f605b70c:  00000000 00000000 00000000 c036d380   ..............6.
f605b71c:  000000d2 c036d3b0 00000001 dead4ead   ......6......N..
f605b72c:  00000000 f605b730 f605b730 00000000   ....0...0.......
f605b73c:  00000000 00000000 f605b744 f605b744   ........D...D...
f605b74c:  00000000 00000000 00000000 00000000   ................
f605b75c:  00000000 00000000 00000000 00000000   ................
f605b76c:  00000000 00000000 00000000 00000000   ................
f605b77c:  00000000 00000000                     ........

If you correlate the dump with the previous display, i think the dump is
correct.

crash> ps 1
   PID    PPID  CPU   TASK    ST  %MEM     VSZ    RSS  COMM
      1      0   0  f7e8caa0  IN   0.0       0      0  init
crash> struct task_struct.sibling
struct task_struct {
   [176] struct list_head sibling;
}
crash> struct task_struct.pid,tgid,pending -l task_struct.sibling 0xf7e8c0d0
  pid = 2,
  tgid = 2,
  pending = {
    list = {
      next = 0xf7e8c494,
      prev = 0xf7e8c494
    },
    signal = {
      sig = {0, 0}
    }
  },

crash> struct task_struct.pid,tgid,pending -l 176 0xf7e8c0d0
  pid = 2,
  tgid = 2,
  pending = {
    list = {
      next = 0xf7e8c494,
      prev = 0xf7e8c494
    },
    signal = {
      sig = {0, 0}
    }
  },

I don't think you can do that with task (-l not supported)

crash> * task_struct.pid,tgid,pending -l 176 0xf7e8c0d0
  pid = 2,
  tgid = 2,
  pending = {
    list = {
      next = 0xf7e8c494,
      prev = 0xf7e8c494
    },
    signal = {
      sig = {0, 0}
    }
  },

  ------------------------------------------------------------------------------------------------------------------------
                    Name: symbols.patch
   symbols.patch    Type: unspecified type (application/octet-stream)
                Encoding: quoted-printable

  ------------------------------------------------------------------------------------------------------------------------
--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility