----- Original Message -----
> -----Original Message-----
> From: crash-utility-bounces(a)redhat.com [mailto:crash-utility-
> bounces(a)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(a)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]\n"; }
string foo_help(){return " This is the help for command foo\n"}
int
foo()
{
if(tflag) tval=atoi(targ)
if(lflag) {
printf("lflag is set, targ=[%s], targ);
}
printf("Hello world!\n");
}
==
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