Purify使用指南

  • 1. 簡(jiǎn)介

    成都創(chuàng)新互聯(lián)是一家專注于網(wǎng)站建設(shè)、成都做網(wǎng)站與策劃設(shè)計(jì),兩當(dāng)網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:兩當(dāng)?shù)鹊貐^(qū)。兩當(dāng)做網(wǎng)站價(jià)格咨詢:18982081108

  • 2. 安裝

    • 2.1. 安裝license

    • 2.2. 安裝Purify

  • 3. 使用

    • 3.1. 查看幫助

    • 3.2. 使用步驟   ATTACH

    • 3.3. 查看BUG   ATTACH

    • 3.4. 定位BUG在源代碼中的位置   ATTACH

    • 3.5. 查找泄漏的內(nèi)存   ATTACH

    • 3.6. 修改BUG   ATTACH

    • 3.7. 隱藏消息   ATTACH

  • 4. 保存/載入結(jié)果

    • 4.1. 保存結(jié)果

    • 4.2. 載入結(jié)果

  • 5. API

  • 6. 命令選項(xiàng)

    • 6.1. Build-time options

    • 6.2. Runtime options

1 簡(jiǎn)介

Purify是IBM開(kāi)發(fā)的,用于定位C、C++代碼中bug和內(nèi)存泄漏位置的自動(dòng)化工具。

Purify的特點(diǎn)有:

  • Purify會(huì)檢查程序運(yùn)行時(shí)用到的所有代碼,包括程序本身的代碼,操作系統(tǒng)提供的代碼和第三方庫(kù)的代碼。

  • Purify支持對(duì)多進(jìn)程和對(duì)線程的程序進(jìn)行檢測(cè)。

  • Purify支持windows,linux和UNIX平臺(tái)。

2 安裝

