[20180625]oradebug peek 2.txt

lfree發表於2018-06-25

[20180625]oradebug peek 2.txt

--//上個星期演示了oradebug peek檢視記憶體資料塊的情況,oradebug peek {address} length 1,最後的引數1可以實現轉儲到跟蹤檔案.
--//以前也使用oradebug檢視sql語句在共享池的父遊標.採用拚接的方式檢視.
--//如果使用上面的方式就簡單了,測試看看.
--//以前的測試,連結:[20161230]檢視父遊標中sql語句.txt => http://blog.itpub.net/267265/viewspace-2131655/

1.環境:
SCOTT@book> @ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

2.檢視父遊標中sql語句:
SCOTT@book> select * from dept where deptno=10;
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK

--//多執行幾次,保持sql語句游標在共享池中,確定sql_id= 4xamnunv51w9j.

SYS@book> @ &r/sharepool/shp4 4xamnunv51w9j 0
TEXT           KGLHDADR         KGLHDPAR         C40                                        KGLHDIVC KGLOBHD0         KGLOBHD6           KGLOBHS0   KGLOBHS6   KGLOBT16   N0_6_16        N20   KGLNAHSH KGLOBT03        KGLOBT09
-------------- ---------------- ---------------- ---------------------------------------- ---------- ---------------- ---------------- ---------- ---------- ---------- --------- ---------- ---------- ------------- ----------
子游標控制程式碼地址 000000007B9C0FD8 000000007C6315A8 select * from dept where deptno=10                0 000000007C25EC10 000000007DBA6D20       4528      12144       3067     19739      19739  911274289 4xamnunv51w9j          0
父遊標控制程式碼地址 000000007C6315A8 000000007C6315A8 select * from dept where deptno=10                0 000000007D84C448 00                     4720          0          0      4720       4720  911274289 4xamnunv51w9j      65535

--//父遊標地址=000000007C6315A8

4.看看範圍:
--//透過查詢x$ksmsp確定範圍
SELECT * FROM x$ksmsp WHERE TO_NUMBER ('000000007C6315A8', 'xxxxxxxxxxxxxxxx') between TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx') and TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx')+KSMCHSIZ

ADDR                   INDX    INST_ID   KSMCHIDX   KSMCHDUR KSMCHCOM         KSMCHPTR           KSMCHSIZ KSMCHCLS   KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00007FDE14C240E8      13208          1          1          1 KGLHD            000000007C631578        560 recr             80 00

--//可以確定範圍: 0x000000007C631578,0x000000007C631578+560.

--//先看看sql語句轉儲的內容:
SCOTT@book> select dump('select * from dept where deptno=10',16) from dual ;
DUMP('SELECT*FROMDEPTWHEREDEPTNO=10',16)
--------------------------------------------------------------------------------------------------------------------
Typ=96 Len=34: 73,65,6c,65,63,74,20,2a,20,66,72,6f,6d,20,64,65,70,74,20,77,68,65,72,65,20,64,65,70,74,6e,6f,3d,31,30

--//我使用的cpu是intel系列的,存在大小頭問題,在記憶體中看到的應該4個位元組4個位元組顛倒.前面4個應該是65,6c,65,73(16進位制).
--//BTW: 我的測試oradebug peek最多查詢60個位元組.

SYS@book> oradebug setmypid
Statement processed.

SYS@book> oradebug peek 0x000000007C631578 560 1
[07C631578, 07C6317A8) = 00000231 80B38F00 7C631500 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00080050 803CBD30 00000000 ...
SYS@book> oradebug tracefile_name
/u01/app/oracle/diag/rdbms/book/book/trace/book_ora_7077.trc

5.檢視轉儲:

*** 2018-06-25 09:05:02.603
Processing Oradebug command 'peek 0x000000007C631578 560 1'
[07C631578, 07C6317A8) = 00000231 80B38F00 7C631500 00000000 00000000 ...
Dump of memory from 0x07C63158C to 0x07C6317A8
07C631580                            00000000              [....]
07C631590 00000000 00000000 00000000 00000000  [................]
07C6315A0 00000000 00080050 803CBD30 00000000  [....P...0.<.....]
07C6315B0 803CBD30 00000000 7DBA6660 00000000  [0.<.....`f.}....]
07C6315C0 7C631700 00000000 00010000 10012841  [..c|........A(..]
07C6315D0 00000001 00000001 00010001 00000002  [................]
07C6315E0 00000000 00000005 00010000 00000000  [................]
07C6315F0 00000000 00000000 7C631778 00000000  [........x.c|....]
07C631600 00000001 00000000 7C631608 00000000  [..........c|....]
07C631610 7C631608 00000000 7C631618 00000000  [..c|......c|....]
07C631620 7C631618 00000000 7BF9D778 00000000  [..c|....x..{....]
07C631630 7BF9D778 00000000 7C631638 00000000  [x..{....8.c|....]
07C631640 7C631638 00000000 7D654A40 00000000  [8.c|....@Je}....]
07C631650 7D654A40 00000000 00000000 00000000  [@Je}............]
07C631660 00000001 00000000 4EAA74D5 00000000  [.........t.N....]
07C631670 0000F131 00000000 7C6316E8 00000000  [1.........c|....]
07C631680 7C631680 00000000 7C631680 00000000  [..c|......c|....]
07C631690 7C631690 00000000 7C631690 00000000  [..c|......c|....]
07C6316A0 00000000 00000000 7FC47F68 00000000  [........h.......]
07C6316B0 00000000 00000000 00000000 00000000  [................]
07C6316C0 00000003 00000001 00020002 00000000  [................]
07C6316D0 00000001 00000000 00000000 00000000  [................]
07C6316E0 00000000 00000000 00000000 00000000  [................]
07C6316F0 00000021 00000000 3650F131 00000000  [!.......1.P6....]
07C631700 1431C45D BDDBB9E7 4EAA74D5 3650F131  [].1......t.N1.P6]
07C631710 00000000 19067678 0011030A 00000000  [....xv..........]
07C631720 00000000 00000000 00000023 00000000  [........#.......]
07C631730 00000000 00000000 00000000 00000000  [................]
07C631740 7C631750 00000000 3650F131 00000053  [P.c|....1.P6S...]
07C631750 656C6573 2A207463 6F726620 6564206D  [select * from de]
07C631760 77207470 65726568 70656420 3D6F6E74  [pt where deptno=]
07C631770 00003031 00000000 00000000 00000000  [10..............]
07C631780 00000000 00000000 00000000 00000000  [................]
        Repeat 1 times
07C6317A0 00000000 00000000                    [........]

--//可以發現sql語句的內容.

*** 2018-06-25 09:05:02.604
Oradebug command 'peek 0x000000007C631578 560 1' console output:
[07C631578, 07C6317A8) = 00000231 80B38F00 7C631500 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00080050 803CBD30 00000000 ...

*** 2018-06-25 09:05:12.659
Processing Oradebug command 'tracefile_name'

--//透過這樣的方式提供快捷的方式檢視記憶體地址的相關內容.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2156597/,如需轉載,請註明出處,否則將追究法律責任。

相關文章