:
# ----------------------------------------------------------------------
#
#  iscda -- Script to print out Initial System Crash Dump Analysis
#
#  History:
#
#    Edit 1   940707   krb   First script for Solaris 2.3, Rev 1.0
#
#
#  Files this script creates:
#
#    /tmp/iscda.{pid}
#
#  Notes:
#
#    This script must be run on the same kernel architecture and
#    under the same OS as the system crash dump we are analyzing.
#
# ----------------------------------------------------------------------

if [ ! $# = 2 ]
then
  echo
  echo "Usage:   iscda  unixfile  corefile  > your-output-file"
  echo
  echo "Examples:  iscda  unix.3  vmcore.3"
  echo "           iscda  /dev/ksyms  /dev/mem"
  echo
  exit
fi

#
#  Make sure we can see the files.
#
if [ ! -f $1 ] && [ ! $1 = "/dev/ksyms" ]
then
  echo; echo "Unable to locate $1.  Exiting."
  echo; exit
fi
if [ ! -f $2 ] && [ ! $2 = "/dev/mem" ]
then
  echo; echo "Unable to locate $2.  Exiting."
  echo; exit
fi


#
#  Okay, we are ready!  Create and put some stuff into output file.
#
echo "Working....."
cat <<EOC

******************************************************************************
Initial System Crash Dump Analysis Output                        iscda Rev 1.0
`date`
******************************************************************************

EOC


#
#  We will be creating our own macros for use in adb sessions.
#  Odds are we will create a unique filename if we use the PID.
#  If it is not unique, let the user do something about it.
#
WHERE=/tmp/iscda.$$
if [ -f $WHERE ]
then
  echo; echo "File $WHERE already exists.  Exiting."
  echo; exit
fi

cat > $WHERE <<EOC
*(<c+0t28)>n
<c+8/X"Thread address"
*(<c+8)>p
<p+a0/X"Proc address"
*(<p+a0)>j
<j+260/s
.,#((*(<c+8))-(*(<c+c)))="This CPU was idle"
0,#(#(<n))&#(#(<n-<e))=n"Next CPU..."n
<n>c
<n,#(#(<n))&#(#(<n-<e))$<$WHERE
EOC


#
#  Get initial information from adb
#
cat <<EOC
************************************
**  Initial information from adb  **
************************************

EOC

adb -k $1 $2 <<EOA
$<utsname
srpc_domain/s16t"Domain name"
lbolt>a
*time-(*<a%0t100)=Y16t"Time of boot"
time/Y16t"Time of crash"
,#(*audit_active)=n"Auditing is not enabled"
,##(*audit_active)=n"Auditing is enabled"
,#(*quotas_initialized)=n"Quotas are not enabled"
,##(*quotas_initialized)=n"Quotas are enabled"
=nn"**  Panic String  **"
="--------------------"
*panicstr/s
=nn"**  Stack Backtrace  **"
="-----------------------"
\$c
=nn"**  Per CPU information  **"
="---------------------------"
ncpus/X"# of CPUs present"
ncpus_online/X"# of CPUs online"
=nn
*cpu_list>c
<c>e
<c,#(<c)="The cpu_list pointer is NULL.  Not a good sign."n
<c,#(#(<c))$<$WHERE
=nn"**  Calltrace  **"
="-----------------"
<sp$<calltrace
=nn
="**  CPU structures  **"
="--------------------"
$<cpus
=nn
="**  Msgbuf  **"
="------------"
$<msgbuf
EOA

cat > $WHERE <<EOC
=nn"**  System is sun4m architecture - Checking enable_sm_wa  **"
="------------------------------------------------------------"
cpunodes/s
enable_sm_wa/D
,##(*enable_sm_wa)="Patch 101406 is installed"
,#(*enable_sm_wa)="Patch 100406 is not installed"
EOC

adb -k $1 $2 <<EOA
0,#(*(utsname+408)-6d000000)$<$WHERE
EOA

#
#  Get process information by using crash.
#
cat <<EOC


**************************************
**  Process information from crash  **
**************************************

EOC
crash $2 $1 <<EOC
p -e
EOC


#
#
#  Get strings output to capture message buffer.
#
cat <<EOC



******************************************************
**  Strings output of complete message ring buffer  **
******************************************************

EOC
strings $2 | head -200


#
#  Additional adb stuff
#
cat <<EOC

***********************
**  Some Statistics  **
***********************

EOC
adb -k $1 $2 <<EOA
=nn"**  Directory Name Lookup Cache Statistics  **"
="----------------------------------------------"
ncsize/D"Directory name cache size"
ncstats/D"# of cache hits that we used"
+/D"# of misses"
+/D"# of enters done"
+/D"# of enters tried when already cached"
+/D"# of long names tried to enter"
+/D"# of long name tried to look up"
+/D"# of times LRU list was empty"
+/D"# of purges of cache"
*ncstats+*(ncstats+4)+*(ncstats+14)>n
*ncstats*0t100%<n=D"Hit rate percentage"
="(See /usr/include/sys/dnlc.h for more information)"
=nn"**  Kernel Memory Request Statistics  **"
="----------------------------------------"
="Small"16t"Large"16t"Outsized"
kmeminfo/3X"Owned by kmem"
+/3X"Mem allocated"
+/3X"# of failures"n
pagesize/D"Memory page size"
="(See /usr/include/sys/sysinfo.h for more information)"
=nn"**  Streams Statistics  **"
="--------------------------"
="In use"16t"Total"16t"Maximum"16t"Failures"
strst/4X"Streams"
+/4X"Queues"
+/4X"MsgBlks"
+/4X"LinkBlks"
="(See /usr/include/sys/strstat.h for more information)"
EOA


#
#  Print out some of the tunable variables.  Do this via macros
#  so that we don't get alot of symbol not found messages if
#  the driver was not modloaded for use.
#
cat > $WHERE <<EOC
=nn"**  Shared Memory Tuning Variables (if in use)  **"
="--------------------------------------------------"
shminfo_shmmax/D"Max segment size"
+/D"Min segment size"
+/D"Max identifiers"
+/D"Max attached shm segs per proc"
EOC

adb -k $1 $2 <<EOA
$<$WHERE
EOA

cat > $WHERE <<EOC
=nn"**  Semaphore Tuning Variables (if in use)  **"
="----------------------------------------------"
seminfo_semmap/D"Entries per map"
+/D"Max identifiers"
+/D"Max in system"
+/D"Max undos"
+/D"Max sems per id"
+/D"Max ops per semop"
+/D"Max undos per proc"
+/D"Max bytes in undos"
+/D"Max sem value"
+/D"Max adjust on exit"
EOC

adb -k $1 $2 <<EOA
$<$WHERE
EOA

cat > $WHERE <<EOC
=nn"**  Message Queue Tuning Variables (if in use)  **"
="--------------------------------------------------"
msginfo_msgmap/D"Max entries in map"
+/D"Max message size"
+/D"Max bytes on queue"
+/D"Max msg queue ids"
+/D"Max segment size (word size multiple)"
+/D"Max system message headers"
+/d16t"Max msg segments (must be < 32768)"
EOC

adb -k $1 $2 <<EOA
$<$WHERE
EOA



cat <<EOC


  +--------------------------------------------------------------------+
  |  For more information about system crash dump analysis, refer to   |
  |  the SunSoft Press book, "Panic!  System Crash Dump Analysis",     |
  |  ISBN 0-13-149386-8, to be published Spring 1994 by Prentice Hall. |
  +--------------------------------------------------------------------+

EOC

rm $WHERE
echo "Done!"
#
#  end of iscda
#
