valgrind在Hi3559A上的尝试
下载valgrind源码
两种方式(任选其一)
1)登录http://valgrind.org/downloads/ 下载压缩包
2)git clone git://sourceware.org/git/valgrind.git
基于hisi toolchain,交叉编译valgrind
编译主机
4.15.0-34-generic #37~16.04.1-Ubuntu SMP Tue Aug 28 10:44:06 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
PC上编译命令
-
export LD=aarch64-himix100-linux-ld
-
export AR=aarch64-himix100-linux-ar
-
export CC=aarch64-himix100-linux-gcc
-
./configure --host=aarch64-himix100-linux --prefix=/home/huangxing/valgrind_install/
-
make -j4
-
make install
编译完成后,在valgrind_install中安装了以下文件。
simh@hxdl:~/valgrind_install$ tree -L 2
.
├── bin
│ ├── callgrind_annotate
│ ├── callgrind_control
│ ├── cg_annotate
│ ├── cg_diff
│ ├── cg_merge
│ ├── ms_print
│ ├── valgrind
│ ├── valgrind-di-server
│ ├── valgrind-listener
│ └── vgdb
├── include
│ └── valgrind
└── lib
├──-- pkgconfig
└──-- valgrind
将valgrind_install目录拷贝到nfs方式挂载的路径下。
海思板端执行:
- export VALGRIND_LIB='/home/simh/valgrind_install/lib/valgrind'
如果不执行上面的命令,会提示找不到memcheck!
-
cd /home/simh/valgrind_install/bin
-
./valgrind --help
此时会提示以下错误:
/home/simh/valgrind_install/bin # ./valgrind ls -l
==19263== Memcheck, a memory error detector
==19263== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==19263== Using Valgrind-3.15.0.GIT and LibVEX; rerun with -h for copyright info
==19263== Command: ls -l
==19263==
valgrind: Fatal error at startup: a function redirection
valgrind: which is mandatory for this platform-tool combination
valgrind: cannot be set up. Details of the redirection are:
valgrind:
valgrind: A must-be-redirected function
valgrind: whose name matches the pattern: strlen
valgrind: in an object with soname matching: ld-linux-aarch64.so.1
valgrind: was not found whilst processing
valgrind: symbols from the object with soname: ld-linux-aarch64.so.1
valgrind:
valgrind: Possible fixes: (1, short term): install glibc's debuginfo
valgrind: package on this machine. (2, longer term): ask the packagers
valgrind: for your Linux distribution to please in future ship a non-
valgrind: stripped ld.so (or whatever the dynamic linker .so is called)
valgrind: that exports the above-named function using the standard
valgrind: calling conventions for this platform. The package you need
valgrind: to install for fix (1) is called
valgrind:
valgrind: On Debian, Ubuntu: libc6-dbg
valgrind: On SuSE, openSuSE, Fedora, RHEL: glibc-debuginfo
valgrind:
valgrind: Note that if you are debugging a 32 bit process on a
valgrind: 64 bit system, you will need a corresponding 32 bit debuginfo
valgrind: package (e.g. libc6-dbg:i386).
valgrind:
valgrind: Cannot continue -- exiting now. Sorry.
此时的处理方法也比较简单,可以任选其一。
-
1) 更改osdrv的makefile,将hirootfs_prepare中的这句话注释掉。
pushd $(OSDRV_DIR)/pub/$(PUB_ROOTFS); $(OSDRV_CROSS)-strip ./lib/*; popd -
2)直接到/opt/hisi-linux/x86-arm/aarch64-himix100-linux/target/lib中取libc-2.24.so(not stripped), 重新制作rootfs。
至此,algrind应该可以在海思平台上运行了,
- cd /home/simh/valgrind_install/bin
- ./valgrind ls -l
/home/simh/valgrind_install/bin # ./valgrind ls -l
==7215== Memcheck, a memory error detector
==7215== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==7215== Using Valgrind-3.15.0.GIT and LibVEX; rerun with -h for copyright info
==7215== Command: ls -l
==7215==
total 2608
-rw------- 1 root root 150158 Oct 24 10:50 callgrind.out.2646
-rw------- 1 root root 476590 Oct 24 10:51 callgrind.out.2661
-rw------- 1 root root 150110 Oct 24 10:51 callgrind.out.2689
-rw------- 1 root root 508277 Oct 24 10:52 callgrind.out.2694
-rw------- 1 root root 509620 Oct 24 10:53 callgrind.out.2735
-rw------- 1 root root 93369 Oct 24 10:52 callgrind.out.2737
-rwxr-xr-x 1 1000 1000 42184 Oct 23 17:38 callgrind_annotate
-rwxr-xr-x 1 1000 1000 12677 Oct 23 17:38 callgrind_control
-rwxr-xr-x 1 1000 1000 32174 Oct 23 17:38 cg_annotate
-rwxr-xr-x 1 1000 1000 10422 Oct 23 17:38 cg_diff
-rwxr-xr-x 1 1000 1000 238632 Oct 23 17:38 cg_merge
-rwxr-xr-x 1 1000 1000 24402 Oct 23 17:38 ms_print
-rwxr-xr-x 1 1000 1000 76888 Oct 23 17:38 valgrind
-rwxr-xr-x 1 1000 1000 104024 Oct 23 17:38 valgrind-di-server
-rwxr-xr-x 1 1000 1000 39072 Oct 23 17:38 valgrind-listener
-rwxr-xr-x 1 1000 1000 168088 Oct 23 17:38 vgdb
==7215==
==7215== HEAP SUMMARY:
==7215== in use at exit: 775 bytes in 8 blocks
==7215== total heap usage: 98 allocs, 90 frees, 66,501 bytes allocated
==7215==
==7215== LEAK SUMMARY:
==7215== definitely lost: 32 bytes in 2 blocks
==7215== indirectly lost: 112 bytes in 1 blocks
==7215== possibly lost: 0 bytes in 0 blocks
==7215== still reachable: 631 bytes in 5 blocks
==7215== suppressed: 0 bytes in 0 blocks
==7215== Rerun with --leak-check=full to see details of leaked memory
==7215==
==7215== For counts of detected and suppressed errors, rerun with: -v
==7215== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
valgrind正常运行了。
数据分析
valgrind在板端运行生成的数据可以通过pc端的工具进行分析。
举例来说:
如果使用callgrind工具,会生成callgrind.out.pid文件,可以通过kcachegrind工具分析,或者通过gprof2dot.py工具进行分析。
gprof2dot.py可以在以下链接下载:
https://github.com/jrfonseca/gprof2dot
使用示例:
gprof2dot.py -f callgrind ./callgrind.out.2735 | dot -Tpng -o ps_report.png
不过valgrind官网推荐使用kcachegrind工具。
Callgrind
Callgrind, by Josef Weidendorfer, is an extension to Cachegrind. It provides all the information that Cachegrind does, plus extra information about callgraphs. It was folded into the main Valgrind distribution in version 3.2.0. Available separately is an amazing visualisation tool, KCachegrind, which gives a much better overview of the data that Callgrind collects; it can also be used to visualise Cachegrind's output.
可以下载kcachegrind源码,按照source中的README,编译,安装,比较简单。
kcachegrind源码下载链接:
http://kcachegrind.sourceforge.net/html/Download.html
编译,安装命令:
-
mkdir build
-
cd build
-
cmake ..
Note:
执行cmake时遇到错误:
simh@hxdl:~/Downloads/kcachegrind-0.7.4/build$ cmake ..
CMake Error at /usr/share/cmake-3.5/Modules/FindKDE4.cmake:111 (message):
ERROR: cmake/modules/FindKDE4Internal.cmake not found in
/home/huangxing/.kde/share/apps;/usr/share/kde4/apps
Call Stack (most recent call first):
CMakeLists.txt:5 (find_package) -
sudo apt install kdelibs5-dev kdebase-apps
之后再执行cmake没有报错。 -
make
-
sudo make install
打开工具试验:
kcachegrind
- 分享
- 举报
-
白 2024-06-01 15:49:55回复 举报build.sh脚本 ./configure \ --prefix="/home/valgrind_install" \ CC=/opt/public/gcc/hisi-linux/x86-arm/aarch64-mix410-linux/bin/aarch64-mix410-linux-gcc \ CXX=/opt/public/gcc/hisi-linux/x86-arm/aarch64-mix410-linux/bin/aarch64-mix410-linux-g++ \ CPP=/opt/public/gcc/hisi-linux/x86-arm/aarch64-mix410-linux/bin/aarch64-mix410-linux-cpp \ AR=/opt/public/gcc/hisi-linux/x86-arm/aarch64-mix410-linux/bin/aarch64-mix410-linux-ar \ RANLIB=/opt/public/gcc/hisi-linux/x86-arm/aarch64-mix410-linux/bin/aarch64-mix410-linux-ranlib \ --target=aarch64-mix410-linux \ --host=aarch64-mix410-linux \ --program-prefix=hisi- 运行: ./build.sh make -j8 sudo make install 安装之后,把valgrind_install拷贝到海思的板子里面去, 然后在板子上运行 export VALGRIND_LIB='/home/valgrind_install/lib/valgrind' ./hisi-valgrind --help 出现错误,找不到memcheck valgrind: failed to start tool 'memcheck' for platform 'arm64-linux': No such file or directory valgrind的版本为valgrind-3.23.0
-
浏览量:3310次2020-08-17 19:59:15
-
浏览量:2847次2020-08-10 09:28:54
-
浏览量:3603次2020-07-27 15:19:53
-
浏览量:3253次2019-02-14 17:57:04
-
浏览量:891次2023-06-07 14:19:47
-
浏览量:4214次2018-05-25 21:45:17
-
浏览量:7279次2018-06-14 23:13:10
-
浏览量:1138次2024-01-06 10:33:06
-
浏览量:3866次2020-08-24 21:15:04
-
2024-01-06 10:44:04
-
浏览量:3830次2018-10-31 14:12:11
-
浏览量:9472次2018-06-02 19:08:30
-
浏览量:3651次2022-01-04 09:00:18
-
浏览量:17214次2018-09-27 20:23:02
-
浏览量:1825次2021-01-04 15:04:02
-
2018-06-18 22:47:22
-
2024-01-06 11:14:41
-
浏览量:1729次2023-06-12 14:34:37
-
浏览量:1087次2024-01-04 17:47:00
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
simonhuang
感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明