2.1 安裝license

  1. 運(yùn)行腳本license_setup

    [cnaps2]:/home/cnaps2/PurifyPlus.7.0.1.0-006>./license_setup
  2. 按回車(chē)?yán)^續(xù)

    ------------------------------------------------------------------------------
    License Setup                  IBM Corporation                 Version: 2.198
    ------------------------------------------------------------------------------
    
                                  Using License Setup
    
        You are running the license_setup command as cnaps2.
    
        Output from license_setup will be copied to a log file.  When you exit
        license_setup or license_setup completes, the location of the log file
        is displayed.
    
        The -help option can be used to display license_setup command line options.
        All of your inputs will be saved for future runs of license_setup.
    
        You can enter a q, q! or ? at any prompt:
        q    Will save your inputs and quit license_setup.
        q!   Quit license_setup without saving your inputs.
             Note that the 'Rational' directory is always saved.
        ?    Get help on the current prompt.
    
        Press the Enter key to continue, q to quit license_setup:
  3. 按回車(chē)?yán)^續(xù)

        Rational PurifyPlus for Linux and UNIX - Enter Install Location
    
    Enter the location to install IBM Rational products.
    This will be referred to as the 'Rational' directory.
    In 'Rational' directory, license_setup will create a releases
    directory to keep all of the products by name and version.
    
    For example, in 'Rational'/releases, this install will
    create a 'PurifyPlus.7.0.1.0-006' directory to install
    Rational PurifyPlus for Linux and UNIX 7.0.1.0-006.
    
    The 'Rational' directory must be accessible from
    every machine where you plan to run these IBM Rational products.
    The 'Rational' directory path must be identical on each machine.
    Thus, an automount path like /tmp_mnt/rational should not be used
    because you cannot access this directory from every machine.
    
    Checking for 'Rational' directories..  None found.
    
    Press the Enter key to continue, q to quit license_setup:
  4. 輸入安裝將要安裝Purify的目錄

        Rational PurifyPlus for Linux and UNIX - Enter Install Location
    
    Enter the location to install IBM Rational products.
    This will be referred to as the 'Rational' directory.
    In 'Rational' directory, license_setup will create a releases
    directory to keep all of the products by name and version.
    
    For example, in 'Rational'/releases, this install will
    create a 'PurifyPlus.7.0.1.0-006' directory to install
    Rational PurifyPlus for Linux and UNIX 7.0.1.0-006.
    
    The 'Rational' directory must be accessible from
    every machine where you plan to run these IBM Rational products.
    The 'Rational' directory path must be identical on each machine.
    Thus, an automount path like /tmp_mnt/rational should not be used
    because you cannot access this directory from every machine.
    
    Checking for 'Rational' directories..  None found.
    
    Press the Enter key to continue, q to quit license_setup: 
    
    Enter 'Rational' directory: /home/cnaps2
  5. 按1接收許可協(xié)議

              Initializing AIX JRE to display license agreement...
        Done.
    
        Please ignore the messages related to 'Could not lock System prefs.'
        It is a known issue with the JRE on AIX.
    
        Running LAP Tool:
    /home/cnaps2/releases/jre142.aix/jre/bin/java -classpath extras/LAP/lib/lapapp.jar:extras/LAP/lib/i18n.jar:/home/cnaps2/sqllib/java/db2java.zip:/home/cnaps2/sqllib/java/sqlj.zip:/home/cnaps2/sqllib/function:/home/cnaps2/sqllib/java/db2jcc_license_cu.jar:/home/cnaps2/sqllib/tools/clpplus.jar:/home/cnaps2/sqllib/tools/antlr-3.2.jar:/home/cnaps2/sqllib/tools/jline-0.9.93.jar:/home/cnaps2/sqllib/java/db2jcc.jar:. com.ibm.lex.lapapp.LAP -l extras/LAP/LA_files -text_only -s /home/cnaps2/releases/PurifyPlus.7.0.1.0-006
    ------------------------------------------------------------------------------
    重要信息:請(qǐng)仔細(xì)閱讀
    
    下面提供了兩個(gè)許可協(xié)議。
    
    1. 評(píng)估程序的國(guó)際許可協(xié)議
    2. 國(guó)際程序許可協(xié)議
    
    如果被許可方為了生產(chǎn)性使用目的(而不是為了評(píng)估、測(cè)試、試用“先試后
    買(mǎi)”或演示)獲得本程序,單擊下面的“接受”按鈕即表示被許可方接受 
    國(guó)際程序許可協(xié)議,且不作任何修改。
    
    如果被許可方為了評(píng)估、測(cè)試、試用“先試后買(mǎi)”或演示(統(tǒng)稱為“評(píng)
    估”)目的獲得本程序:?jiǎn)螕粝旅娴摹敖邮堋卑粹o即表示被許可方同時(shí)接受
    (i)評(píng)估程序的國(guó)際許可協(xié)議(“評(píng)估許可”),且不作任何修改;和
    (ii)國(guó)際程序許可協(xié)議(“IPLA”),且不作任何修改。
    
    
    按 Enter 鍵繼續(xù)查看本許可協(xié)議或按 "1" 接受本協(xié)議,按 
    "2" 拒絕本協(xié)議,按 "3" 打印本協(xié)議,按 "5" 用英語(yǔ)查
    看,或按 "99" 回到上一屏幕。
    1
  6. 按1選擇Rational PurifyPlus for Linux and UNIX

              cnaps2 accepts the license agreement on 公元2014年07月31日  星期四  17時(shí)25分22秒.
    ------------------------------------------------------------------------------
                        Rational PurifyPlus for Linux and UNIX 
                   Product and License Configuration Selection Menu 
    
        Make a selection that best describes your desired license set up.
    
        Enter option 1 if you are doing license set up for:
          Rational PurifyPlus for Linux and UNIX
    
        Enter option 2 if you are doing license set up for:
          Rational Purify/Quantify/PureCoverage
    
        You can only select one item from the list.
        These products require FLEXlm licensing.  Enter option 'e' to see the
        specific FLEXlm licenses for each product.
    
            PurifyPlus or Individual License Configuration:
        1)  Rational PurifyPlus for Linux and UNIX 
        2)  Rational Purify/Quantify/PureCoverage Individual Licensing 
        3)  License setup only - IBM Rational products 
    
        e)  Explain what licenses are needed for each product.
        d)  Download the latest version of the license_setup command from
            ftp.software.ibm.com and run it.
        b)  Back to the previous menu.
        q)  Quit license_setup.  Enter q! to quit without saving your inputs.
        ?)  Help.
    
        Enter option: [e] 1
  7. 按2選擇設(shè)置license文件

        Enter option: [e] 1
    
        Installing: FLEXlm 11.8 for Solaris SPARC...
        from: /home/cnaps2/PurifyPlus.7.0.1.0-006/extras/flexlm.sol
          to: /home/cnaps2/base/cots/flexlm.11.8/sun4_solaris2
    
        Installing: FLEXlm 11.8 for Solaris x64...
        from: /home/cnaps2/PurifyPlus.7.0.1.0-006/extras/flexlm.solaris_x64
          to: /home/cnaps2/base/cots/flexlm.11.8/solaris_x64
    
        Installing: FLEXlm 11.8 for AIX...
        from: /home/cnaps2/PurifyPlus.7.0.1.0-006/extras/flexlm.aix
          to: /home/cnaps2/base/cots/flexlm.11.8/rs6k_aix
    
        Installing: FLEXlm 11.8 for Linux...
        from: /home/cnaps2/PurifyPlus.7.0.1.0-006/extras/flexlm.i386_linux2
          to: /home/cnaps2/base/cots/flexlm.11.8/i386_linux2
    ------------------------------------------------------------------------------
    
                          PurifyPlus - Licensing Options Menu
    
        Select one of the following 2 licensing options.
    
         1)  Use an existing IBM Rational license file (permanent or temporary) or license
             server for PurifyPlus 7.0.1.0-006.
         2)  Set up a license server using a permanent or term-license-agreement (TLA) license.
             You need a .upd license file to import into license_setup.
    
         b)  Back to the previous menu.
         e)  Explain the licensing options in more detail.
         q)  Quit license_setup.  Enter q! to quit without saving your inputs.
    
        Enter license option: [e] 2
  8. 輸入license文件的路徑

      ------------------------------------------------------------------------------
    
                          PurifyPlus - Import Licenses
    
    The import file you specify should be from a file you saved from an
    e-mail message you received from IBM.  This is not the
    license file license_setup will set up.  It is the license information this
    program will import to make decisions about what product(s) you
    have licensed and how the licenses should be set up with as a FLEXlm
    license server.
    
    The file is called something like license_for_server.upd.
    The file must contain FLEXlm SERVER and INCREMENT lines for
    PurifyPlus.
    
    Currently, license_setup cannot import a redundant server license file.
    
    If you do not have a .upd file to import licenses from, enter none.
    
    File to import from: [none] /home/cnaps2/PurifyPlus.7.0.1.0-006/IBM.Rational.PurifyPlus.v7.1.lic.eval.upd
  9. 選擇1檢查license文件

                            PurifyPlus - License Check Menu
    
    ---> 1)  Check license keys in:
             /home/cnaps2/PurifyPlus.7.0.1.0-006/IBM.Rational.PurifyPlus.v7.1.lic.eval.upd
             Will check for these licenses:
    
    License Feature                  Description
    PurifyPlusUNIX                   Rational PurifyPlus for UNIX
    DevelopmentStudioUNIX            Rational Suite DevelopmentStudio for UNIX
    DevelopmentStudioUNIXRT          Rational Suite DevelopmentStudio RealTime for
                                       UNIX
    purecov                          Rational PureCoverage for UNIX
    purify                           Rational Purify for UNIX
    quantify                         Rational Quantify for UNIX 
    
         The license server is not needed for uncounted licenses:
    
         2)  No need to start or restart the license server.
    
         3)  No need to check license server using lmstat--licenses are uncounted.
    
         4)  License settings for PurifyPlus up-to-date.
    
         b)  Back to the previous menu.
         q)  Quit license_setup.  Enter q! to quit without saving your inputs.
         ?)  Help.
    
        Enter menu option: [1]
  10. license文件檢查通過(guò)后按回車(chē)?yán)^續(xù)

        Will check for these specific licenses:
    
    License Feature                  Description
    PurifyPlusUNIX                   Rational PurifyPlus for UNIX
    DevelopmentStudioUNIX            Rational Suite DevelopmentStudio for UNIX
    DevelopmentStudioUNIXRT          Rational Suite DevelopmentStudio RealTime for
    								   UNIX
    purecov                          Rational PureCoverage for UNIX
    purify                           Rational Purify for UNIX
    quantify                         Rational Quantify for UNIX
    
        Searching for 'ibmratl' specific license keys in:
          /home/cnaps2/PurifyPlus.7.0.1.0-006/IBM.Rational.PurifyPlus.v7.1.lic.eval.upd
        No ibmratl specific licenses found.
    
        Searching for 'rational' specific license keys...
        One rational specific license found.
    
        All 'rational' license keys are okay in:
          /home/cnaps2/PurifyPlus.7.0.1.0-006/IBM.Rational.PurifyPlus.v7.1.lic.eval.upd
    
        Searching for 'telelogic' specific license keys...
        No telelogic specific licenses found.
    
        Press the Enter key to continue, q to quit license_setup:
  11. 按q退出,自此license安裝完畢

                            PurifyPlus - License Check Menu
    
         1)  Check license keys in:
             /home/cnaps2/PurifyPlus.7.0.1.0-006/IBM.Rational.PurifyPlus.v7.1.lic.eval.upd 
    
         The license server is not needed for uncounted licenses:
    
         2)  No need to start or restart the license server.
    
         3)  No need to check license server using lmstat--licenses are uncounted.
    
         4)  License settings for PurifyPlus up-to-date.
    
         b)  Back to the previous menu.
    ---> q)  Quit license_setup.  Enter q! to quit without saving your inputs.
         ?)  Help.
    
        Enter menu option: [q]

2.2 安裝Purify

  1. 運(yùn)行rs_install

    [cnaps2]:/home/cnaps2/PurifyPlus.7.0.1.0-006>./rs_install
    ------------------------------------------------------------------------------
    RS Install                     IBM Corporation                 Version: 2.198
    ------------------------------------------------------------------------------
    
                                    Using RS Install
    
        You are running the rs_install command as cnaps2.
    
        Output from rs_install will be copied to a log file.  When you exit
        rs_install or rs_install completes, the location of the log file
        is displayed.
    
        The -help option can be used to display rs_install command line options.
        All of your inputs will be saved for future runs of rs_install.
    
        You can enter a q, q! or ? at any prompt:
        q    Will save your inputs and quit rs_install.
        q!   Quit rs_install without saving your inputs.
             Note that the 'Rational' directory is always saved.
        ?    Get help on the current prompt.
    
        Press the Enter key to continue, q to quit rs_install:
  2. 按回車(chē)?yán)^續(xù)

    ------------------------------------------------------------------------------
    
            Rational PurifyPlus for Linux and UNIX - Enter Install Location
    
        Enter the location to install IBM Rational products.
        This will be referred to as the 'Rational' directory.
        In 'Rational' directory, rs_install will create a releases
        directory to keep all of the products by name and version.
    
        For example, in 'Rational'/releases, this install will
        create a 'PurifyPlus.7.0.1.0-006' directory to install
        Rational PurifyPlus for Linux and UNIX 7.0.1.0-006.
    
        The 'Rational' directory must be accessible from
        every machine where you plan to run these IBM Rational products.
        The 'Rational' directory path must be identical on each machine.
        Thus, an automount path like /tmp_mnt/rational should not be used
        because you cannot access this directory from every machine.
    
        Checking for 'Rational' directories..  One found.
    
        Enter 'Rational' directory: [/home/cnaps2]
  3. 輸入安裝目錄

    Enter 'Rational' directory: [/home/cnaps2] /home/cnaps2
  4. 選擇1Rational PurifyPlus for Linux and UNIX

        cnaps2 accepted the license agreement on 公元2014年07月31日  星期四  17時(shí)25分22秒.
    ------------------------------------------------------------------------------
                        Rational PurifyPlus for Linux and UNIX 
                   Product and License Configuration Selection Menu 
    
        Make a selection that best describes your desired installation.
    
        Enter option 1 if you are installing and have a license for:
          Rational PurifyPlus for Linux and UNIX
    
        Enter option 2 if you are installing and have a license for:
          Rational Purify/Quantify/PureCoverage
    
        You can only select one item from the list.
        These products require FLEXlm licensing.  Enter option 'e' to see the
        specific FLEXlm licenses for each product.
    
            PurifyPlus or Individual License Configuration:
    --> 1)  Rational PurifyPlus for Linux and UNIX 
        2)  Rational Purify/Quantify/PureCoverage Individual Licensing 
        3)  License setup only - IBM Rational products 
    
        e)  Explain what licenses are needed for each product.
        d)  Download the latest version of the rs_install command from
            ftp.software.ibm.com and run it.
        b)  Back to the previous menu.
        q)  Quit rs_install.  Enter q! to quit without saving your inputs.
        ?)  Help.
    
        Enter option: [1] 1
  5. 輸入yes,表示使用之前選定的license文件

        Installed: FLEXlm 11.8 for Solaris SPARC
    
        Installed: FLEXlm 11.8 for Solaris x64
    
        Installed: FLEXlm 11.8 for AIX
    
        Installed: FLEXlm 11.8 for Linux
    
        Installed: FLEXlm 11.8 for Solaris SPARC
    
        Installed: FLEXlm 11.8 for Solaris x64
    
        Installed: FLEXlm 11.8 for AIX
    
        Installed: FLEXlm 11.8 for Linux
    
        Checking if PurifyPlus license is configured:
    Rational PurifyPlus for UNIX
          yes: /home/cnaps2/PurifyPlus.7.0.1.0-006/IBM.Rational.PurifyPlus.v7.1.lic.eval.upd  (Has product licenses)
    
        Found one license file:
    
        /home/cnaps2/PurifyPlus.7.0.1.0-006/IBM.Rational.PurifyPlus.v7.1.lic.eval.upd contains:
        License: PurifyPlusUNIX  Evaluation key expires: 15-aug-2014  
    
        Would you like to configure PurifyPlus
        to use this license file? [yes] yes
  6. 輸入1,安裝默認(rèn)組件

                     PurifyPlus - Typical/Custom Install Preference
    
        Choose the install option you prefer:
    
    ---> 1)  Typical      Install recommended product components.
    
         2)  Custom       Select specific product components to install.
    
         b)  Back to the previous menu.
         f)  Forward to install and post-install PurifyPlus now.
         q)  Quit rs_install.  Enter q! to quit without saving your inputs.
         ?)  Help.
    
        Enter install preference: [1]
  7. 選擇f,表示確定

    ------------------------------------------------------------------------------
    
                     PurifyPlus - Typical/Custom Install Preference
    
        Choose the install option you prefer:
    
         1)  Typical      Install recommended product components.
    
         2)  Custom       Select specific product components to install.
    
        You have chosen to do a typical install.
    
         b)  Back to the previous menu.
    ---> f)  Forward to install and post-install PurifyPlus now.
         q)  Quit rs_install.  Enter q! to quit without saving your inputs.
         ?)  Help.
    
        Enter install preference: [f]
  8. Purify會(huì)自動(dòng)檢測(cè)操作系統(tǒng),并安裝相應(yīng)版本的程序

    ------------------------------------------------------------------------------
    
                                  Documentation Table
    
        The docs/ directory on the release media contains the on-line
        documentation for the product.  This may include the installation
        guide, release note, getting started docs or on-line help.
    
             Install?   Size (KB)  Product Documentation
             --------   ---------  ---------------------
         1)       yes       14164  Documents in HTML. (Documentation)
         2)       yes        3756  Documents for Adobe Acrobat reader. (Documentation)
         3)       yes           1  Rs Help List (Documentation)
             --------   ---------  ---------------------
                  all       17921  Total (does not account for documents
                                          already installed.)
    
        Updating:   /home/cnaps2/config/PurifyPlus_License_Map [rev 198]
    Rational PurifyPlus for UNIX
    ------------------------------------------------------------------------------
    
    
       ......
    
        Creating/updating setup files
        in /home/cnaps2/releases/PurifyPlus.7.0.1.0-006...
             Created: purifyplus_setup.csh in PurifyPlus.7.0.1.0-006
             Created: purifyplus_setup.sh in PurifyPlus.7.0.1.0-006
    
        You can source the setup file to help you start the programs in this
        install.  If you are installing this for users in addition to yourself
        you will want to have them add one of these commands to their login
        environment.
    
        Users of csh, tcsh and other csh-compatible shells do this:
    
    source /home/cnaps2/purifyplus_setup.csh
    
        Users of sh, ksh, bash and other bourne-compatible shells do this:
    
    . /home/cnaps2/purifyplus_setup.sh
    
    ------------------------------------------------------------------------------
        The rs_install command completed successfully.
        Defaults saved in:
        /home/cnaps2/config/defaults/rs_install.PurifyPlus.7.0.1.0-006.cnaps2
        rs_install log file:
        /home/cnaps2/releases/PurifyPlus.7.0.1.0-006/rs_install.L2601H8.cnaps2.log
    
        End of rs_install.

