{"id":91,"date":"2025-09-11T11:34:59","date_gmt":"2025-09-11T03:34:59","guid":{"rendered":"https:\/\/blog.cnsn.fun\/?p=91"},"modified":"2025-09-11T11:34:59","modified_gmt":"2025-09-11T03:34:59","slug":"rv1126%e4%ba%a4%e5%8f%89%e7%bc%96%e8%af%91valgrind%e5%b7%a5%e5%85%b7","status":"publish","type":"post","link":"https:\/\/blog.cnsn.fun\/?p=91","title":{"rendered":"RV1126\u4ea4\u53c9\u7f16\u8bd1valgrind\u5de5\u5177"},"content":{"rendered":"<p>valgrind\u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u5f00\u6e90\u5de5\u5177\uff0c\u4e3b\u8981\u7528\u4e8e\u5185\u5b58\u8c03\u8bd5\u3001 \u5185\u5b58\u6cc4\u6f0f\u68c0\u6d4b\u3001\u6027\u80fd\u5206\u6790\u4ee5\u53ca\u7ebf\u7a0b\u9519\u8bef\u7684\u68c0\u6d4b\u3002\u672c\u6587\u7528\u4e8e\u8bb0\u5f55\u5728x86\u7684 Ubuntu \u865a\u62df\u673a\u4e0a\u5bf9RV1126\u5f00\u53d1\u677f\u7684valgrind\u8fdb\u884c\u4ea4\u53c9\u7f16\u8bd1\u7684\u8fc7\u7a0b\u3002<\/p>\n<h3>\u4e0b\u8f7d\u6e90\u7801<\/h3>\n<p>\u8fdb\u5165\u4e0b\u9762\u7f51\u5740\u4e0b\u8f7dvalgrind\u7684\u6e90\u7801\uff0c\u8fd9\u91cc\u9009\u62e9\u7684\u7248\u672c\u662f3.23.0<\/p>\n<pre><code>wget https:\/\/sourceware.org\/pub\/valgrind\/valgrind-3.23.0.tar.bz2<\/code><\/pre>\n<h3>\u89e3\u538b\u7f29\u6e90\u7801<\/h3>\n<pre><code>tar -xvf valgrind-3.23.0.tar.bz2\n\ncd valgrind-3.23.0<\/code><\/pre>\n<h3>\u4fee\u6539configure\u6587\u4ef6<\/h3>\n<p>\u4e3a\u4e86\u907f\u514d\u7f16\u8bd1\u7684\u8fc7\u7a0b\u62a5\u9519\uff0c\u9700\u8981\u4fee\u6539configure\u6587\u4ef6\u7684\u6e90\u7801\u5b9e\u73b0\u3002\u8fd9\u91cc\u53ef\u4ee5\u641c\u7d22\u5173\u952e\u8bcd\u201cVGCONF_PLATFORM_ARM_ARCH\u201d,\u627e\u5230\u4e0b\u9762\u7684\u6bb5\u843d\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<pre><code># \u4fee\u6539\u524d\n     armv7*)\n        { printf &quot;%s\\n&quot; &quot;$as_me:${as_lineno-$LINENO}: result: ok (${host_cpu})&quot; &gt;&amp;5\nprintf &quot;%s\\n&quot; &quot;ok (${host_cpu})&quot; &gt;&amp;6; }\n        VGCONF_PLATFORM_ARM_ARCH=&quot;-marm -mcpu=cortex-a8&quot;\n        ARCH_MAX=&quot;arm&quot;\n        ;;\n\n# \u4fee\u6539\u4e3a\n     armv7* | arm)\n        { printf &quot;%s\\n&quot; &quot;$as_me:${as_lineno-$LINENO}: result: ok (${host_cpu})&quot; &gt;&amp;5\nprintf &quot;%s\\n&quot; &quot;ok (${host_cpu})&quot; &gt;&amp;6; }\n        VGCONF_PLATFORM_ARM_ARCH=&quot;-marm -mcpu=cortex-a8&quot;\n        ARCH_MAX=&quot;arm&quot;\n        ;;\n<\/code><\/pre>\n<h3>\u751f\u6210\u914d\u7f6e\u6587\u4ef6<\/h3>\n<pre><code>.\/configure --host=arm-none-linux-gnueabihf CC=\/home\/hf\/1126\/rv1126_rv1109_linux\/prebuilts\/gcc\/linux-x86\/arm\/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf\/bin\/arm-linux-gnueabihf-gcc --prefix=&quot;$PWD\/_install&quot;\n1<\/code><\/pre>\n<h3>\u7f16\u8bd1\u5e76\u5b89\u88c5\u5230_install\u76ee\u5f55<\/h3>\n<pre><code>make\n\nmake install\n<\/code><\/pre>\n<h3>\u4e0a\u4f20RV1126\u5f00\u53d1\u677f\u5e76\u6d4b\u8bd5<\/h3>\n<h4>\u6587\u4ef6\u90e8\u7f72\u5f00\u53d1\u677f<\/h4>\n<p>\u751f\u6210\u7684\u6587\u4ef6\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b\uff0c\u9700\u8981\u5c06\u5176\u4e2d\u7684 bin\u3001include\u3001lib \u4ee5\u53ca libexec \u56db\u4e2a\u6587\u4ef6\u5939\u62f7\u8d1d\u5230\u5f00\u53d1\u677f\u4e2d\u3002\u7531\u4e8e\u9700\u8981\u4e0d\u5c0f\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u56e0\u6b64\u8fd9\u91cc\u5728\u5f00\u53d1\u677f\u7684 \/userdata\/ \u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a valgrind \u6587\u4ef6\u5939\uff0c\u7528\u4e8e\u5b58\u653e\u4ee5\u4e0a\u56db\u4e2a\u6587\u4ef6\u5939\u3002<\/p>\n<p>\u865a\u62df\u673a\u4e0a\u7684\u7f16\u8bd1\u751f\u6210\u6587\u4ef6\u7ed3\u6784<\/p>\n<ul>\n<li>_install\n<ul>\n<li>bin<\/li>\n<li>include<\/li>\n<li>lib<\/li>\n<li>libexec<\/li>\n<li>share<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u5f00\u53d1\u677f\u4e0a\u90e8\u7f72 valgrind \u7684\u6587\u4ef6\u7ed3\u6784<\/p>\n<ul>\n<li>userdata\n<ul>\n<li>valgrind\n<ul>\n<li>bin<\/li>\n<li>lib<\/li>\n<li>libexec<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>\u914d\u7f6e\u6743\u9650<\/h4>\n<p>\u672c\u90e8\u5206\u7684\u547d\u4ee4\u5747\u5728\u5f00\u53d1\u677f\u7684\u547d\u4ee4\u7ec8\u7aef\u5185\u8fdb\u884c\uff0c\u9700\u8981\u914d\u7f6e\u7684\u662f\u65b0\u4e0a\u4f20\u7684 valgrind \u5728\u5f00\u53d1\u677f\u4e0a\u7684\u6743\u9650\u3002<\/p>\n<p>\u9996\u5148\u9700\u8981\u914d\u7f6e valgrind \u94fe\u63a5\u5e93\u7684\u73af\u5883\u53d8\u91cf\uff0c\u8fd9\u91cc\u6709\u4e24\u79cd\u65b9\u6848\uff0c\u4e00\u79cd\u662f\u4e34\u65f6\u6027\u7684\uff0c\u53ea\u5728\u5f53\u524d\u547d\u4ee4\u7ec8\u7aef\u5185\u6709\u6548\uff0c\u53e6\u4e00\u79cd\u662f\u6c38\u4e45\u6027\u7684\u3002<\/p>\n<pre><code># \u4e34\u65f6\u6027\u914d\u7f6e\nexport VALGRIND_LIB=\/userdata\/valgrind\/libexec\/valgrind\n\n# \u6c38\u4e45\u6027\u914d\u7f6e\nvi \/etc\/preofile.d\/RkEnv.sh\nexport VALGRIND_LIB=\/userdata\/valgrind\/libexec\/valgrind     \u5c06\u672c\u6761\u547d\u4ee4\u6dfb\u52a0\u81f3 RkEnv.sh \u5185\n<\/code><\/pre>\n<p>\u968f\u540e\uff0c\u914d\u7f6e valgrind \u7684\u6267\u884c\u6743\u9650<\/p>\n<pre><code># \u914d\u7f6e valgrind \u7684\u6267\u884c\u6743\u9650\n\ncd \/userdata\/valgrind\/bin\/\nchmod a+x .\/valgrind\n<\/code><\/pre>\n<p>\u6700\u540e\uff0c\u7531\u4e8e valgrind \u7684\u6267\u884c\u9700\u8981\u8bf8\u5982 memcheck \u6216 helgrind \u7684\u914d\u5408\uff0c\u56e0\u6b64\u8fd8\u9700\u8981\u7ed9 memcheck-arm- linux \u4e0e helgrind-arm-linux \u76f8\u5e94\u7684\u6267\u884c\u6743\u9650\u3002<\/p>\n<pre><code>chmod +x \/userdata\/valgrind\/libexec\/valgrind\/memcheck-arm-linux\n\nchmod +x \/userdata\/valgrind\/libexec\/valgrind\/helgrind-arm-linux\n<\/code><\/pre>\n<h4>\u6d4b\u8bd5\u6548\u679c<\/h4>\n<pre><code># \u7531\u4e8e valgrind \u4e0d\u5728\u7cfb\u7edf\u547d\u4ee4\u96c6\u5185\uff0c\u6240\u4ee5\u5728\u4f7f\u7528\u65f6\u9700\u8981\u6307\u5b9a\u5b83\u6240\u5728\u7684\u8def\u5f84\n\/userdata\/valgrind\/bin\/valgrind --version\n\n# \u5229\u7528 valgrind \u7684 memcheck \u5bf9 \/root\/ \u8def\u5f84\u4e0b\u7684 test \u53ef\u6267\u884c\u6587\u4ef6\u7684\u5185\u5b58\u8fdb\u884c\u5206\u6790\uff0c\u5e76\u5c06\u5206\u6790\u7ed3\u679c\u8bb0\u5f55\u5728\u5f53\u524d \/root\/ \u8def\u5f84\u4e0b\u7684 log.txt \u5185\n\/userdata\/valgrind\/bin\/valgrind --tool=memcheck --leak-check=full --track-origins=yes  --log-file=\/root\/log.txt --show-reachable=yes \/userdata\/app<\/code><\/pre>\n<p>\u81f3\u6b64\uff0cRV1126 \u4ea4\u53c9\u7f16\u8bd1 valgrind \u5de5\u5177\u7684\u8fc7\u7a0b\u4fbf\u7ed3\u675f\u4e86\uff0c\u5173\u4e8e valgrind \u7684\u4f7f\u7528\uff0c\u4e4b\u540e\u5355\u72ec\u5199\u4e00\u7bc7\u6587\u7ae0\u8fdb\u884c\u8bb0\u5f55\u603b\u7ed3\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>valgrind\u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u5f00\u6e90\u5de5\u5177\uff0c\u4e3b\u8981\u7528\u4e8e\u5185\u5b58\u8c03\u8bd5\u3001 \u5185\u5b58\u6cc4\u6f0f\u68c0\u6d4b\u3001\u6027\u80fd\u5206\u6790\u4ee5\u53ca\u7ebf\u7a0b\u9519\u8bef\u7684\u68c0\u6d4b\u3002\u672c\u6587\u7528 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,10],"tags":[],"class_list":["post-91","post","type-post","status-publish","format-standard","hentry","category-c","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.cnsn.fun\/index.php?rest_route=\/wp\/v2\/posts\/91","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.cnsn.fun\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.cnsn.fun\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.cnsn.fun\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.cnsn.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=91"}],"version-history":[{"count":0,"href":"https:\/\/blog.cnsn.fun\/index.php?rest_route=\/wp\/v2\/posts\/91\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.cnsn.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.cnsn.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.cnsn.fun\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}