{"id":4584,"date":"2019-08-16T23:44:23","date_gmt":"2019-08-16T15:44:23","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=4584"},"modified":"2019-08-16T23:44:24","modified_gmt":"2019-08-16T15:44:24","slug":"gcov","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/gcov","title":{"rendered":"gcov\u547d\u4ee4 – \u6d4b\u8bd5\u4ee3\u7801\u8986\u76d6\u7387"},"content":{"rendered":"\n

gcov\u547d\u4ee4\u662f\u4e00\u6b3e\u6d4b\u8bd5\u7a0b\u5e8f\u7684\u4ee3\u7801\u8986\u76d6\u7387\u7684\u5de5\u5177\u3002 <\/p>\n\n\n\n

gcov\u53ef\u4ee5\u7edf\u8ba1\u6bcf\u4e00\u884c\u4ee3\u7801\u7684\u6267\u884c\u9891\u7387\uff0c\u5b9e\u9645\u4e0a\u54ea\u4e9b\u4ee3\u7801\u786e\u5b9e\u88ab\u6267\u884c\u4e86\uff0c\u6bcf\u4e00\u6bb5\u4ee3\u7801\u7684\u6267\u884c\u65f6\u95f4\u3002 gcov\u53ea\u5728\u4f7f\u7528GCC\u7f16\u8bd1\u7684\u4ee3\u7801\u4e0a\u5de5\u4f5c\u3002\u5b83\u4e0e\u4efb\u4f55\u5176\u4ed6\u6982\u8981\u6216\u6d4b\u8bd5\u8986\u76d6\u673a\u5236\u4e0d\u517c\u5bb9\u3002 <\/p>\n\n\n\n

gcov\u547d\u4ee4\u5728\u6d4b\u8bd5\u4ee3\u7801\u8986\u76d6\u7387\u65f6\uff0c\u5fc5\u987b\u4f7f\u7528gcc\u547d\u4ee4\u7684\u201c-fprofile-arcs\u201d\u9009\u9879\u548c\u201c-ftest-coverage\u201d\u9009\u9879\u7f16\u8bd1C\u8bed\u8a00\u6587\u4ef6\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>gcov [\u53c2\u6570] [\u6587\u4ef6]<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n
-a<\/td>\u663e\u793a\u6bcf\u4e2a\u57fa\u672c\u7684\u4fe1\u606f<\/td><\/tr>
-b<\/td>\u8f93\u51fa\u5305\u542b\u5206\u652f\u6982\u7387<\/td><\/tr>
-c<\/td>\u7ed9\u51fa\u8df3\u8f6c\u7684\u5206\u652f\u6570\uff0c\u800c\u4e0d\u662f\u767e\u5206\u6bd4<\/td><\/tr>
-n<\/td>\u4e0d\u521b\u5efa\u8f93\u51fa\u6587\u4ef6<\/td><\/tr>
-l<\/td>\u4e3a\u5305\u542b\u8fdb\u6765\u7684\u6e90\u6587\u4ef6\u4f7f\u7528\u957f\u8f93\u51fa\u6587\u4ef6\u540d<\/td><\/tr>
-f<\/td>\u8f93\u51fa\u6bcf\u4e2a\u51fd\u6570\u7684\u5c0f\u7ed3\u4fe1\u606f<\/td><\/tr>
-p<\/td>\u4fdd\u7559\u6240\u6709\u8def\u5f84\u540d<\/td><\/tr><\/tbody><\/table>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u663e\u793a\/root\/linuxcool.c\u6587\u4ef6\u7684\u4ee3\u7801\u8986\u76d6\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# gcov \/root\/linuxcool.c<\/pre>\n","protected":false},"excerpt":{"rendered":"

gcov\u547d\u4ee4\u662f\u4e00\u6b3e\u6d4b\u8bd5\u7a0b\u5e8f\u7684\u4ee3\u7801\u8986\u76d6\u7387\u7684\u5de5\u5177\u3002 gcov\u53ef\u4ee5\u7edf\u8ba1\u6bcf\u4e00\u884c\u4ee3\u7801\u7684\u6267\u884c\u9891\u7387\uff0c\u5b9e\u9645\u4e0a\u54ea\u4e9b\u4ee3\u7801\u786e\u5b9e\u88ab\u6267\u884c […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/4584"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=4584"}],"version-history":[{"count":2,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/4584\/revisions"}],"predecessor-version":[{"id":4616,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/4584\/revisions\/4616"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=4584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=4584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=4584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}