Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Guidelines for using Purify

2025-03-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. Brief introduction

two。 Installation

2.1. Install license

2.2. Install Purify

3. Use

3.1. View help

3.2. Use step ATTACH

3.3. View BUG ATTACH

3.4. Locate the location of BUG in the source code ATTACH

3.5. Find leaked memory ATTACH

3.6. Modify BUG ATTACH

3.7. Hidden message ATTACH

4. Save / load results

4.1. Save the result

4.2. Load result

5. API

6. Command option

6.1. Build-time options

6.2. Runtime options

1 introduction

Purify is an automated tool developed by IBM to locate bug and memory leaks in C, C++ code.

The characteristics of Purify are:

Purify checks all the code used when the program is running, including the code of the program itself, the code provided by the operating system, and the code of third-party libraries.

Purify supports the detection of multiple processes and threaded programs.

Purify supports windows,linux and UNIX platforms.

2 install 2.1 install license

Run the script license_setup

[cnaps2]: / home/cnaps2/PurifyPlus.7.0.1.0-006 >. / license_setup

Press enter to continue

-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:

Press enter to continue

Rational PurifyPlus for Linux and UNIX-Enter Install LocationEnter the location to install IBM Rational products.This will be referred to as the 'Rational' directory.In' Rational' directory, license_setup will create a releasesdirectory to keep all of the products by name and version.For example, in 'Rational'/releases This install willcreate a 'PurifyPlus.7.0.1.0-006' directory to installRational PurifyPlus for Linux and UNIX 7.0.1.0-006.The 'Rational' directory must be accessible fromevery 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 usedbecause you cannot access this directory fromevery machine.Checking for 'Rational' directories.. None found.Press the Enter key to continue, q to quit license_setup:

Enter the directory where Purify will be installed

Rational PurifyPlus for Linux and UNIX-Enter Install LocationEnter the location to install IBM Rational products.This will be referred to as the 'Rational' directory.In' Rational' directory, license_setup will create a releasesdirectory to keep all of the products by name and version.For example, in 'Rational'/releases This install willcreate a 'PurifyPlus.7.0.1.0-006' directory to installRational PurifyPlus for Linux and UNIX 7.0.1.0-006.The 'Rational' directory must be accessible fromevery 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 usedbecause you cannot access this directory fromevery machine.Checking for 'Rational' directories.. None found.Press the Enter key to continue, q to quit license_setup: Enter 'Rational' directory: / home/cnaps2

Press 1 to receive the license agreement

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. Jarllib hinge homebank cnaps2 helix sqllibmax tools0.9.93.jarllibqqllibUnix sqllibUnix sqllibUnix javaGrex db2jcc.jarl.jarlllib. Com.ibm.lex.lapapp.LAP-l extras/LAP/LA_files-text_only-s / home/cnaps2/releases/PurifyPlus.7.0.1.0-006 Murray- Important: please read carefully the two license agreements provided below. 1. International license agreement for evaluation procedures 2. International Program license Agreement if the Licensee acquires the Program for productive use (rather than for evaluation, testing, or trial "try and buy" or demonstration), click the "accept" button below to indicate that the Licensee accepts the International Program license Agreement without any modification. If Licensee obtains this Program for evaluation, testing, trial "try and Buy" or demonstration (collectively referred to as "Evaluation"): by clicking the "accept" button below, Licensee also accepts (I) the International license Agreement for the Evaluation Program ("Evaluation license") without any modification; and (ii) International Program license Agreement ("IPLA") without any modification. Press the Enter key to continue to view this license agreement or press "1" to accept this agreement, press "2" to reject this agreement, press "3" to print this agreement, press "5" to view it in English, or press "99" to return to the previous screen. one

Press 1 to select Rational PurifyPlus for Linux and UNIX

17:25:22 on Thursday, July 31, 2014, cnaps2 accepts the license agreement on.-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

Press 2 to select the setup license file

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

Enter the path to the license file

-PurifyPlus-Import LicensesThe import file you specify should be from a file you saved from ane-mail message you received from IBM. This is not thelicense file license_setup will set up. It is the license information thisprogram will import to make decisions about what product (s) youhave licensed and how the licenses should be setup with as a FLEXlmlicense server.The file is called something like license_for_server.upd.The file must contain FLEXlm SERVER and INCREMENT lines forPurifyPlus.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

Select 1 to check the license file

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 DescriptionPurifyPlusUNIX Rational PurifyPlus for UNIXDevelopmentStudioUNIX Rational Suite DevelopmentStudio for UNIXDevelopmentStudioUNIXRT Rational Suite DevelopmentStudio RealTime for UNIXpurecov Rational PureCoverage for UNIXpurify Rational Purify for UNIXquantify 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]

Press enter to continue after the license file is checked.

Will check for these specific licenses:License Feature DescriptionPurifyPlusUNIX Rational PurifyPlus for UNIXDevelopmentStudioUNIX Rational Suite DevelopmentStudio for UNIXDevelopmentStudioUNIXRT Rational Suite DevelopmentStudio RealTime for UNIXpurecov Rational PureCoverage for UNIXpurify Rational Purify for UNIXquantify 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:

Press Q to exit and license has been installed since then

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 install Purify

Run rs_install

[cnaps2]: / home/cnaps2/PurifyPlus.7.0.1.0-006 >. / rs_install----RS Install IBM Corporation Version: 2.198Murray-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:

Press enter to continue

-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]

Enter the installation directory

Enter 'Rational' directory: [/ home/cnaps2] / home/cnaps2

Select 1Rational PurifyPlus for Linux and UNIX

17:25:22 on Thursday, July 31, 2014, cnaps2 accepted the license agreement on.-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

Enter yes to indicate the use of the previously selected license file

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

Enter 1 to install the default component

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]

Select f to indicate OK

-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]

Purify automatically detects the operating system and installs the appropriate version of the program

-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-006Created: purifyplus_setup.sh in PurifyPlus.7.0.1.0-006You 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 use 3.1 to view help

Use a web browser to view help documentation

Purify-onlinehelp

View the complete online help

Menu Help > Help topics

Menu Help > On window

Menu Help > On content

3.2Using step ATTACH

Just put purify in front of the normal compile / link command

Purify cc-g hello.c

If compilation and linking are distributed into different steps, you only need to put purify before the linking operation.

Cc-c-g hello.cpurify cc-g hello.o

Execute the compiled program.

The program will run as usual and display a Purify Viewer window showing the found BUG.

It is worth mentioning that Purify will not suspend the execution of the program after finding the BUG. There is no doubt that the start, run and exit of the program is the same as the original program.

3.3View BUG ATTACH

NOTE: Purify Viewer displays information about only one executable program at a time. It indicates the name of the executable program displayed, the directory it is in, and the ID of the user who executed the program.

3.4 locate the location of BUG in the source code ATTACH

NOTE: if the-g option is used at compile time, Purify View displays the source file where BUG is located, the line number and the variable name involved. Without the-g option, only the file name and function name can be displayed.

3.5.Look for leaked memory ATTACH

When the program exits, Purify looks for leaked memory and reports unfreed memory.

Purify divides memory into three states, each of which counts the number and size of memory blocks.

Leaked memory

There is no pointer to this memory.

Potentially Leaked memory

There is no pointer to the head of the memory, but there is a pointer to the inside of the memory.

Memory in use

A block of memory with a pointer to it (there is no leak)

NOTE: if you are running a program that does not quit for a long time, you can generate a memory leak report by clicking the `memory tool` button in the menu bar while the program is still running.

3.6 modify BUG ATTACH

Pressing the Edit tool button (the fifth button on the toolbar shows a pen to write the document) will open the editor for you to modify the source code

NOTE: by default, Purify View displays only 7 lines of related source code. But you can modify the number of rows displayed by modifying the Xresource

3.7 Hidden message ATTACH

If the testing program is large, it may produce hundreds of reports of information about BUG. In this case, to quickly locate the most important BUG location, you can hide the information of the specified type or source.

The way to hide messages in Purify viewer is:

Select the message you want to hide

Select menu Options > Suppressions

Select the type of message to hide at Message to suppress

Select the source of the message to hide at Where to suppress

Pressing the 'Make configuent` button at the bottom left will keep the hidden configuration in the .purify file

The `Select File on the lower right... The `button lets you choose to keep the configured .purify file hidden.

4 Save / load results

Purify can save the test results to Purify View file with the suffix .pv, or load the test results from Purify View file.

4.1 Save the results

Select the menu `File > Save As`

Enter the saved file name with a suffix of .pv, represented as Purify view file

4.2 load results

There are two ways to load the result file

Select the menu `File > Open` from View to open Purify view file

Run on the command line:

Purify-view filename.pv5 API

Purify provides a series of API that can be inserted into the source code to provide more personalized detection capabilities.

To use Purify API, you need include `/ purify.h` and link library ``

Table 1: Purify API briefly describes Commonly used APIfunctions Descriptionint purify_describe (char * addr) Prints specific de tails about memoryint purify_is_running (void) Returns "TRUE" if the program is instrumentedint purify_new_inuse (void) Prints a message on all memory newly in useint purify_new_leaks (void) Prints a message on all new leaksint purify_new_fds_inuse (void) Lists the new open file descriptorsint purify_printf (char * format, …) Prints formatted text to the Viewer or log-fileint purify_watch (char * addr) Watches for memory write, malloc, freeint purify_watch_n (char * addr, int size, char * type) Watches memory: type = "r", "w", "rw" int purify_watch_info (void) Lists active watchpointsint purify_watch_remove (int watchno) Removes a specified watchpointint purify_what_colors (char * addr, int size) Prints the color coding of memory6 command options 6.1 Build-time options

Use build-time options at compile time. For example

Purify-cache-dir=$HOME/cache-always-use-cache-dir cc-o hello hello.cTable 2: Build-time options description options specification default value-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/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 where Purify is installed, then exits

6.2 Runtime options

Runtime options can take effect not only with option when using purify, but also by writing to the environment variable `PURIFYOPTIONS`. For example

Setenv PURIFYOPTIONS "- log-file=mylog.%v.%p 'printenv PURIFYOPTIONS'" Table 3: common Runtime options description options description default value-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 use 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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report