FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Crash Utility

 
 
LinkBack Thread Tools
 
Old 03-07-2012, 05:48 PM
"Luc Chouinard"
 
Default How to use scripts in crash?

> -----Original Message-----
> From: crash-utility-bounces@redhat.com [mailto:crash-utility-
> bounces@redhat.com] On Behalf Of Lei Wen
> Sent: Wednesday, March 07, 2012 10:58 AM
> To: Discussion list for crash utility usage, maintenance and
development
> Subject: [Crash-utility] How to use scripts in crash?
>
> Hi Dave,
>
> Do you have some guide doc that describe how to use the scripts in
crash?
> Like the example, I want to print out current filesystems registered.
> I then need do following
> 1. using "p" to get "file_systems" symbol value 2. using "list" with
command as
> "list -o file_system_type.next -s file_system_type.name,fs_flags <the
> file_systems symbol value>"
>
> So if the previous file_systems symbol value could be stored, and then
I don't
> need to copy the "p" result to "list" command by hand, but could let
script do
> such kind of thing.
>
> I also notice there is "sial" script support in crash, but that is too
complex for
> me... I don't know how to start a basic usage with that... Is there
any detailed
> doc that could help me from a start?
>
> Thanks,
> Lei
>
> --
> Crash-utility mailing list
> Crash-utility@redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility


Sial is a C interpreter with a few twists like the string type and its
associated operators .
The ps example is a good one. Using args and callbacks, including
printing recursively (parent->siblings) the process tree.
Let me know if you have questions. I tried to comment the example as
much as I could at the time. And yes, check out the readme files.

It also has a built in preprocessor which enables you to write/modify
debugging code that easily adapts to the linux version of the core you
are looking at.

All of the type and symbol information from kernel space is available in
sial through the dwarf interface.
You can combine these 2 features with the built in 'exists' operators on
member and variables to enable yet better portability across various
linux flavors.

SGI and other engineering outfits have been cut&pasting kernel code into
sial scripts for years.

The hello worl skeleton for a sial command :
==
string foo_opt(){ return "lt:h"; }
string foo_usage() { return "[-l] [-t counter] [-h]
"; }
string foo_help(){return " This is the help for command foo
"}
int
foo()
{
if(tflag) tval=atoi(targ)
if(lflag) {
printf("lflag is set, targ=[%s], targ);
}
printf("Hello world!
");
}
==
By load'ing this file into crash you automatically create a callable
foo command in crash, complete with help and usage.

Sial can be extended with 'sial builtins' and associated APis.
If there are native crash functions (like back traces and fast searches)
that can be useful as a function in sial, we can do that.

-Luc

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
 
Old 03-07-2012, 06:19 PM
Dave Anderson
 
Default How to use scripts in crash?

----- Original Message -----
>
>
> > -----Original Message-----
> > From: crash-utility-bounces@redhat.com [mailto:crash-utility-
> > bounces@redhat.com] On Behalf Of Lei Wen
> > Sent: Wednesday, March 07, 2012 10:58 AM
> > To: Discussion list for crash utility usage, maintenance and development
> > Subject: [Crash-utility] How to use scripts in crash?
> >
> > Hi Dave,
> >
> > Do you have some guide doc that describe how to use the scripts in crash?
> > Like the example, I want to print out current filesystems registered.
> > I then need do following
> > 1. using "p" to get "file_systems" symbol value 2. using "list" with command as
> > "list -o file_system_type.next -s file_system_type.name,fs_flags <the file_systems symbol value>"
> >
> > So if the previous file_systems symbol value could be stored, and then I don't
> > need to copy the "p" result to "list" command by hand, but could let script do
> > such kind of thing.
> >
> > I also notice there is "sial" script support in crash, but that is too complex for
> > me... I don't know how to start a basic usage with that... Is there any detailed
> > doc that could help me from a start?
> >
> > Thanks,
> > Lei
> >
> > --
> > Crash-utility mailing list
> > Crash-utility@redhat.com
> > https://www.redhat.com/mailman/listinfo/crash-utility
>
>
> Sial is a C interpreter with a few twists like the string type and its
> associated operators.

> The ps example is a good one. Using args and callbacks, including
> printing recursively (parent->siblings) the process tree.
> Let me know if you have questions. I tried to comment the example as
> much as I could at the time. And yes, check out the readme files.
>
> It also has a built in preprocessor which enables you to write/modify
> debugging code that easily adapts to the linux version of the core you
> are looking at.
>
> All of the type and symbol information from kernel space is available in
> sial through the dwarf interface.
> You can combine these 2 features with the built in 'exists' operators on
> member and variables to enable yet better portability across various linux flavors.
>
> SGI and other engineering outfits have been cut&pasting kernel code into
> sial scripts for years.
>
> The hello worl skeleton for a sial command :
> ==
> string foo_opt(){ return "lt:h"; }
> string foo_usage() { return "[-l] [-t counter] [-h]
"; }
> string foo_help(){return " This is the help for command foo
"}
> int
> foo()
> {
> if(tflag) tval=atoi(targ)
> if(lflag) {
> printf("lflag is set, targ=[%s], targ);
> }
> printf("Hello world!
");
> }
> ==
> By load'ing this file into crash you automatically create a callable
> foo command in crash, complete with help and usage.
>
> Sial can be extended with 'sial builtins' and associated APis.
> If there are native crash functions (like back traces and fast searches)
> that can be useful as a function in sial, we can do that.
>
> -Luc

Thanks Luc -- that's exactly what we-the-uninitiated could use to
gain some traction in using sial, a solid but simple example script,
perhaps less sophisticated than the ps.c example.

The one above is a great start, although it's missing a couple of ";"
line endings and the first printf is missing the enclosing parenthesis.
And it seems to be missing some declarations for targ and tval?

crash> help foo

NAME
foo -

SYNOPSIS
foo [-l] [-t counter] [-h]


DESCRIPTION
This is the help for command foo


crash> foo -l
File script, line 9, Error: Unknown variable [targ]
crash> foo -t 100
File script, line 7, Error: Unknown variable [tval]
crash> foo -h
Hello world!
crash> foo
Hello world!
crash>

In any case, a very simple example that shows the basics such as
the above, as well as kernel-data access, and any other fundamentals
to get someone on their way would be *really* helpful to put on
the extensions page. I've asked folks to forward me their sial
scripts on a number of occasions, but for whatever reason, nobody
has.

Thanks,
Dave



--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
 
Old 03-07-2012, 07:41 PM
"Luc Chouinard"
 
Default How to use scripts in crash?

>
> In any case, a very simple example that shows the basics such as the
above, as
> well as kernel-data access, and any other fundamentals to get someone
on their
> way would be *really* helpful to put on the extensions page. I've
asked folks to
> forward me their sial scripts on a number of occasions, but for
whatever reason,
> nobody has.
>
> Thanks,
> Dave
>
>

It has been so long, and did not have an image/namelist to fire crash
against at the time.
I should set myself up properly. That explains the errors.

One can only access the Xarg string if the Xflag int variable is set.
You need to declare tval somewhere as a string as well.

I mean to get a sial archive going at some point in the future. Maybe a
git repo where folks can add and contribute. I am still thinking of
doing it when I get the time.

I'll write a better example and forward to the list asap.

-Luc


--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
 
Old 03-07-2012, 11:34 PM
Max Matveev
 
Default How to use scripts in crash?

On Wed, 7 Mar 2012 07:57:40 -0800, Lei Wen wrote:

lei> I then need do following
lei> 1. using "p" to get "file_systems" symbol value
lei> 2. using "list" with command as "list -o file_system_type.next -s file_system_type.name,fs_flags <the file_systems symbol value>"

lei> So if the previous file_systems symbol value could be stored,
lei> and then I don't need to copy the "p" result to "list" command
lei> by hand, but could let script do such kind of thing.

Others have mentioned pykdump and sial, there is also a granddaddy of
it all - good ol' gdb script. They're not as flexible as sial or
pykdump but they have an advantage of being "always on" - gdb is part
of crash.

Here is an example of printing list of 'rpc tasks' from sunrpc module

define rpc_tasks
set $e = ((struct list_head *)$arg0)
set $n = $e->next
set $of = &(((struct rpc_task *)0)->tk_task)

while $n != $e
set $i = (struct rpc_task *)((char *)$n - (char *)$of)
set $proc = $i->tk_msg->rpc_proc
if ($proc->p_name)
printf "%p %s", $i, $proc->p_name
else
printf "%p NULL", $i
end
printf " %p(%s, xprt %p) %p", $i->tk_client,
$i->tk_client->cl_protname, $i->tk_client->cl_xprt,
$i->tk_client->$i->tk_rqstp

if ($i->tk_rqstp)
printf "(%x)", $i->tk_rqstp->rq_xid
end
printf " %d
", $i->tk_pid
set $n = $n->next
end
end

You can type this by hand or save it into a file and then use
'source your.file.name.here' command in crash. After sourcing is done
you have a command called rpc_tasks which can be used like this:

crash> rpc_tasks 0xabcd8000

where 0xabcd8000 is the list_head of a task list.

The example shows how to walk a list and how to access a list entry if
the linkage is not directly at the start of the structure.

max

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
 
Old 03-08-2012, 02:11 PM
Lei Wen
 
Default How to use scripts in crash?

Hi Bruce,

On Thu, Mar 8, 2012 at 12:25 AM, Bruce Korb <bruce.korb@gmail.com> wrote:
> On Wed, Mar 7, 2012 at 8:08 AM, Dave Anderson <anderson@redhat.com> wrote:
>>> I also notice there is "sial" script support in crash, but that is
>>> too complex for me... I don't know how to start a basic usage with
>>> that... Is there any detailed doc that could help me from a start?
>>>
>>> Thanks,
>>> Lei
>>
>> I can't help you with sial usage, but there is a ~1000-page README
>> file in crash-6.0.4/extensions/libsial. *And perhaps the sample
>> ps.c and files.c sial scripts from the crash extensions page could
>> be used as templates for your requirements.
>
> There's also pykdump, if you don't mind python. *It is rigged up to be
> able to call back into crash, which sial is not. *It also has better facilities
> for coping with compile time structure variations. *So if you need to learn
> a new language anyway (sial being a new language as it is not C),
> it may as well be python.
>
> Alternatively, you can also write shell scripts that emit crash commands
> into a file that, when sourced, does a bunch of crash commands before
> re-invoking itself. *I finally did that since there is no provision for scripts
> to feed commands back to crash directly. *It works. *It's tricky. *Attached
> is an example that will do approximate "bt"s on threads that were caught
> "on proc" at the time of a crash. *It's my template.
>

Seem I get no luck to build out the pykdump...
I git clone its tree from:
git://pykdump.git.sourceforge.net/gitroot/pykdump/pykdump
After this, I do the ./configure -c <crash build place>
and then make, the following error shows up:
Makefile:24: slocal.mk: No such file or directory
make: *** No rule to make target `slocal.mk'. Stop.

Any idea?
> Cheers - Bruce
>
Thanks,
Lei

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
 
Old 03-08-2012, 02:34 PM
Alex Sidorenko
 
Default How to use scripts in crash?

On March 8, 2012 11:11:36 PM Lei Wen wrote:
> Seem I get no luck to build out the pykdump...
> I git clone its tree from:
> git://pykdump.git.sourceforge.net/gitroot/pykdump/pykdump
> After this, I do the ./configure -c <crash build place>
> and then make, the following error shows up:
> Makefile:24: slocal.mk: No such file or directory
> make: *** No rule to make target `slocal.mk'. Stop.

Hi Bruce,

some time ago it was possible to build PyKdump with distribution-provided
Python, but then I have realized it does not make much sense as it would be
difficult to redistribute it.

So the only supported approach at this moment is to to build Python from
sources first and then build PyKdump using Python libraries from this build.

http://sourceforge.net/apps/mediawiki/pykdump/index.php?title=BuildingGit

explains this in more details. In particular, you need to specify _both_
locations of crash sources and Python sources, e.g.


$ ./configure -p /src/Python/Python-2.7.2 -c /src/kerntools/crash-6.0.3

After this slocal.mk will be created.

Regards,
Alex

--
------------------------------------------------------------------
Alexandre Sidorenko email: asid@hp.com
WTEC Linux Hewlett-Packard (Canada)
------------------------------------------------------------------

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
 
Old 03-08-2012, 02:35 PM
Bruce Korb
 
Default How to use scripts in crash?

Hi Lei,

On Thu, Mar 8, 2012 at 7:11 AM, Lei Wen <adrian.wenl@gmail.com> wrote:
> Seem I get no luck to build out the pykdump...
....
> Makefile:24: slocal.mk: No such file or directory
> make: *** No rule to make target `slocal.mk'. *Stop.
>
> Any idea?

It's true the build mechanisms of pykdump leave a lot to be desired.
You have to tell the thing where to find the python build tree, too,
because the process involves rolling up a largish subset of python
into the .so file. After configuring there should be *three* .mk files.
I've attached a file showing how mine got set up for my platform
with my layout, meaning you won't be able to use it (directly), but
you'll see more-or-less what you need. You'll find the pykdump guy
helpful 'cuz he helped me through exactly the same problems. Weeks
ago now, so I've forgotten what exactly I had to do....

Good luck. Cheers - Bruce

$ ls -l $(find * -name '*.so')
-rwxrwxrwx 1 bruce staff 6302242 Feb 8 15:54 Extension/mpykdump.so
-rwxrwxrwx 1 bruce staff 5896299 Feb 8 12:41 Extension/pykdump_c.so
$ head -3000 *.mk
==> crash.mk <==
# Configuration options for 'crash' tree
CRASHDIR := /mnt/home-work/TOOLS/crash-5.1.1-patched
GDBDIR := /mnt/home-work/TOOLS/crash-5.1.1-patched/gdb-7.0/gdb
GDBINCL = -I$(GDBDIR) -I$(GDBDIR)/config -I$(GDBDIR)/../bfd
-I$(GDBDIR)/../include -I$(GDBDIR)/../intl
EXTRA := -DGDB7 -I$(GDBDIR)/common
TARGET := X86_64
CRASHVERS := 5.1.1

==> local.mk <==
# Configuration options for local build
PYTHON := python
PYINCLUDE := -I/usr/include/python2.6
CC := gcc -pthread
CFLAGS := -fPIC
LIBS := -L. -lpython2.6 -lpthread -ldl -lutil -lm
LINKFLAGS := -nostartfiles -shared -Xlinker -export-dynamic
TOPDIR := /mnt/home-work/TOOLS/pykdump-bld

==> slocal.mk <==
# Configuration options for static-build
PYTHONDIR := /mnt/home-work/TOOLS/Python-2.6.7
PYTHON := env LD_LIBRARY_PATH=/mnt/home-work/TOOLS/Python-2.6.7 /mnt/home-work/TOOLS/Python-2.6.7/python
PYINCLUDE := -I/mnt/home-work/TOOLS/Python-2.6.7/Include -I/mnt/home-work/TOOLS/Python-2.6.7
CC := gcc -pthread
CFLAGS := -fPIC
LIBS := /mnt/home-work/TOOLS/Python-2.6.7/libpython2.6.a -lpthread -ldl -lutil -lm
LINKFLAGS := -nostartfiles -shared -Xlinker -export-dynamic
TOPDIR := /mnt/home-work/TOOLS/pykdump-bld
STDLIBP := /mnt/home-work/TOOLS/Python-2.6.7/local/lib/python2.6
COMPALL := /mnt/home-work/TOOLS/Python-2.6.7/local/lib/python2.6/compileall.py
MINPYLIB_FILES := minpylib-2.6.lst
--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
 

Thread Tools




All times are GMT. The time now is 12:40 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org