Thanks hawtin.
Thanks all the monks who have given valuable pointers. Now what I have done, I first put an infinite loop in .c file and build it with -g and without -O option. Started perl script and now I can debug with gdb after attaching PID.
Thanks again.
-Pijush