General - Collecting Stack Trace

If we have any native debugger installed collect the stack trace. Try to generate stack trace from core file for all the threads dumped.
  • SOLARIS
    • pstack core or
    • /opt/SUNWspro/bin/dbx program core
      • (dbx) thread -info t@1 ==> show the thread information
      • (dbx) where ==> show the thread stack
  • AIX
    • The syscorepath utility can be used to specify a single system-wide directory in which all core files of any processes are saved. The syntax for this command is: syscorepath -p alternate_directory.
    • To set the OS for full core dumps and files to unlimited
      • Set the ulimit setting for core dumps to unlimited: ulimit -c unlimited.
      • Set the ulimit setting for core files to unlimited: ulimit -f unlimited.
    • Set Smit to use full core dumps either by starting smit and setting: System Environments -> Change/Show Characteristics of Operating System -> Enable Full CORE dump to "TRUE", or by using the command chdev -l sys0 -a fullcore='true' as root.
    • Ensure that the current working directory has enough disk space available to write the core file. You can redirect AIX core files to alternative locations using a symbolic link. To do this, you must create a link from the current working directory of the process to an alternative directory where there is a file called "core". After a full core file has been generated and located, you must rename that file to prevent any other core file, that is generated in the same directory, from overwriting it.
    • Run SMIT (or smitty) --> System Environments --> Change / Show Characteristics of Operating System --> Use pre-430 style CORE dump. Set the last option to true and then adb / dbx will be able to read new core files produced (the core file must be created under new settings).
  • LINUX
    • gdb program core
      • (gdb) where
  • HPUX
    • adb programname core
      • (adb) $c

Labels: , ,

Posted by - at 2:55 am | 0 comments read on

Shell Scripting - Monitor Process

This script wil help you in monitoring process resources like memory, cpu usage etc in a portable way across all UNIX/LINUX environment



#!bin/sh

PROCCHECKDELAY=1
RUNCHECKDELAY=2
PROCNORUN=
PAGEROWS=80
PROCNAME=$1
PROCID=

if [ $# -ne 1 ]
then
echo give program name to watch;
exit 1;
fi

stat_process()
{
PROCID=
_mypid=
while [ true ]
do
_mypid=`ps -e 2>/dev/null|grep $1|head -n1|awk '{ print $1 }'`;
if [ ! -z "$_mypid" ]
then
PROCNORUN=
break;
fi
if [ -z "$PROCNORUN" ] ;
then
PROCNORUN=yes
echo "$1 is not running"
echo "recheck after $RUNCHECKDELAY seconds";
sleep $RUNCHECKDELAY;
fi
done
PROCID=$_mypid;
}

i=$PAGEROWS;
while true;
do
stat_process $PROCNAME;

if [ $i -eq $PAGEROWS ] ;
then
i=0;
UNIX95= ps -p $PROCID -o vsz,pid,ruser,rss,pcpu,pmem,args 2>/dev/null
else
UNIX95= ps -p $PROCID -o vsz,pid,ruser,rss,pcpu,pmem,args 2>/dev/null|tail +2
fi
if [ ! -z "$PROCID" ]
then
i=`expr $i + 1`;
fi
sleep $PROCCHECKDELAY;
done;

Labels: , , , ,

Posted by - at 12:37 am | 0 comments read on

C C++ Programming - Useful Tracing and Profiling Tools

I have been searching for few tracing and profiling tools these days. Tracing tools are my fav because we will be able to debug it while it is running and can get an overview of what is happening inside a.out. esp while learning the flow of a prog.

I found the given below tools and links very useful...


Labels: , , , , , ,

Posted by - at 12:02 am | 1 comments read on

Shell Script - Memory Watch for UNIX Platforms

Simple memory profile script for UNIX/LINUX platforms.


#!bin/sh

PROCCHECKDELAY=1
RUNCHECKDELAY=2
PAGEROWS=80
PROCNAME=$1
PROCID=

if [ $# -ne 1 ]
then
echo give program name to watch;
exit 1;
fi

stat_process()
{
PROCID=
_mypid=
while [ true ]
do
_mypid=`ps -e 2>/dev/null|grep $1|head -n1|awk '{ print $1 }'`;
if [ -z "$_mypid" ]
then
echo "$1 is not running"
else
break;
fi
echo "recheck after $RUNCHECKDELAY seconds";
sleep $RUNCHECKDELAY;
done
PROCID=$_mypid;
}

i=$PAGEROWS;
while true;
do
stat_process $PROCNAME;
if [ $i -eq $PAGEROWS ] ;
then
i=0;
UNIX95= ps -p $PROCID -o vsz,pid,ruser,args 2>/dev/null
else
UNIX95= ps -p $PROCID -o vsz,pid,ruser,args 2>/dev/null|tail +2
fi
if [ ! -z "$PROCID" ]
then
i=`expr $i + 1`;
fi
sleep $PROCCHECKDELAY;
done;


please post your valuable comments and suggestions.

Labels: , , , , ,

Posted by - at 3:17 pm | 0 comments read on

Archives

Links