Here are some essays on the dmalloc transplant I actually made in the development environment
Configuring the DMALLOC environment for your PC
1. First open the source package and go to the Dmalloc folder
2../configure configuration Makefile, I was adding a threading option, so my is./configure--enable-threads
3. After generating the makefile, you need to modify the makefile inside the compilation options cc and CXX
I use the DM6467 development environment, so I changed to ARM_V5T_LE-GCC and arm_v5t_le-g++, here according to their own needs to change to cross-compiling command is good.
4. Then make
5. Make install
To this, the environment is configured to complete
Into the code that we need to test for a memory leak, such as our code in the test folder, named Mem.c.
1. Enter test
2. Compile the ARM_V5T_LE-GCC Mem.c-o Mem-ldmalloc with the cross-compilation tool, and remember to add-ldmalloc This compilation option to use Dmalloc.
Upon successful execution, the generated mem is copied to a directory on the Development Board, awaiting execution.
Configure the Dmalloc execution environment for the Development Board
1. Copy the Dmalloc file from the/usr/local/bin of the PC to the directory of the Development Board/bin
2. From the PC/usr/local/lib copy the relevant. A file to the Development Board directory/usr/lib
3. Copy the dmalloc.h file from the/usr/local/include of the PC to the directory of the Development Board/usr/include
4. Enter the configuration file command export dmalloc_options=log=logname,debug=0x3
Here logname is a file we entered, the subsequent compilation of debug information will be printed in, 0x3 is the option of debug, detailed can see http://www.linuxfordevices.com/c/a/ linux-for-devices-articles/eljonline-brmemory-leak-detection-in-embedded-systems/I've also pasted the compilation options down here.
Copy the above compiled mem executable to our Development board and run it.
--------------------------
The following is a list of the tests and the corresponding bits to set in ' Debug ':
* None (Nil): No functionality (0)
* Log-stats (LST): Log general statistics (0x1)
* Log-non-free (LNF): Log non-freed pointers (0x2)
* Log-known (LKN): Log only known non-freed (0x4)
* Log-trans (LTR): Log Memory transactions (0x8)
* Log-admin (LAD): Log administrative info (0x20)
* Log-blocks (LBL): Log blocks when Heap-map (0x40)
* Log-bad-space (lbs): Dump space from bad pointers (0x100)
* Log-nonfree-space (LNS): Dump space from non-freed pointers (0x200)
* Log-elapsed-time (Let): Log elapsed time for allocated pointer (0x40000)
* Log-current-time (LCT): Log current time for allocated pointer (0x80000)
* Check-fence (CFE): Check fencepost errors (0x400)
* CHECK-HEAP (che): Check heap adm structs (0x800)
* Check-lists (CLI): Check free lists (0x1000)
* Check-blank (CBL): Check mem overwritten by Alloc-blank, Free-blank (0x2000)
* Check-funcs (CFU): Check Functions (0x4000)
* Force-linear (FLI): Force Heap-space-Be linear (0x10000)
* Catch-signals (CSI): Shut in SIGHUP, SIGINT, SIGTERM (0x20000)
* Realloc-copy (RCO): Copy all Re-allocations (0x100000)
* Free-blank (FBL): Overwrite freed memory space with Blank_char (0x200000)
* Error-abort (EAB): Abort immediately on error (0x400000)
* Alloc-blank (ABL): Overwrite newly alloced memory with Blank_char (0x800000)
* HEAP-CHECK-MAP (HCM): Log heap-map on Heap-check (0x1000000)
* Print-messages (PME): Write Messages to stderr (0x2000000)
* Catch-null (CNU): Abort if no memory available (0x4000000)
* Never-reuse (NRE): Never Reuse freed memory (0x8000000)
* Allow-free-null (AFN): Allow the frees of NULL pointers (0x20000000)
* Error-dump (EDU): Dump core On Error and then continue (0x40000000)
Application of Dmalloc on the embedded Development Board