当前位置: 首页 > news >正文

网站建设与运营的预算方案模板网建公司转型

网站建设与运营的预算方案模板,网建公司转型,合肥 电子商务 网站推广,私密浏览器免费看片在线看一、关于gcov工具gcov伴随gcc发布。gcc编译加入-fprofile-arcs -ftest-coverage参数生成二进制程序#xff0c;执行测试用例生成代码覆盖率信息。1、如何使用gcov用GCC编译的时候加上-fprofile-arcs -ftest-coverage选项#xff0c;链接的时候也加上。fprofile-arcs参数使gcc…一、关于gcov工具gcov伴随gcc发布。gcc编译加入-fprofile-arcs -ftest-coverage参数生成二进制程序执行测试用例生成代码覆盖率信息。1、如何使用gcov用GCC编译的时候加上-fprofile-arcs -ftest-coverage选项链接的时候也加上。fprofile-arcs参数使gcc创建一个程序的流图之后找到适合图的生成树。只有不在生成树中的弧被操纵(instrumented)gcc添加了代码来清点这些弧执行的次数。当这段弧是一个块的唯一出口或入口时操纵工具代码(instrumentation code)将会添加到块中否则创建一个基础块来包含操纵工具代码。gcov主要使用.gcno和.gcda两个文件。.gcno是由-ftest-coverage产生的它包含了重建基本块图和相应的块的源码的行号的信息。.gcda是由加了-fprofile-arcs编译参数的编译后的文件运行所产生的它包含了弧跳变的次数和其他的概要信息(而gcda只能在程序运行完毕后才能产生的)。Gcov执行函数覆盖、语句覆盖和分支覆盖。举个例子,程序代码由main.c和tmp.c两个文件组成编译、链接、运行程序编译gcc -fprofile-arcs -ftest-coverage -o myapp main.c tmp.c运行./myapp然后输入命令gcov main.c,gcov tmp.c这个时候当前目录下有了新的文档main.c.gcov,和tmp.c.gcov若想保存覆盖率文件上述命令修改为命令gcov main.c yourfilename,gcov tmp.c yourfilename而这时候的main.c.gcov,和tmp.c.gcov就包含了函数和代码执行次数的信息我们可以查看结果-:   65:/***************************************************************************************-:   66: * name         : main-:   67: * return       : 0 OK-:   68: *                other ERROR-:   69: * history      : 2006-06-13-:   70:****************************************************************************************/-:   71:int main( int argc, char *argv[] )                                                      /* the entrance for program*/function main called 4 returned 100% blocks executed 81%4:   72:{4:   73:        int loop 0 ;4:   74:        int ret OK ;4:   75:        int empty_line 0 ;4:   76:        int code_line 0 ;4:   77:        int annotation_line 0 ;4:   78:        struct stat file_stat ;                                                         /* use for file state */4:   79:        char recu_name[256] ;4:   80:        char *pwd NULL ;4:   81:        char *tmp NULL ;-:   82:4:   83:        if( argc MAX_FILE ){                                    /* file size larger than max size */#####:   98:                        printf( file [%s] size is over 64K! \ncontinue....\n, argv[loop] ) ;#####:   99:                        continue ;-: 100:                }#####这就是表示没跑到的各个参数使用如下gcov [-b] [-c] [-v] [-n] [-l] [-f] [-o directory] sourcefile-bWrite branch frequencies to the output file, and write branch summary info to the standard output. This option allows you tosee how often each branch in your program was taken.//b(ranch),分支测试-cWrite branch frequencies as the number of branches taken, rather than the percentage of branches taken.-vDisplay the gcov version number (on the standard error stream).//太简单了吧,我上面用了-nDo not create the gcov output file.-lCreate long file names for included source files. For example, if the header file x.h contains code, and was included in thefile a.c, then running gcov on the file a.c will produce an output file called a.c.x.h.gcov instead of x.h.gcov. This canbe useful if x.h is included in multiple source files.-fOutput summaries for each function in addition to the file level summary.-oThe directory where the object files live. Gcov will search for .bb, .bbg, and .da files in this directory.新版的是这么说的-o directory│file--object-directory directory--object-file fileSpecify either the directory containing the gcov data files, or theobject path name. The .gcno, and .gcda data files are searched forusing this option. If a directory is specified, the data files arein that directory and named after the source file name, without itsextension. If a file is specified here, the data files are namedafter that file, without its extension. If this option is not sup-plied, it defaults to the current directory.其他的更有新版的-u,-u--unconditional-branchesWhen branch counts are given, include those of unconditionalbranches. Unconditional branches are normally not interesting.-p--preserve-pathsPreserve complete path information in the names of generated .gcovfiles. Without this option, just the filename component is used.With this option, all directories are used, with ’/’ characterstranslated to ’#’ characters, ’.’ directory components removed and’..’ components renamed to ’^’. This is useful if sourcefiles arein several different directories. It also affects the -l option.二、关于lcovLcov则是上的gcov结果展现的一个前端可以将覆盖率信息转换成html展现。1.如何访问用户空间应用程序代码覆盖数据的示例---------------------------------------------------------------------前提条件使用GCC以-fprofile-arcs和-ftest-coverage选项编译程序。假设编译目录名称为/root/test/code_cover/然后执行以我的一个实例/root/test/code_cover/下的fork.c为例看代码的覆盖率首先进入/root/test/code_cover/目录a)重置计数器lcov --directory . --zerocountersb)收集当前代码覆盖状态到一个文件(应用程序启动和停止至少一次后该命令才能正常工作)lcov --directory . --capture --output-file app.infoCapturing coverage data from .Found gcov version: 3.4.6Scanning . for .gcda files ...Found 1 data files in .Processing ./TestQuery.gcdaFinished .info-file creationc)获取HTML输出genhtml -o results app.info其中的“-o results”是指示结果存放在什么位置的。Readingdata file app.infoFound 18 entries.Found common filename prefix /home/search/isearch_yb/srcWriting .css and .png files.Generating output.Processing file cpp/core/basis/GlobalDef.hProcessing file cpp/core/search/QueryCache.h...Writing directory view page.Overall coverage rate: 117 of 514 lines (22.8%)使用web浏览器打开index.html文件查看代码覆盖结果。三、Linux内核覆盖率测试将最终的gcov内核模块文件复制到system wide modules目录或者PERL脚本所在目录。以root身份执行Gcov在对Linux内核程序进行代码覆盖率测试时同样可以采用gcov但是需要对kernel打一个补丁。Gcov的内核补丁下载地址。下载gcov内核补丁(wget)解压补丁然后为一个kernel打补丁(patch –p1 /home/linux-v3.4-mem/gcov-kernel-2/linux-2.6.18-gcov.patch)注意打补丁时应该处于内核的主目录下也即/home/linux-v3.4-mem打完补丁之后通过make menuconfig配置gcov配置页面显示如下配置完毕之后重新编译内核将编译成功的gcov这个内核模块/home/linux-v3.4-mem /kernel/gcov/gcov-proc.ko拷贝到网络文件系统下面arm linux系统启动后加载这个模块(1)/insmod gcov-proc.ko然后再跑其他测试程序跑了一段时间你会发现在/proc/gcov目录下有各种gcov的统计文件/proc/gcov # lsarch      crypto    init      kernel    security  vmlinuxblock     drivers   ipc       net       sound把这整个目录拷贝到fedora虚拟机下的一个目录我是拷贝到/nfs/kernel_test/gcov目录下然后(2)收集当前代码覆盖状态到一个文件lcov --directory . --output-file kernel.info(3)获取HTML输出genhtml kernel.info使用web浏览器打开index.html文件查看代码覆盖结果。上面是怎样获取内核运行代码覆盖率的一般方法及流程。但如果我们只想获取一个程序运行时的内核代码覆盖率改怎么办呢这里先说几个gcov-proc模块的特性(1)模块属性我们发现/sys/module/gcov_proc下有parameters文件夹进去我们发现有两个属性文件/sys/module/gcov_proc/parameters # lsgcov_linkgcov_persist这两个属性是控制什么的呢看看官方表述- gcov_link0/1 (default is 1): When set to non-zero, symbolic links tosource and gcov graph files are created in /proc/gcov along with the datafiles.- gcov_persist0/1 (default is 0): When set to non-zero, gcov data forkernel modules is kept even after those modules are unloaded so thatcoverage measurements can be extended to module cleanup code. To clearthis persistent data, write to /proc/vmlinux.(2)重启内核覆盖率采集的数据To reset coverage data for a specific file, simply write to the associated datafile in the /proc/gcov hierarchy:echo 0 /proc/gcov/kernel/signal.daTo reset all coverage data, write to the extra file /proc/gcov/vmlinux:echo 0 /proc/gcov/vmlinux四、获取程序运行时段的内核覆盖率我的方法是在运行应用程序(这里面是以我的/nfs/memtest/timetest下的timetest应用程序为例)的开始先用“echo 0 /proc/gcov/vmlinux”指令将我们的/proc/gcov下的统计信息全部清空让它重新计数的下面说下我们的方法和步骤1、先获得一个含义gcov信息的内核和gcov-proc.ko这个上面已经说过了2、启动linux内核然后安装gcov-proc.ko/memtest # insmod gcov-proc.kogcov-proc: initializing proc module: persist0 link1 formatgcc 3.4gcov-proc: init done/memtest # cd timetest//memtest/timetest # ls20100106.logfp2timetesttimetest.ctimetest.gcno20100111.logresultstimetest-lcovtimetest.gcda3、这时先用“echo 0 /proc/gcov/vmlinux”指令清空gcov然后运行timetest然后将/proc/gcov拷贝到/tmp下面这是防止直接拷到虚拟机下会产生大量的网络函数调用增加统计误差。/memtest/timetest # echo 0 /proc/gcov/vmlinux ./timetest cp -r /proc/gcov/ /tmpgame over count1 is 0xc9413e40,count2 is 0x0,count3 is 0x3c8b1e45,count4 is 0x0/memtest/timetest # ls /tmpgcov4、现在统计的数据是放在/tp/gcov下面的我们需要将之拷贝到上位机的虚拟机中才能分析因为我们的lcov只能在虚拟机中才能运行的。/memtest/timetest # cp -r /tmp/gcov/ .//memtest/timetest #5、现在需要转到虚拟机下接着运行lcov来产生最后的html页面了。[rootlocalhost timetest]# cd gcov/[rootlocalhost gcov]# lcov --directory . --capture --output-file timetest.info[rootlocalhost gcov]# genhtml -o results timetest.info这样就生成了最后基本上只运行在timetest时间段的内核代码覆盖率了。
http://www.zqtcl.cn/news/551853/

相关文章:

  • 河南建设网站公司简介做新闻类网站需要什么资质
  • 网络文化经营许可证图片下载优化大师安装桌面
  • 网站cms系统教育网站开发文档
  • 用网站做淘客怎么做网站建设在电访销售话术
  • 做电影网站赚了几百万动画制作流程
  • 怎么做企业的网站首页wordpress 主机迁移
  • 网站常见问题网页设计代码开头
  • 聊城网站推广品牌推广计划描述
  • 池州网站制作优化有没有专业做特产的网站
  • wordpress采集站源码wordpress好用的会员插件
  • 寿县城乡建设局网站青岛网站建设大全
  • 杭州做网站的好公司哪家好做影视网站侵权吗
  • 自助建站网站seo公司想学编程做网站
  • 网站空间备案要多久花木公司网站源码
  • 高端求职网站排名ftontpage如何做网站
  • 音乐网站开发技术河南省住房和城乡建设门户网站
  • 吉安微信网站弋阳县建设工程网站
  • 网站建设自学建站视频教程哈尔滨全国网站建设
  • 网站建设基础培训网站架构拓扑图
  • 网站开发价格预算成都必去的地方排行榜
  • 鹤岗做网站企业建立网站主要包括那些流程
  • 如何进网站出口外贸是做什么的
  • 网站制作北京网站建设公司哪家好一个人 建设网站
  • 百度网站是什么阿里云免费网站建设
  • 网站建设平台源码攻击网站步骤
  • 注册了网站之后怎么设计深圳开发app
  • 国外网站搭建平台移动互联网公司
  • 做网络私活的网站网站开发的人
  • 数据分析网站开发四川手机网站设计方案
  • 什么是网络营销的方法莱州网站建设关键字排名优化网络托管微信代运营