本文转自 xkdcc 51CTO博客,原文链接:http://blog.51cto.com/brantc/116670,如需转载请自行联系原作者 To use Purify API functions, include <purifyhome>/purify.h in your code and link with <purifyhome>/purify_stubs.a.
In Makefile, you should write as follow for C++:
LINK_FLAGS = - L/usr/local/rational/releases/purify.i386_linux2.2003a.06.15/purify_staubs.a
LINK_PURIFY = purify –cache-dir=$(HOME)/.cache gcc $(LINK_FLAGS)
main.purify:$(OBJS)
$(LINK_PURIFY) –lstdc++ -o main.purify $(OBJS)
Commonly used API functions
|
|
int purify_describe (char *addr)
|
Prints specific details about memory
|
int purify_is_running (void)
|
Returns "TRUE" if the program is instrumented
|
int purify_new_inuse (void)
|
Prints a message . all memory newly in use
|
int purify_new_leaks (void)
|
Prints a message . all new leaks
|
int purify_new_fds_inuse (void)
|
Lists the new open file de.ors
|
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)
|
|
int purify_watch_remove (int watchno)
|
Removes a specified watchpoint
|
int purify_what_colors (char *addr, int size)
|
Prints the color coding of memory
|
Purify messages
Purify reports the following messages. For detailed, platform-specific information, see the Purify .line help system.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Potential Leak(
is memory that does not have a pointer to its beginning,but does have .e to its interior)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Freeing Mismatched Memory
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Uninitialized Memory Copy
|
|
|
|
|
|
Uninitialized Memory Read
|
|
|
Freeing Unallocated Memory
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* Message severity: F=Fatal, C=Corrupting, W=Warning, I=Informational