Skip to content

C Library to trace allocation function calls

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE.txt
Unknown
COPYING.txt
Notifications You must be signed in to change notification settings

mfederczuk/memtrace

Repository files navigation

Memtrace

version: 3.0.0 Changelog   Documentation

About

Library to trace allocation function calls.

Memtrace is a C library to trace allocation function calls by printing them to stderr.
The calls are printed out in the format of "<source_file>:<line>: <function_name>(<args>...)[: <return_value>]".

Usage

Include memtrace3.h in source files that you want to debug.
It is not recommended to include memtrace3.h in any header files.

#include <memtrace3.h>
#include <stdlib.h>

int main() {
	void* ptr = malloc(64);
	free(ptr);
}

The target binary must be linked with the memtrace3 library.

cc main.c -lmemtrace3

Possible output:

main.c:5: malloc(64): 0x47c2a0
main.c:6: free(0x47c2a0)

Memtrace should purely be used for debugging purposes. To make sure that the end user, that is manually building and installing your software, doesn't need to download and install Memtrace themselves, you should wrap the directive where you include memtrace3.h inside a preprocessor if block, which should only be entered when compiling debug builds of your software.

#ifndef NDEBUG
 #include <memtrace3.h>
#endif

For more information visit the extensive documentation.

Download & Installation

Download the source code (by cloning the repository), build the library and install it.

git clone -b v3.0.0 -o memtrace3 https://github.com/mfederczuk/memtrace.git &&
	cd memtrace3 &&
	make &&
	sudo make install

Contributing

Read through the Contribution Guidelines if you want to contribute to this project.

License

Memtrace is licensed under both the Mozilla Public License 2.0 AND the Apache License 2.0.
For more information about copying and licensing, see the COPYING.txt file.

About

C Library to trace allocation function calls

Topics

Resources

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE.txt
Unknown
COPYING.txt

Code of conduct

Stars

Watchers

Forks