Topic
  • 4 replies
  • Latest Post - ‏2011-09-16T21:14:29Z by JerryCallen
JerryCallen
JerryCallen
9 Posts

Pinned topic Does Quantify on Windows have the ability to profile spawned processes?

‏2011-09-15T16:26:36Z |
I'm trying to profile a Windows application with Quantify, and the application creates processes that I would also like to profile. Does Quantify have any built-in ability to do that, or would I have to change the "CreateProcess" call to prepend "quantify" and some appropriate command-line option to the existing command line?

I am working with the trial edition of PurifyPlus 7.0.1, which doesn't seem to come with much in the way of documentation, and I don't see anything that looks like what I want when I do "quantify /?".
Updated on 2011-09-16T21:14:29Z at 2011-09-16T21:14:29Z by JerryCallen
  • SystemAdmin
    SystemAdmin
    2948 Posts

    Re: Does Quantify on Windows have the ability to profile spawned processes?

    ‏2011-09-15T16:36:31Z  
    Hi Jerry,

    >
    > I'm trying to profile a Windows application with Quantify, and the application
    > creates processes that I would also like to profile. Does Quantify have any
    > built-in ability to do that, or would I have to change the "CreateProcess" call
    > to prepend "quantify" and some appropriate command-line option to the existing
    > command line?
    >

    The best way to deal with this situation is probably to "pre-instrument" the exe
    that gets launched. In this manner, when FOO.exe is executed, it's actually the
    Quantify'd version that is being run. How is this done?

    1. Delete all files in your existing cache dir. (By default, this is probably
    C:\Program Files\IBM\RationalPurifyPlus\PurifyPlus\cache)
    2. Open a CMD shell
    3. Execute the following command to create an instrumented exe:
    DOS> quantify /run=no /replace=yes FOO.exe
    4. The original uninstrumented FOO.exe gets saved into FOO.exe.ORIGINAL while
    the new FOO.exe is actually a Quantify'd app.
    5. Add the following directories to your PATH environment variable:
    C:\Program Files\IBM\RationalPurifyPlus\PurifyPlus\cache
    C:\Program Files\IBM\RationalPurifyPlus\Common

    Now, when your program launches FOO.exe, it's actually the Quantify'd version that
    gets executed. (When you're done, just copy FOO.exe.ORIGINAL back to FOO.exe).

    Regards,
    Don
  • JerryCallen
    JerryCallen
    9 Posts

    Re: Does Quantify on Windows have the ability to profile spawned processes?

    ‏2011-09-15T17:41:07Z  
    Hi Jerry,

    >
    > I'm trying to profile a Windows application with Quantify, and the application
    > creates processes that I would also like to profile. Does Quantify have any
    > built-in ability to do that, or would I have to change the "CreateProcess" call
    > to prepend "quantify" and some appropriate command-line option to the existing
    > command line?
    >

    The best way to deal with this situation is probably to "pre-instrument" the exe
    that gets launched. In this manner, when FOO.exe is executed, it's actually the
    Quantify'd version that is being run. How is this done?

    1. Delete all files in your existing cache dir. (By default, this is probably
    C:\Program Files\IBM\RationalPurifyPlus\PurifyPlus\cache)
    2. Open a CMD shell
    3. Execute the following command to create an instrumented exe:
    DOS> quantify /run=no /replace=yes FOO.exe
    4. The original uninstrumented FOO.exe gets saved into FOO.exe.ORIGINAL while
    the new FOO.exe is actually a Quantify'd app.
    5. Add the following directories to your PATH environment variable:
    C:\Program Files\IBM\RationalPurifyPlus\PurifyPlus\cache
    C:\Program Files\IBM\RationalPurifyPlus\Common

    Now, when your program launches FOO.exe, it's actually the Quantify'd version that
    gets executed. (When you're done, just copy FOO.exe.ORIGINAL back to FOO.exe).

    Regards,
    Don
    That's a clever little trick. I'll give it a try and let you know how it worked out.
  • JerryCallen
    JerryCallen
    9 Posts

    Re: Does Quantify on Windows have the ability to profile spawned processes?

    ‏2011-09-16T18:51:40Z  
    I'm having some success with this, but it hasn't been very easy.

    First off, I want to correct something I wrote earlier: there is documentation with the trial version of PurifyPlus. It just doesn't work with Chrome. I copied the URL (C:\Program Files (x86)\IBM\RationalPurifyPlus\PurifyPlus\help\Quantify\Webhelp\quantify.htm) from Chrome's address bar, pasted it into IE9, and - voila! - documentation. (Let me guess: the help system is built with RoboHelp, which doesn't play nice with Chrome...)

    Next: I was able to instrument the subprocess executable pretty much as suggested, using a command line like this:

    quantify
    /RunTimeDataBase=0x20510000
    /RunTimeDataSize=0xfc50000
    /CacheDir=C:\svn\trunk\install\qcache
    /SelectiveInstrumentation
    /SelectedModuleList=C:\svn\trunk\install\lib\myprog.exe;
    /run=no /replace=yes
    C:\svn\trunk\install\lib\myprog.exe

    This creates:

    • myprog.exe.Original (a copy of myprog.exe)
    • myprog.exe.QSel (the instrumented executable)

    The original executable (myprog.exe) was left in place and not replaced by the instrumented executable. I manually deleted the original, renamed the "QSel" to the original name, and then ther instrumented executable ran autimatically when invoked as a spawned process from the main program.

    I was also able to get this to work on specific DLLs (my system load DLLs into a generic framework, sot eh executable itself isn't very interesting to profile). I used the same command line and renaming trick; the only difference was to replace myprog.exe on the command line with mything.dll.

    SO - thank you for the help!
  • JerryCallen
    JerryCallen
    9 Posts

    Re: Does Quantify on Windows have the ability to profile spawned processes?

    ‏2011-09-16T21:14:29Z  
    As long as the set of spawned programs is known and small, pre-instrumenting them is a straightforward approach to handling this.