[Crash-utility] [PATCH 1/1] Resend CLI list command, print deep structure members

Dave Anderson anderson at redhat.com
Tue May 19 16:14:49 UTC 2015



----- Original Message -----
> Hi Dave,
> 
> my bad.
> 
> Since you've made some simplifications in my patch, I hope it's ok to make
> short patch.

Hi Alex,

I've run into three problems dealing with embedded arrays.

First, should array elements inside an embedded structure be 
selectable?  For example, the task_struct has an embedded 
task_rss_stat structure:

  crash> task_struct.rss_stat
  struct task_struct {
     [456] struct task_rss_stat rss_stat;
  }

that contains a "count" array:

  crash> task_rss_stat
  struct task_rss_stat {
      int events;
      int count[3];
  }
  SIZE: 16

I can display the whole thing:

  crash> task -R rss_stat
  PID: 11722  TASK: ffff8801073da5d0  CPU: 0   COMMAND: "crash"
    rss_stat = {
      events = 11, 
      count = {0, 0, 0}
    }, 
  
Or break it down into its two members, individually or both at the same time:

  crash> task -R rss_stat.events
  PID: 11722  TASK: ffff8801073da5d0  CPU: 1   COMMAND: "crash"
    rss_stat.events = 13,
  
  crash> task -R rss_stat.count
  PID: 11722  TASK: ffff8801073da5d0  CPU: 1   COMMAND: "crash"
    rss_stat.count = {0, 0, 0}

  crash> task -R rss_stat.events,rss_stat.count
  PID: 11722  TASK: ffff8801073da5d0  CPU: 1   COMMAND: "crash"
    rss_stat.events = 14,
    rss_stat.count = {0, 0, 0}

But trying to access a member of the rss_stat.count[] array fails:
  
  crash> task -R rss_stat.count[1]
  PID: 11722  TASK: ffff8801073da5d0  CPU: 2   COMMAND: "crash"
  task: invalid structure member reference: rss_stat.count[1]
  crash> 

Is that expected behavior?



Secondly, on a somewhat related note, this seems strange.  The 
task_struct has an embedded array of 3 pid_link structures:
  
  crash> task_struct.pids
  struct task_struct {
     [608] struct pid_link pids[3];
  }

Here they are all dumped:

  crash> task -R pids
  PID: 11722  TASK: ffff8801073da5d0  CPU: 2   COMMAND: "crash"
    pids = {{
        node = {
          next = 0x0, 
          pprev = 0xffff880105fc9888
        }, 
        pid = 0xffff880105fc9880
      }, {
        node = {
          next = 0xffff880209d01198, 
          pprev = 0xffff880209d05d38
        }, 
        pid = 0xffff88000eeefd00
      }, {
        node = {
          next = 0xffff880209d011b0, 
          pprev = 0xffff880209d05d50
        }, 
        pid = 0xffff88010d07ed00
      }}, 

Or I can pick just one member of the array:
  
  crash> task -R pids[1]
  PID: 11722  TASK: ffff8801073da5d0  CPU: 0   COMMAND: "crash"
    pids[1] =   {
      node = {
        next = 0xffff880209d01198,
        pprev = 0xffff880209d02848
      },
      pid = 0xffff88000eeefd00
    },
  
And refine it further by asking for just the "node" member:

  crash> task -R pids[1].node
  PID: 11722  TASK: ffff8801073da5d0  CPU: 0   COMMAND: "crash"
    pids[1].node = {
      next = 0xffff880209d01198,
      pprev = 0xffff880209d02848
    },
  
But for some reason, it fails to accept the "pid_link.pid" member:

  crash> task -R pids[1].pid
  PID: 11722  TASK: ffff8801073da5d0  CPU: 0   COMMAND: "crash"
  task: invalid structure member reference: pids[1].pid



And third, this behavior also doesn't seem correct.  Here again I select
just the first element of the task_struct.pids[] array:
  
  crash> task -R pids[0].node
  PID: 11722  TASK: ffff8801073da5d0  CPU: 2   COMMAND: "crash"
    pids[0].node = {
      next = 0x0,
      pprev = 0xffff880105fc9888
    },
  
But it allows me to leave off the "pids[x]" reference, and if so, it defaults
to the first member of the array:

  crash> task -R pids.node
  PID: 11722  TASK: ffff8801073da5d0  CPU: 0   COMMAND: "crash"
    pids.node = {
      next = 0x0,
      pprev = 0xffff880105fc9888
    },
  
Should it reject that syntax?

Dave





More information about the Crash-utility mailing list