Tools_and_techniques_for_advanced_debugging_in_Unix
Tools_and_techniques_for_advanced_debugging_in_Unix
By
Riyaj Shamsudeen
Me
18 years using Oracle products/DBA
OakTable member
Oracle ACE
Certified DBA versions 7.0,7.3,8,8i,
9i &10g
Specializes in RAC, performance
tuning, Internals and E-business
suite
Chief DBA with OraInternals
Email: rshamsud@orainternals.com
Blog : orainternals.wordpress.com
URL: www.orainternals.com
Problem statement:
Demo: testcase1.sql
Truss - trace system calls and signals
truss –p 28393
Options:
truss [-fcaeildD] [ - [tTvx] [!] syscall ,...] [ - [sS] [!] signal ,...] [ -
[mM] [!] fault ,...] [ - [rw] [!] fd ,...] [ - [uU] [!] lib ,... : [:] [!] func ,...] [-
o outfile] com- mand | -p pid...
Solaris – truss
Hpux- tusc (download)
Linux – strace
Truss
To trace a process and print minimal information
truss –p <pid> Example: truss –p 23898
Pfiles:
pfiles can be used to associate this file ids with file names.
Pfiles lists the files currently opened by a process. In few
unix platform, this can be achieved by lsof command
also.
Using these device numbers and
pfiles Inode numbers, file names can be mapped.
pfiles 28393
28393: ar60runb P_CONC_REQUEST_ID=2452107 STARTDATE='012006'
ENDDATE='122006'
Current rlimit: 4096 file descriptors
0: S_IFIFO mode:0000 dev:272,0 ino:7325504 uid:11175 gid:100 size:0
O_RDWR
1: S_IFREG mode:0644 dev:233,63004 ino:895220 uid:11175 gid:100 size:0
O_WRONLY|O_APPEND|O_CREAT
2: S_IFREG mode:0644 dev:233,63004 ino:895220 uid:11175 gid:100 size:0
O_WRONLY|O_APPEND|O_CREAT
...
17: S_IFREG mode:0644 dev:233,63004 ino:895242 uid:11175 gid:100 size:
102522880
O_RDWR|O_CREAT|O_TRUNC
18: S_IFREG mode:0644 dev:233,63004 ino:895305 uid:11175 gid:100 size:
25491841
O_RDWR|O_CREAT|O_TRUNC
WARNINGS
The following proc tools stop their target processes while inspecting them
and reporting the results: pfiles, pldd, pmap, and pstack.
#! /bin/ksh
pid=$1
(( cnt=1000 ))
while [[ $cnt -gt 0 ]]; Wrote this small shell script, to
do dump Memory map and stack of this
date
pmap -x $pid Process, in a loop, every 10 seconds.
pstack $pid
echo $cnt
(( cnt=cnt-1 ))
sleep 10
done
pmap
Address Kbytes RSS Anon Locked Mode Mapped File
00010000 72 72 - - r-x-- java
00030000 16 16 16 - rwx-- java
00034000 8744 8680 8680 - rwx-- [ heap ]
77980000 1224 1048 - - r--s- dev:273,2000 ino:104403
77CFA000 24 24 24 - rw--R [ anon ]
...
FF39A000 8 8 8 - rwx-- libthread.so.1
FF3A0000 8 8 - - r-x-- libc_psr.so.1
FF3B0000 184 184 - - r-x-- ld.so.1
FF3EE000 8 8 8 - rwx-- ld.so.1
FF3F0000 8 8 8 - rwx-- ld.so.1
FF3FA000 8 8 8 - rwx-- libdl.so.1
FFB80000 24 - - - ----- [ anon ]
FFBF0000 64 64 64 - rw--- [ stack ]
-------- ------- ------- ------- -------
total Kb 182352 65568 26360 - Process initially started
with
a memory usage of 182MB
pmap
Address Kbytes RSS Anon Locked Mode Mapped File
00010000 72 72 - - r-x-- java
00030000 16 16 16 - rwx-- java
00034000 8808 8720 8720 - rwx-- [ heap ]
77980000 1224 1048 - - r--s- dev:273,2000 ino:104403
77CFA000 24 24 24 - rw--R [ anon ]
77F7A000 24 24 24 - rw--R [ anon ]
78000000 72 72 72 - rwx-- [ anon ]
78012000 64 64 64 - rwx-- [ anon ]
7814C000 144 144 144 - rwx-- [ anon ]
78170000 8 8 8 - rwx-- [ anon ]
78172000 8 8 8 - rwx-- [ anon ]
78174000 8 8 8 - rwx-- [ anon ]
78176000 104 104 104 - rwx-- [ anon ]
..
FF370000 96 96 - - r-x-- libthread.so.1
FF398000 8 8 8 - rwx-- libthread.so.1
FF39A000 8 8 8 - rwx-- libthread.so.1
FF3A0000 8 8 - - r-x-- libc_psr.so.1
FF3B0000 184 184 - - r-x-- ld.so.1
FF3EE000 8 8 8 - rwx-- ld.so.1
FF3F0000
FF3FA000
8
8
8
8
8
8
- rwx-- ld.so.1
- rwx-- libdl.so.1
As the process was
FFB80000 24 - - - ----- [ anon ] running, Process
FFBF0000 64 64 64 - rw--- [ stack ]
-------- ------- ------- ------- ------- memory usage started
total Kb 281040 210736 171528 - to grow.
Problem #2
Demo: testcase2.sql
pstack
pstack shows current stack of the process. Let’s look at pstack for this java process:
pstack 1567
1567: oraclesolrac1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
000000000ab1418f pevm_SUBSTR () + 12f
000000000aad49bf pfrinstr_SUBSTR () + 5f
000000000aac5880 pfrrun_no_tool () + 40
000000000aac6a6f pfrrun () + 4df
000000000ab2e3fa plsql_run () + 2ea
000000000aaa4a83 peicnt () + 143
000000000a0fba56 kkxexe () + 216
000000000447b5c7 opiexe () + 2757
0000000004d54695 kpoal8 () + ce5
0000000004472693 opiodr () + 433
0000000008e67f69 ttcpip () + 599
000000000444cfc0 opitsk () + 600
000000000445bb75 opiino () + 675
0000000004472693 opiodr () + 433
0000000004441f4e opidrv () + 32e
0000000005672197 sou2o () + 57
000000000159eac9 opimai_real () + 219
000000000568f2de ssthrdmain () + 14e
000000000159e89b main () + cb
000000000159e67c ???????? ()
Oradebug short_stack
Oradebug short_stack also can be used to get process stack.
Example:
http://blog.tanelpoder.com/seminar/
Contact info:
Email: rshamsud@gmail.com
Blog : orainternals.wordpress.com
URL : www.orainternals.com