<menu id="w8yyk"><menu id="w8yyk"></menu></menu>
  • <dd id="w8yyk"><nav id="w8yyk"></nav></dd>
    <menu id="w8yyk"></menu>
    <menu id="w8yyk"><code id="w8yyk"></code></menu>
    <menu id="w8yyk"></menu>
    <xmp id="w8yyk">
    <xmp id="w8yyk"><nav id="w8yyk"></nav>
  • 網站首頁 > 物聯資訊 > 技術分享

    dmalloc在嵌入式的開發板上的應用

    2016-09-28 00:00:00 廣州睿豐德信息科技有限公司 閱讀
    睿豐德科技 專注RFID識別技術和條碼識別技術與管理軟件的集成項目。質量追溯系統、MES系統、金蝶與條碼系統對接、用友與條碼系統對接

    下面是我實際在開發環境里面做的dmalloc移植時候的一些隨筆

     

    配置PC的dmalloc環境
    1. 首先把源碼包打開,進入dmalloc文件夾
    2. ./configure 配置Makefile,我是加了線程選項的,所以我的是./configure --enable-threads
    3. 生成Makefile之后,需要修改makefile里面的編譯選項 cc和cxx
       我用的是DM6467的開發環境,所以我的改成了arm_v5t_le-gcc和arm_v5t_le-g++,這里按照各自需要改成交叉編譯的命令就好。
    4. 然后make
    5. make install
    到此,環境配置完成

    進到我們需要測試內存漏洞的代碼,例如我們的代碼在test文件夾里,名字叫mem.c。
    1. 進入test
    2. 用交叉編譯工具編譯arm_v5t_le-gcc mem.c -o mem -ldmalloc,這里記得加-ldmalloc這個編譯選項,這樣才能使用dmalloc。
    執行成功后,生成的mem拷貝到開發板的某個目錄,等待執行。

    配置開發板的dmalloc執行環境
    1. 從PC的/usr/local/bin 拷貝dmalloc 文件到開發板的目錄/bin
    2. 從PC的/usr/local/lib 拷貝相關的.a文件到開發板的目錄/usr/lib
    3. 從PC的/usr/local/include 拷貝dmalloc.h 文件到開發板的目錄/usr/include
    4. 輸入配置文件命令 export DMALLOC_OPTIONS=log=logname,debug=0x3
       這里的logname是一個我們輸入的文件,以后的編譯debug信息會打印進去,0x3是debug的選項,詳細的可以看http://www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/ELJonline-BRMemory-Leak-Detection-in-Embedded-Systems/  我下面也把編譯選項貼過來了。


    將上面編譯好的mem可執行程序拷貝到我們的開發板上,然后運行。

    --------------------------
    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 to be linear (0x10000)

        * catch-signals (csi): shut down program on 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)

    RFID管理系統集成商 RFID中間件 條碼系統中間層 物聯網軟件集成
    最近免费观看高清韩国日本大全