3 使用

3.1 查看幫助

  • 使用web瀏覽器查看幫助文檔

    purify -onlinehelp

  • 查看完整的在線幫助

    菜單Help>Help topics

    菜單Help>On window

    菜單Help>On content

3.2 使用步驟   ATTACH

  1. 只要將purify放在普通的編譯/鏈接命令前

    purify cc -g hello.c

    若編譯和鏈接是分成不同的步驟分布進(jìn)行的,則只需要將purify放在鏈接操作前即可.

    cc -c -g hello.c
    purify cc -g hello.o
  2. 執(zhí)行編譯出來(lái)的程序.

    程序會(huì)照常運(yùn)行,并顯示Purify Viewer窗口展示找到的BUG.

    Purify使用指南

    值得一提的是,Purify在找到BUG后并不會(huì)暫停程序的執(zhí)行,程序的啟動(dòng),運(yùn)行,退出與原程序一般無(wú)疑.

    Purify使用指南

3.3 查看BUG   ATTACH

Purify使用指南

NOTE: Purify Viewer一次只顯示一個(gè)可執(zhí)行程序的信息. 它會(huì)指明所顯示的可執(zhí)行程序名稱,所處于的目錄和執(zhí)行該程序的用戶ID

Purify使用指南

3.4 定位BUG在源代碼中的位置   ATTACH

Purify使用指南

NOTE: 若在編譯時(shí)使用了-g選項(xiàng),則Purify View會(huì)顯示BUG所在的源文件,行號(hào)和涉及的變量名. 若沒(méi)有帶-g選項(xiàng),則只能顯示文件名和函數(shù)名.

Purify使用指南

3.5 查找泄漏的內(nèi)存   ATTACH

當(dāng)程序退出,Purify會(huì)查找泄漏的內(nèi)存并給出未釋放的內(nèi)存報(bào)告.

Purify將內(nèi)存分為三個(gè)狀態(tài),每個(gè)狀態(tài)都會(huì)統(tǒng)計(jì)內(nèi)存塊的數(shù)量和大小.

  • Leaked memory

    沒(méi)有指針指向這塊內(nèi)存

  • Potentially Leaked memory

    沒(méi)有指針指向這塊內(nèi)存的頭部,但是有指針指向這塊內(nèi)存的內(nèi)部.

  • Memory in use

    有指針指向的內(nèi)存塊(不存在泄漏的情況)

    Purify使用指南

NOTE: 若運(yùn)行的是一個(gè)需要長(zhǎng)期不退出的程序,可以在程序尚在運(yùn)行時(shí),通過(guò)單擊菜單欄中的`New Leaks tool`按鈕來(lái)產(chǎn)生內(nèi)存泄漏的情況報(bào)告.

Purify使用指南

3.6 修改BUG   ATTACH

按下Edit tool按鈕(工具欄第5個(gè)按鈕顯示是一支筆寫(xiě)文檔)會(huì)打開(kāi)編輯器供你修改源代碼

NOTE: 默認(rèn)情況下,Purify View只顯示7行相關(guān)的源代碼. 但你可以通過(guò)修改Xresource來(lái)修改顯示的行數(shù)

3.7 隱藏消息   ATTACH

若檢測(cè)的程序很大,則可能會(huì)產(chǎn)生成百上千的關(guān)于BUG的信息報(bào)告. 這種情況下,要想快速的定位到最重要的BUG位置,可以隱藏指定類型或來(lái)源的信息.

在Purify viewer中隱藏消息的方法為:

  1. 選擇想隱藏的消息

  2. 選擇菜單Options>Suppressions

    在Message to suppress處選擇要隱藏的消息的類型

    在Where to suppress處選擇要隱藏的消息的來(lái)源

    按下左下方的`Make permanent`按鈕會(huì)將隱藏配置保持在.purify文件中

    右下方的`Select File…`按鈕可以選擇保持隱藏配置的.purify文件

    Purify使用指南Purify使用指南

4 保存/載入結(jié)果

Purify可以將檢測(cè)的結(jié)果保存到后綴為.pv的Purify View file中, 也可以從Purify View file中載入檢測(cè)結(jié)果

4.1 保存結(jié)果

  1. 選擇菜單`File>Save As`

  2. 輸入保存的文件名,后綴名使用.pv,表示為Purify view file

4.2 載入結(jié)果

有兩種方式載入結(jié)果文件

  1. 從View中選擇菜單`File>Open`,打開(kāi)Purify view file

  2. 在命令行運(yùn)行:

    purify -view filename.pv

5 API

Purify提供了一系列的API可以插入到源代碼中提供更個(gè)性化的檢測(cè)功能.

要使用Purify API,需要include `<purifyhome>/purify.h`并且鏈接庫(kù)`<purifyhome/purify_stubs.a>`

Table 1: Purify API簡(jiǎn)要說(shuō)明
Commonly used APIfunctions Description
int purify_describe (char *addr)Prints specific de tails about memory
int purify_is_running (void)Returns "TRUE" if the program is instrumented
int purify_new_inuse (void)Prints a message on all memory newly in use
int purify_new_leaks (void)Prints a message on all new leaks
int purify_new_fds_inuse (void)Lists the new open file descriptors
int purify_printf (char *format, …)Prints formatted text to the Viewer or log-file
int purify_watch (char *addr)Watches for memory write ,  malloc, free
int purify_watch_n (char *addr, int size, char *type)Watches memory: type = " r", "w", "rw"
int purify_watch_info (void)Lists active watchpoints
int purify_watch_remove (int watchno)Removes a specified watchpoint
int purify_what_colors (char *addr, int size)Prints the color coding of memory

6 命令選項(xiàng)

6.1 Build-time options

在編譯時(shí)使用build-time options. 例如

purify -cache-dir=$HOME/cache -always-use-cache-dir cc -o hello hello.c
Table 2: Build-time options說(shuō)明
options說(shuō)明默認(rèn)值
-always-use-cache-dirForces all instrumented object files to be written to the global cache directoryno
-cache-dirSpecifies the global directory where Purify caches instrumented object files<purifyhome>/cache
-ignore-runtime-environmentPrevents the runtime Purify environment from overriding the option values used in building the programno
-linkerSets the alternative linker to build the executables instead of the system defaultsystem-dependent
-print-home-dirPrints the name of the directory wher e Purify is installed, then exits

6.2 Runtime options

Runtime options除了可以在使用purify時(shí)用帶option的方式生效,還能通過(guò)寫(xiě)到環(huán)境變量`PURIFYOPTIONS`中生效.例如

setenv PURIFYOPTIONS "-log-file=mylog.%v.%p ‘printenv PURIFYOPTIONS‘"
Table 3: 常用Runtime options說(shuō)明
選項(xiàng)說(shuō)明默認(rèn)值
-auto-mount-prefixRemoves the prefix used by file system auto-mounters/tmp_mnt
-chain-lengthSets the maximum number of stack frames to print in a report6
-fds-in-use-at-exitSpecifies that the file descriptor in us e message be displaye d at program exityes
-follow-child-processesControls whether Purify monitors child  processes in an instrumented programno
-jit-debugEnables just-in-time debuggingnone
-leaks-at-exitReports all leaked memory at program exityes
-log-fileWrites Purify output to a log file instead of the Viewer  windowstderr
-messagesControls display of repeated messages:  "first",  "all" , or in a  "batch" at program exitfirst
-program-nameSpecifies the full pathname of  the instrumented program if  argv[ 0] contains an undesirable or incorrect valueargv[ 0]
-show-directoryShows the directory path for each file in the call chain, if the information is availableno
-show-pcShows the full pc value in each frame of the call chainno
-show-pc-offsetAppends a pc-offset to each function name in the call chainno
-view-fileSaves Purify output to a view file ( .pv ) instead of the Viewer .none
-user-pathSpecifies a list of directories in which to search for programs and source codenone
-windowsRedirects Purify output to stderr instead of the  Viewer  if -windows=nonone

網(wǎng)站標(biāo)題:Purify使用指南
網(wǎng)站路徑:http://www.muchs.cn/article26/jiopjg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、外貿(mào)建站、網(wǎng)站設(shè)計(jì)、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)關(guān)鍵詞優(yōu)化、靜態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司