Thursday, February 2, 2012
Monday, July 18, 2011
gprof enabling
- Add the ”-pg” option to every .o compilation + to the exe also.
- Link with static versions of libraries that need being profiled.
Example given:
cd /vob/signalware/Master/scos
swmake gprof cd /vob/signalware/Master/test/tcap/c7
rm /vob/signalware/Master/library/libscos.so
clearmake -V "PROT_FLAGS=-DC7_Q" gprof Then running c7icptrans should produce a gmon.out.
To extract the information from gmon.out, use gprof:
gprof /export/home/omni_9S5/bin/test/c7icptrans gmon.out > gprof.txt
Trace system calls from libFt in is41tst32
truss -u libFt:: /export/home/omni/bin/is41tst32 -debug -alone -node A71 -prot A7 -lpc 1-85-2 -rpc 1-85-2 -lssn -rssn 6 -ninvoke 200 0xffff
Example use
# mdb -k
Loading modules: [ unix krtld genunix ip usba logindmux ptm cpc ipc random nfs ]
> ::queue -v -m c7m3uart
0000030026cc1d30
> 0000030026cc1d30::q2stream
30026c5c940
> 30026c5c940::stream
+-----------------------+-----------------------+
| 0x30026cc8478 | 0x30026cc8388 |
| mom | mom |
| | |
| cnt = 0t0 | cnt = 0t0 |
| flg = 0x00004022 | flg = 0x00044032 |
+-----------------------+-----------------------+
| ^
v |
+-----------------------+-----------------------+
| 0x30026cc13e0 | 0x30026cc12f0 |
| c7tcap | c7tcap |
| | |
| cnt = 0t0 | cnt = 0t0 |
| flg = 0x00004022 | flg = 0x00004032 |
+-----------------------+-----------------------+
| ^
v |
+-----------------------+-----------------------+
| 0x30026cc0c30 | 0x30026cc0b40 |
| c7sccp | c7sccp |
| | |
| cnt = 0t0 | cnt = 0t0 |
| flg = 0x00004022 | flg = 0x00004032 |
+-----------------------+-----------------------+
| ^
v |
+-----------------------+-----------------------+
| 0x30026cc1e20 | 0x30026cc1d30 |
| c7m3uart | c7m3uart |
| | |
| cnt = 0t0 | cnt = 0t0 |
| flg = 0x00004022 | flg = 0x00004032 |
+-----------------------+-----------------------+
| ^
v |
+-----------------------+-----------------------+
| 0x30026cc81e8 | 0x30026cc80f8 |
| lom_ | lom_ |
| | |
| cnt = 0t0 | cnt = 0t0 |
| flg = 0x00244022 | flg = 0x00204032 |
+-----------------------+-----------------------+
>
watchmalloc how to (sangria)
Very slow!
cd /usr/lib/secure/64
suidwrap ln -s /usr/lib/64/watchmalloc.so.1
export LD_PRELOAD_64=/usr/lib/secure/64/watchmalloc.so.1
export MALLOC_DEBUG=WATCH,RW
libumem how to (sangria)
Requires Solaris 9 update 3, and above.
cd /usr/lib/secure/64
suidwrap ln -s /usr/lib/64/libumem.so.1 Then,
export LD_PRELOAD_64=/usr/lib/secure/64/libumem.so.1
export UMEM_DEBUG=default
export UMEM_LOGGING=transaction
go.omni
gcore `pid guiserver` If core “core.15604” is dumped, then
mdb core.15604
Memory leaks / Memory corruption
- Generalities: Alternate Methods of Debugging
- libumem: libumem
- or, libumem: libumem
PM sig_segv
$ gdb
(gdb) file /vob/signalware/Master/pm/pm |
Reading symbols from /vob/signalware/Master/pm/pm...done.
(gdb) attach 26427
Attaching to program `/vob/signalware/Master/pm/pm', process 26427
Reading symbols from /usr/lib/sparcv9/omni/libdgms.so...done.
Loaded symbols for /usr/lib/sparcv9/omni/libdgms.so
...
sol-thread active.
Retry #1:
Retry #2:
Retry #3:
Retry #4:
[New LWP 1 ]
[New Thread 1 (LWP 1)]
Symbols already loaded for /usr/lib/sparcv9/omni/libdgms.so
...
[Switching to Thread 1 (LWP 1)]
0xffffffff7d7a677c in _poll () from /usr/lib/64/libc.so.1
(gdb) handle SIGSEGV stop print
Signal Stop Print Pass to program Description
SIGSEGV Yes Yes Yes Segmentation fault
(gdb) cont
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0xffffffff7d73d28c in strlen () from /usr/lib/64/libc.so.1
(gdb) bt
#0 0xffffffff7d73d28c in strlen () from /usr/lib/64/libc.so.1
#1 0xffffffff7d790308 in _doprnt () from /usr/lib/64/libc.so.1
#2 0xffffffff7d792538 in vsprintf () from /usr/lib/64/libc.so.1
#3 0xffffffff7e71b624 in FtFormatInternationalMsg (catd=0x10075fa50, set_number=45, message_number=109,
defaultString=0xffffffff7c321a0f "M DENY\n %s\n %s\n",
destMsgBuf=0x100186380 "M DENY\n +------+\n| INFO | Acquiring lock on addDelNode.lock.6981\n+------+\n/export/home/omni/bin/DFcat addDelNode.lock.6981 2>&1\n/export/home/omni/bin/DFconvert /tmp/addDelNode.lock.6981\n\n+------+\n|"..., sizeDestMsgBuf=4096)
at ../lib_util.c:1740
#4 0x0000000100010a14 in DoCreateNode (pcmd=0x100624a10) at pm.c:5333
#5 0x0000000100034980 in yyparse () at parse.y:1026
#6 0x000000010003acf4 in parseMML () at nlex.l:1024
#7 0x0000000100037620 in process_mml_cmd () at parse.y:2399
#8 0x000000010000a760 in main (argc=7672264, argv=0x100624e18) at pm.c:1555
(gdb) quit
Ignore SIGUSR2 signals
This command will prevent your program from stopping whenever it receives a SIGUSR2 but will print it anyway.
(gdb) handle SIGUSR2 nostop noprint This is useful in JGUI Server to prevent gdb from being stopped by SIG_CPT.
Ignore SIGALRM in single-stepping
To ignore SIGALRM signals while single-stepping, but treat them normally during normal execution, you could define:
define hook-stop
handle SIGALRM nopass
end define hook-run
handle SIGALRM pass
end define hook-continue
handle SIGLARM pass
end NB: recorded in ~gallinar/.gdbinit, which is read automatically by gdb if gallinar or which can be sourced (within gdb) if root.
Installing gdb
Excerpt:
CC="gcc -m64" ./configure --prefix=/u/engineering/locals/solaris10/softs/proglang/gdb-6.6
make
make install Compilation errors:
rm -f gdb
gcc -g -O2 \
-o gdb gdb.o libgdb.a \
../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a ./../intl/libintl.a ../libiberty/libiberty.a -ldl -lncurses -lsocket -lnsl -lm ../libiberty/libiberty.a
Undefined first referenced
symbol in file
initscr32 libgdb.a(tui.o)
w32addch libgdb.a(tui-io.o)
w32attron libgdb.a(tui-wingeneral.o)
w32attroff libgdb.a(tui-wingeneral.o)
acs32map libgdb.a(tui-win.o)
ld: fatal: Symbol referencing errors. No output written to gdb To solve it:
cd /usr/ccs/lib
ln -s /usr/ccs/lib/libcurses.so libncurses.so
valgrind: failed to start tool memcheck for platform amd64-linux: No such file or directory
valgrind was not able to find memcheck.
Solution: Put in VALGRIND_LIB the parent directory of amd64-linux directory.
E.g.:
export VALGRIND_LIB=/u/gallinar/downloaded/valgrind-3.2.3/.in_place
Example run
/u/engineering/locals/linux/bin/valgrind --leak-check=yes --show-reachable=yes --num-callers=16 --quiet $OMNI_HOME/bin/MonControl -filetype pcap -enable C7_L3MTP 2>&1 | tee MonControl.log