历史上的今天
今天是:2025年01月13日(星期一)
2020年01月13日 | 在ARM Linux 使用 Valgrind
2020-01-13 来源:eefocus
Linux valgrind 移植到ARM-Linux
一、Cross-Compile/交叉编译
(1)下载及解压Valgrind-3.11
(2)修改confirure
将armv7*)修改为armv7*|arm*)
(3)执行configure
./configure CC=arm-linux-gcc CPP=arm-linux-cpp CXX=arm-linux-g++ --host=arm-linux --prefix=/opt/valgrind/lib
注意:CC=arm-linux-gcc,之所以没有像有些博客上写的、用了绝对路径,是因为「我已经将arm-linux-gcc 软链接/soft-linke 到了实际的gcc」。
(4)make
(5)make install
二、移植到ARM开发板
注意:make install之后,编译生成的bin/和lib/目录存放在PC上的/opt/valgrind/lib目录下。将此目录下的bin/和lib/目录单独「复制/Copy」出来,不要Copy share/和include/目录,因为文件有点大,而且include/和share/这两个目录在开发板上没有用。
在ARM开发板上建立「目录-/opt/valgrind/lib/valgrind/」,将上面刚刚编译得到的lib/目录下的文件(.so, .a 等)放到左边提到的这个目录(/opt/valgrind/lib/valgrind)中。
注意:上面这个步骤非常关键,如果放错位置,在运行程序valgrind的时候,会提示「failed to start 'memcheck' : No such file or directory」。
三、ARM上配置使用
1、Error:在运行「./valgrind ls」的时候依然碰到了一个错误,出现在「vgdb」。错误提示是:
[12:58:19]root@freescale ~/valgrind/valgrind/bin$ ./valgrind ls
[12:58:19]==5978== Memcheck, a memory error detector
[12:58:19]==5978== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
[12:58:19]==5978== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
[12:58:19]==5978== Command: ls
[12:58:19]==5978==
[12:58:20]==5978== error writing 36 bytes to shared mem /tmp/vgdb-pipe-shared-mem-vgdb-5978-by-root-on-???
在网页failure to run on armv6 following the armv6 legacy patches suggested by bug 276897找到了一个暂时的方法,就是临时禁用「vgdb」。
[12:54:55]root@freescale ~/valgrind/valgrind/bin$ ./valgrind --vgdb=no ls
[12:54:55]==5976== Memcheck, a memory error detector
[12:54:55]==5976== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
[12:54:55]==5976== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
[12:54:55]==5976== Command: ls
[12:54:55]==5976==
[12:54:56]ERROR: ld.so: object '/opt/valgrind/lib/valgrind/vgpreload_core-arm-linux.so' from LD_PRELOAD cannot be preloaded: ignored.
[12:54:56]ERROR: ld.so: object '/opt/valgrind/lib/valgrind/vgpreload_memcheck-arm-linux.so' from LD_PRELOAD cannot be preloaded: ignored.
[12:54:57]==5976== Conditional jump or move depends on uninitialised value(s)
[12:54:57]==5976== at 0x4909C98: index (in /lib/libc-2.11.1.so)
[12:54:57]==5976==
[12:54:58]==5976== Conditional jump or move depends on uninitialised value(s)
[12:54:58]==5976== at 0x4909D90: strcmp (in /lib/libc-2.11.1.so)
[12:54:58]==5976== by 0x4910377: strcoll_l (in /lib/libc-2.11.1.so)
[12:54:58]==5976==
[12:54:58]==5976== Conditional jump or move depends on uninitialised value(s)
[12:54:58]==5976== at 0x4909D98: strcmp (in /lib/libc-2.11.1.so)
[12:54:58]==5976== by 0x4910377: strcoll_l (in /lib/libc-2.11.1.so)
2、LD_PRELOAD错误
[12:54:56]ERROR: ld.so: object '/opt/valgrind/lib/valgrind/vgpreload_core-arm-linux.so' from LD_PRELOAD cannot be preloaded: ignored.
上述的错误,经过检查,发现:「/opt/valgrind/lib/valgrind」缺少一些「.so/共享动态库」。重新编译「Valgrind」,并且用「arm-linux-strip」将文件进行精简,顺利复制。程序也顺利运行。
四、Valgrind简介
1、Valgrind是什么?
2、Valgrind能做什么?
(1)「badapp.c」
1 #include 2 3 void f(void) 4 { 5 int* x = malloc(10 * sizeof(int)); 6 x[10] = 0; // problem 1: heap block overrun 7 } // problem 2: memory leak -- x not freed 8 9 int main(void) 10 { 11 f(); 12 return 0; 13 } (2) [15:20:06] [15:20:06]==8399== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. [15:20:06]==8399== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info [15:20:06]==8399== Command: ./bad1pp1 [15:20:06]==8399== [15:20:07]connect fail. ip:10.167.13.207, strlen(ip):13. File:main.c, Line:696 [15:20:07]Internet Fail. File: main.c, Line: 2469 [15:20:08]==8399== Invalid write of size 4 [15:20:08]==8399== at 0x8414: f (badapp1.c:6) [15:20:08]==8399== by 0x842F: main (badapp1.c:11) [15:20:08]==8399== Address 0x496f050 is 0 bytes after a block of size 40 alloc'd [15:20:08]==8399== at 0x483481C: malloc (in /opt/valgrind/lib/valgrind/vgpreload_memcheck-arm-linux.so) [15:20:08]==8399== [15:20:08]==8399== [15:20:08]==8399== HEAP SUMMARY: [15:20:08]==8399== in use at exit: 40 bytes in 1 blocks [15:20:08]==8399== total heap usage: 1 allocs, 0 frees, 40 bytes allocated [15:20:08]==8399== [15:20:08]==8399== 40 bytes in 1 blocks are definitely lost in loss record 1 of 1 [15:20:08]==8399== at 0x483481C: malloc (in /opt/valgrind/lib/valgrind/vgpreload_memcheck-arm-linux.so) [15:20:08]==8399== [15:20:08]==8399== LEAK SUMMARY: [15:20:08]==8399== definitely lost: 40 bytes in 1 blocks [15:20:08]==8399== indirectly lost: 0 bytes in 0 blocks [15:20:08]==8399== possibly lost: 0 bytes in 0 blocks [15:20:08]==8399== still reachable: 0 bytes in 0 blocks [15:20:08]==8399== suppressed: 0 bytes in 0 blocks [15:20:08]==8399== [15:20:08]==8399== For counts of detected and suppressed errors, rerun with: -v [15:20:08]==8399== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 11 from 5) 3、Valgrind工作原理? 4、谁开发的Valgrind? Julian Seward, from Cambridge, UK. 5、Valgrind的名称来源 From Nordic mythology. Originally (before release) the project was named Heimdall, after the watchman of the Nordic gods. He could "see a hundred miles by day or night, hear the grass growing, see the wool growing on a sheep's back" (etc). This would have been a great name, but it was already taken by a security package "Heimdal". Keeping with the Nordic theme, Valgrind was chosen. Valgrind is the name of the main entrance to Valhalla (the Hall of the Chosen Slain in Asgard). Over this entrance there resides a wolf and over it there is the head of a boar and on it perches a huge eagle, whose eyes can see to the far regions of the nine worlds. Only those judged worthy by the guardians are allowed to pass through Valgrind. All others are refused entrance. It's not short for "value grinder", although that's not a bad guess.
史海拾趣
|
将5.0BSP移值到6.0 上时,运行到串口驱动时,就运行不下去了, DNW提示信息: WARNING: CReg2440Uart::CReg2440Uart failed to obtain processor frequency - using default value (66750000). DEBUG: Serial2 SYSINTR : -766318612 WARNING: C ...… 查看全部问答> |
|
请教如何获取monthcalendar(日历控件)被选中的日期信息,急急急急急急急! 如题,小弟在做一个日程管理的小应用程序, 请问如何获取在日历控件上选定的日期信息, 比如选定某日, 在程序中要提取该日的日期和星期几的信息。 谢谢各位,很急,请大家帮帮忙。… 查看全部问答> |
|
去年夏天,家里用了20多年的老冰箱(老人家买的,买了新冰箱后不够用,所以一直用着)坏了照明灯泡,用起来很不方便。当时把灯泡拿到电子市场去配,竟然找不到这种灯头的,只有作罢。 今天晚上在家没事,就 ...… 查看全部问答> |
|
之前能仿真的。能下载程序的。 后来设置了一下 就只有不行了 一直是 AXD Uable to halt ARM core 我也不知道哪里出了问题。.   ...… 查看全部问答> |
|
#include #include void main(void) { WDTCTL=WDT_MDLY_32; IE1|=WDTIE; P1DIR|=BIT6; while(1); } #pragma vector=WDT_VECTOR __interrupt void watchdor(void) { P1O ...… 查看全部问答> |
|
我也来加入四层板的学习,在上班抽空时间总算布局完了,大概布了下,还不是很整齐,在这里得感谢@okhxyyo 的耐心帮忙和指导~ 希望能大家一起共同进步和学习… 查看全部问答> |




