【发布时间】:2021-11-14 20:30:38
【问题描述】:
我可以在我的 PC (Ubuntu) 上使用 Valgrind 检查某个 SW,但为了获得更真实的结果,我还想在 OpenWRT (21.02.0-rc4) 上检查相同的 SW。
基本上 Valgrind 在 OpenWRT 中运行,但目前存在几个问题:
1- 我在跑步
valgrind -s --leak-check=full --show-leak-kinds=all --track-origins=yes ./my_SW
这在 PC 上有效,但在 OpenWRT 上,--track-origins=yes 参数会在 Valgrind 启动后立即导致“Killed”消息。
2- 当我跳过 track-origins 参数时,Valgrind 能够运行我的软件,但在最后的报告中:
==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)
我认为我的问题可能与以下问题有关:
cross-compiled Valgrind does not detect obvious leaks
所以我尝试应用建议的解决方案并使用我的 SW、Valgrind 和 libc 的未剥离版本。我为我的 SW 和 Valgrind 做了这个,但我不知道如何在 OpenWRT 中构建一个未剥离的 libc 版本。我找不到相关的makefile。有什么想法吗?
更新:@Paul Floyd 我尝试了您的建议,但似乎我的 valgrind 甚至不适用于 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#
【问题讨论】:
-
被杀死的消息到底是什么?
-
root@OpenWrt:/opt# valgrind -s --leak-check=full --show-leak-kinds=all --track-origins=yes ./my_SW ==12453== Memcheck ,内存错误检测器 ==12453== 版权所有 (C) 2002-2017 和 GNU GPL,由 Julian Seward 等人撰写。 ==12453== 使用 Valgrind-3.16.1 和 LibVEX;使用 -h 重新运行以获取版权信息 ==12453== 命令:./my_SW ==12453== Killed root@OpenWrt:/opt#