Search

ParaSoft

HOME
PRODUCTS
SUPPORT
ABOUT
WHAT'S NEW
EVENTS


Insure++

Quick facts

Add-on Modules:
   -INUSE
   -TCA

Comparisons

Technical Papers

Support & Manuals

FAQs

Recent Reviews

User Testimonials

Press Releases


Insure tool to debug c++





Building Shared Libraries With Insure++


Shared libraries can be built with Insure-compiled objects, but the exact commands vary widely across platforms. Here are the necessary steps for several supported platforms. If your platform does not yet appear, try to modify one of the given methods for your situation.

The commands are given in the context of a shared library containing one object, which is built from the source file foo.C. The file main.C contains the function main, which calls a function in foo.C. In each example, the first command shows how you should compile any objects which will end up in the shared library, the second shows how you should build the shared library, and the third shows how you should build the final executable.

  • DEC Alpha OSF/1 (Digital UNIX)

        insure -g -c foo.C
        ins_ld -shared -o libfoo.so foo.o
        insure -g -o foo main.C foo.so
    
  • HP HP-UX

        insure -g +z -c foo.C
        ins_ld -b -o libfoo.sl foo.o
        insure -g -o foo main.C  -L. -lfoo
    
  • IBM AIX

    detailed example

  • SGI IRIX

        insure -g -c foo.C
        ins_ld -shared -o libfoo.so foo.o
        insure -g -o foo main.C libfoo.so
    
  • Sun Solaris 5.X

        insure -G -KPIC -g -c foo.C
        CC -G -Bdynamic -o libfoo.so foo.o
        insure -g -o foo main.c libfoo.so
    

Here is an example for HP-UX:

If you build the source files

/* leak.c */
#include <stdio.h>
#include <stdlib.h>

leak()
{
  char *ptr;
  printf("in leak\n");
  ptr = malloc(10);
}

/* foo.c */
main()
{
  leak();
  exit(0);
}
with the commands
    insure -g +z -c foo.C
    ins_ld -b -o libfoo.sl leak.o
    insure -g -o foo main.C -L. -lfoo
You will see the following output when you run the program foo.
in leak
[leak.c:9] **LEAK_SCOPE**
>> }

  Memory leaked leaving scope: <return>

  Lost block : 0x40052928 thru 0x40052931 (10 bytes)
               block allocated at:
                          malloc()  (interface)
                            leak()  leak.c, 8

  Stack trace where the error occurred:
                            leak()  leak.c, 9

** TCA log data will be merged with tca.log **

For more information call (888) 305-0041, fax (626)305-9048, or email quality@parasoft.com

Tools to debug c++ and java
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft