Dr. Memory Documentation

repository·master·Indexed 25 days ago

https://github.com/dynamorio/drmemory

A high-performance memory monitoring and debugging tool built on the DynamoRIO dynamic instrumentation platform. It detects memory errors such as leaks, uninitialized memory access, buffer overflows, and double frees across Windows, Linux, Mac, and Android. The project also includes specialized Windows tools like drstrace for system call tracing and drltrace for library call tracing.

Tokens
993
Snippets
1
Records
9
Agent score
82%

What's inside Dr. Memory

  1. Overview of drltrace

    master
    drltrace is a standalone tool for Windows built on the Dr. Memory framework. It functions as a system call tracer that records calls to shared libraries. Specifically, it reports all invocations of exported functions across all shared libraries loaded into a target process.
  2. Overview of Dr. Memory capabilities

    master

    Dr. Memory is a memory monitoring tool used to identify various memory-related programming errors in unmodified application binaries. It supports Windows, Linux, Mac, and Android on IA-32, AMD64, and ARM hardware.

    Key errors detected include:

    • Accesses of uninitialized memory
    • Accesses to unaddressable memory (including heap underflow/overflow and accesses outside allocated heap units)
    • Accesses to freed memory
    • Double frees
    • Memory leaks
    • Windows specific: Handle leaks, GDI API usage errors, and accesses to un-reserved thread local storage slots.
  3. Overview of Dr. Memory

    master

    Dr. Memory is a memory monitoring tool used to identify memory-related programming errors. It is built on the DynamoRIO binary translation engine and supports Windows (XP and higher) and Linux. Beta support is available for Mac OSX, Linux/ARM, and Android/ARM (32-bit only).

    Key error detection capabilities include:

    • Accesses to uninitialized memory
    • Accesses to unaddressable memory (including heap underflow, overflow, and accesses outside allocated heap units)
    • Accesses to freed memory
    • Double frees
    • Memory leaks
    • Windows-specific: handle leaks, GDI API usage errors, and accesses to un-reserved thread local storage slots.

    Dr. Memory also includes a system call tracing tool for Windows and a symbol query utility.

  4. Quick start for Linux

    master

    To use Dr. Memory on Linux, first build your application with debug information using specific flags to ensure accurate error reporting, then run it through the bin/drmemory executable.

    Recommended build flags:

    • -g: Include debug information.
    • -fno-inline: Disable inlining.
    • -fno-omit-frame-pointer: Preserve frame pointers for better stack traces.
    • -m32: (Optional) Target 32-bit if using the 32-bit beta version.
  5. Quick start for Windows

    master

    To use Dr. Memory on Windows, build your application with debug information and run it using the drmemory command. If you used the installer, drmemory should be available in your PATH.

    Recommended build flags for cl:

    • /Zi: Generate complete debugging information.
    • /MT: Use the multithreaded static runtime.
    • /EHsc: Enable standard C++ exception handling.
    • /Oy-: Disable frame pointer omission.
    • /Ob0: Disable all optimizations (inlining).
  6. Quick start for Mac

    master

    To use Dr. Memory on Mac (Beta), build your application with debug information and run it through the bin/drmemory executable. Note that Mac support is currently in Beta and limited to 32-bit.

    Recommended build flags:

    • -g: Include debug information.
    • -fno-inline: Disable inlining.
    • -fno-omit-frame-pointer: Preserve frame pointers.
    • -m32: Required for current Mac Beta support.
  7. Identify Dr. Memory Windows binary types and descriptions

    master

    The Dr. Memory project includes several Windows binaries (executables and DLLs). When inspecting these files, you can identify their purpose via their FileDescription and InternalName metadata. Key components include:

    • Front end: drmemory.exe
    • Main library: A client DLL (name depends on CLIENT_LIBNAME)
    • System call tracer: drstrace.exe (executable) or drstracelib.dll (library)
    • Library call tracing tool: drltrace.exe (executable) or drltracelib.dll (library)
    • Symbol utilities: symquery.exe (query), winsyms.exe (translation), and verinfo.exe (version query)
    • Specialized tools: drheapstat (heap statistics), drsyscall.dll (system call monitor), drfuzz.dll (fuzz testing), and umbra.dll (shadow memory translator).