Determining glibc version
- From C, use confstr(3) with _CS_GNU_LIBC_VERSION and _CS_GNU_LIBPTHREAD_VERSION.
- libdank provides confstr_dyn(), a convenience wrapper
- On the command line, getconf(1) can be used:
- getconf GNU_LIBC_VERSION, getconf GNU_LIBPTHREAD_VERSION
Memory Utilities
- What is mudflap? FIXME
- Memory traces: if code calls
mtrace(), then the environment variable MALLOC_TRACE is checked for a filename. If this file can be written to/created, it'll be truncated, and hooks will be installed so that all allocations and deallocations are dumped to the file. The mtrace(1) tool (part of glibc) can then be used to generate human-readable output from this file, especially if the source code is available.
- Heap consistency checking: A less efficient allocation system can be used, which detects certain classes of errors. Link with -lmcheck, or call
mcheck(3) prior to any allocations, or define MALLOC_CHECK_ to be 1 (to print a warning) or 2 (to generate SIGABRT). mprobe(3) is available in this mode, which upon invocation performs extra checks on specified blocks.
- Statistics:
mallinfo(3) can be called at any time to collect statistics from the allocator. Beware: this function returns a large struct on the stack (unless its prototype is ever changed), and can thus be incredibly slow!