Re: How to print the details of a structure inside a structure having a list_head entry.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




----- Original Message -----
> I need a help in using crash utility.
> 
> I have a structure like this
> 
> struct a {
>     ...
>     struct task_struct task;
>     ...
>     struct list_head list;
>     ...
> }
> 
> It is possible to get the address of the task structure using *-s a.task*
> option in the *list *command. But what if i want to get the value of a member
> inside task, say *task.comm*? Is it possible to make the list command to print
> to it directly?

No, not from a single "list" command.  

What you could do is redirect the output to a file, either parsing/modifying the command
output on the command line itself, or by modifying the output file, such that the end
result is a list of task_struct addresses.

Presuming your list has an external list_head structure named "starting_list_head",
and that the a.task member is a task_struct pointer (i.e., not embedded like your
example above), you could create a list of task_struct pointers like this:

 $ list -o a.list -H starting_list_head -s a.task | grep task | awk '{print $3}' > input

Or just redirect the list command output and modify the input file by hand.  

And then, for a simple example, if the input file looked like this:

  crash> cat input
  ffffffff81c13440
  ffff88021282d330
  ffff88021282dac0
  crash>

You could either to this:

  crash> task -R comm <input
  PID: 0      TASK: ffffffff81c13440  CPU: 0   COMMAND: "swapper/0"
    comm = "swapper/0\000\000\000\000\000\000", 

  PID: 0      TASK: ffff88021282d330  CPU: 1   COMMAND: "swapper/1"
    comm = "swapper/1\000\000\000\000\000\000", 

  PID: 0      TASK: ffff88021282dac0  CPU: 2   COMMAND: "swapper/2"
    comm = "swapper/2\000\000\000\000\000\000", 

  crash>

or this:

  crash> struct task_struct.comm <junk
    comm = "swapper/0\000\000\000\000\000\000"
    comm = "swapper/1\000\000\000\000\000\000"
    comm = "swapper/2\000\000\000\000\000\000"
  crash> 

Or you could put the crash command in the input file itself:

  crash> cat input
  task_struct.comm ffffffff81c13440
  task_struct.comm ffff88021282d330
  task_struct.comm ffff88021282dac0
  crash>

and then do this:

  crash> < input
  crash> task_struct.comm ffffffff81c13440
    comm = "swapper/0\000\000\000\000\000\000"
  crash> task_struct.comm ffff88021282d330
    comm = "swapper/1\000\000\000\000\000\000"
  crash> task_struct.comm ffff88021282dac0
    comm = "swapper/2\000\000\000\000\000\000"
  crash>

That's about as automated as it can be.

Dave

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




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux