[Crash-utility] Retrieve pointer value for scripting

Louis Bouchard louis.bouchard at canonical.com
Fri Dec 6 09:23:40 UTC 2013


Bonjour Patrick,

Le 06/12/2013 10:02, Patrick Agrain a écrit :
> Hello,
> 
> We wish to call 'crash' with a script file to automate some basic command and
> output the result on a text file.
> 
> This works perfectly for basic commands such as bt, log, mod and so on,
> especially when no input data is required.
> 
> We try now to dump the kernel stack through a 'rd <@> <size>'.
> My problem is to "extract" this <@> and to "input" it in this 'rd' command.
> 
> For the moment, I'm able to get the task_struct * with following command :
> ps | grep '>' | awk '{ print $5 };'
> 
> From that, the pointer of the thread_info would be available through
> (task_struct *)->stack.
> 
> But how to get all these together to finally ouptut a valid 'rd' command ?
> Meaby another way to get this kernel stack dump would exist ?
> 
> Any help would be appreciate.
> Regards,
> Patrick Agrain
> 
> -- 
> Crash-utility mailing list
> Crash-utility at redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility

I did that kind of work a few years ago as the crashdc project :

http://crashdc.sourceforge.net/

The project is now dormant (elegant way of saying abandoned) but everything in
there is still valid, so you might be able to reuse some of it.

One of the most efficient way I found to work on specific address is to output
to a file from within crash, work a list of command from that file output and
feed back crash with this list.

A quick example would go like that. If you want active.mm.mm_count for each task
you could do :

crash> foreach task | grep active_mm | awk '{print "* mm_struct.mm_count ",$3}'
> tempfile
crash> head -1 tempfile
* mm_struct.mm_count  0xffff880c46af9880,
crash> < tempfile
crash> * mm_struct.mm_count  0xffff880c46af9880,
  mm_count = {
    counter = 0x4
  }
...

I'd be happy to get suggestions from others as well.

Kind regards,

...Louis



-- 
Louis Bouchard
Software engineer, Cloud & Sustaining eng.
Canonical Ltd
Ubuntu support: http://canonical.com/support




More information about the Crash-utility mailing list