Valgrind在OpenWRT上无法正常工作,我需要重建libc吗



我可以在我的电脑(Ubuntu(上用Valgrind检查某个软件,但为了获得更真实的结果,我也想在OpenWRT(21.02.0-rc4(上检查相同的软件。

Basicly Valgrind在OpenWRT中运行,但目前有几个问题:

1-我正在运行

valgrind -s --leak-check=full --show-leak-kinds=all --track-origins=yes ./my_SW

在PC上这是可行的,但在OpenWRT上CCD_;被杀死";Valgrind启动后立即发送消息。

2-当我跳过轨道原点参数时,Valgrind可以运行我的SW,但在最后的报告中:

==12462== HEAP SUMMARY:
==12462==     in use at exit: 0 bytes in 0 blocks
==12462==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==12462== 
==12462== All heap blocks were freed -- no leaks are possible

在PC上,Valgrind报告了数千次分配和相同数量的空闲,但在OpenWRT上,它似乎无法检测到任何堆的使用。

3-在OpenWRT上,我得到了很多错误,比如下面的一个,而同样的软件在PC上运行时没有错误:

==12462== Conditional jump or move depends on uninitialised value(s)
==12462==    at 0x4079058: ??? (in /lib/libc.so)
==12462==    by 0x408A4B4: ??? (in /lib/libc.so)

我认为我的问题可能与以下问题有关:

交叉编译的Valgrind没有检测到明显的泄漏

因此,我尝试应用建议的解决方案,并使用我的SW、Valgrind和libc的未破解版本。我这样做是为了我的SW和Valgrind,但我不知道如何在OpenWRT中构建libc的非破解版本。我找不到相关的makefile。有什么想法吗?

更新:@Paul Floyd我试过你的推荐,但我的勇气似乎甚至不适用于pwd:

root@OpenWrt:/opt# valgrind --tool=none pwd
==2919== Nulgrind, the minimal Valgrind tool
==2919== Copyright (C) 2002-2017, and GNU GPL'd, by Nicholas Nethercote.
==2919== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==2919== Command: pwd
==2919== 
vex mips->IR: unhandled instruction bytes: 0xE8 0x67 0x25 0xB3
==2919== 
==2919== Process terminating with default action of signal 4 (SIGILL)
==2919==    at 0x43B405: ??? (in /bin/busybox)
==2919==    by 0x4021A0C: ??? (in /lib/libc.so)
==2919== 
Illegal instruction
root@OpenWrt:/opt# 

我的建议是从简单开始。

让"valgrind--tool=none-pwd"或类似的东西工作。

不要添加"--track origins=yes",除非您有一个错误,例如;条件跳转或移动取决于未初始化的值";并且您无法从错误消息中找到问题。

同样,您不需要从"泄漏"选项开始。在没有它们的情况下运行,如果摘要显示存在泄漏,则根据需要添加它们。

您不应该需要libc-debuginfo。这将使错误调用堆栈更加清晰,但没有它,Valgrind应该可以正常工作。

您可以将输出与"--tool=none——trace redir=yes";在你的Ubuntu盒子和OpenWRT盒子上。

你应该看看类似的东西

paulf> ./vg-in-place --tool=none --trace-redir=yes pwd 2>&1 | grep Reading
--42969-- Reading syms from /bin/pwd
--42969-- Reading syms from /libexec/ld-elf.so.1
--42969-- Reading syms from /usr/home/paulf/scratch/valgrind/none/none-amd64-freebsd
--42969-- Reading syms from /usr/home/paulf/scratch/valgrind/coregrind/vgpreload_core-amd64-freebsd.so
--42969-- Reading syms from /lib/libc.so.7
--42969-- Reading syms from /lib/libc.so.

路径和文件名可能不同,但应该始终是

  1. 可执行文件
  2. 动态加载程序库
  3. valgrind刀具
  4. valgrind岩心
  5. 链接到可执行文件的动态库

如果你没有看到";正在从libc.so读取符号";那么Valgrind将无法拦截对malloc和free的调用。

最后,您可以使用--trace symtab=yes查看输出。这将是很长的一段时间,但这两个平台之间不应该有任何无法解释的重大差异。

最新更新