• [20180625]oradebug peek 2.txt


    [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'

    --//通过这样的方式提供快捷的方式查看内存地址的相关内容.

  • 相关阅读:
    ORACLE字符串函数
    Ubuntu14.04安装wineqq国际版
    phonegap学习笔记
    Android Studio 1.5.1
    CodeBlocks+Qt(MinGW)配置
    Java多线程之synchronized(五)
    Java多线程之synchronized(四)
    Java多线程之synchronized(三)
    Java多线程之synchronized(二)
    Java多线程之synchronized(一)
  • 原文地址:https://www.cnblogs.com/lfree/p/9248888.html
Copyright © 2020-2023  润新知