- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试获取基于 arm 的嵌入式系统的代码覆盖率。使用 x86 进行交叉编译。基本上,我有一个交叉分析问题。
对于我想要生成代码覆盖率数据的应用程序,我定义了一个信号处理程序,我在其中调用 __gcov_flush()
将代码覆盖率数据刷新到 .gcda 文件。我正在向应用程序发送 SIGUSR1。该应用程序使用多个 .so 文件,其中实现了大量代码和逻辑。
当我向进程发送信号时,仅为应用程序创建/更新了 .gcda 文件。 .so 的 .gcda 文件根本没有创建/更新。
有没有办法让 __gcov_flush()
刷新应用程序正在使用的 .so 的所有覆盖率数据?
我不想强制应用程序 exit()
因为那样会破坏我想要做的事情的目的。我需要能够转储应用程序的覆盖数据以及它在运行时使用的 .so。请帮忙!!
使用 ARM GCC v4.5.1。
这是我到目前为止为生成代码覆盖率数据所做的工作:
我在主联编文件中为 GCC 定义了以下选项:CFLAGS += -fprofile-arcs -ftest-coverage
LDFLAGS += -fprofile-arcs -ftest-coverage
我还将 GCOV_PREFIX
和 GCOV_PREFIX_STRIP
导出为目标系统上的全局环境变量,以强制在特定路径中创建 .gcda 文件。这是有效的。
我唯一的问题是当从应用程序调用 __gcov_flush()
时,.so 的 .gcda 文件没有被创建/更新。
最佳答案
这个问题在 GCC 邮件列表上得到了回答。TLDR:需要在每个使用的共享库中添加一个处理程序,它将转储覆盖率数据。然后需要调用这些处理程序。
来自the mailing list的详细回答如下。
On Fri, 19 Jun 2015, Utpal Patel wrote:
I am trying to get code coverage for an arm based embedded system. Using x86 for cross compilation.So basically, I have a cross profiling question.
For the application I want to generate code coverage data, I have defined a signal handler inside which I call __gcov_flush() to flush code coverage data to .gcda files. I am sending SIGUSR1 to the application. The application uses multiple .so files where bulk of the code and logic is implemented.
When I send the signal to the process, the .gcda files for just the application get created/updated. The .gcda files for the .so's are not created/updated at all.
Is there a way to make __gcov_flush() flush all the coverage data for the .so's that the application is using?
I dont want to force the application to exit() because that would defeat the purpose of what I am trying to do. I need to be able to dump coverage data for the application and the .so it uses at runtime. Please help!!
When you compiled your application with
-fprofile-arcs
only the application was instrumented (conceptually a 64bit counters in each basic block of the apps minimum spaning tree) and those counters are what
-ftest-coverage__gcov_flush()
is dumping.So if you want profiling infos from libraries you need to compile the library for profiling as gcov is a static instrumentation and there is no way to get infos from a
.so
without that it was compiled for profiling just like your application. If the application is compiled for profiling then its data will be dumped when you call__gcov_flush()
but since you can not send signals to a library to call some handler you would need to install some other mechanism in the library e.g. brute force put aint libdump(void) {
__gcov_flush();
}into the library and call that from your application signal handler just like you called
__gcov_flush();
now.This is from a trivial library that just provides an open call that is a wrapper to libc open and the libdump function
2: 77:int libdump(void) {
2: 78: __gcov_flush();
1: 79: return 0;
-: 80:}
-: 81:/* we now can get code coverage of the library */
145: 82:int open(const char *pathname, int flags, mode_t mode) {
145: 83: return __open(pathname, flags, mode);
-: 84:}the library is compiled with
gcc -fPIC -Wall -g -O2 -fprofile-arcs -ftest-coverage -shared -o libgctest.so.0 libgc.c
the application has the
libdump()
in the signal handlerint libdump(void);
void gc_handler(int signum)
{
printf("received signal\n");
__gcov_flush(); /* dump coverage data on receiving SIGUSR1 */
libdump(); /* and dump library converage data */
}and is compiled with
gcc -O2 -fprofile-arcs -ftest-coverage hello.c -o hello -lgctest
`kill -10 <PIDOF application>` will now dump the gcda of both application and library.HTH hofrat
ps: I have no clue why the count of the return 0 line in the libhandler does not have a count of 2 as well....
关于code-coverage - GCOV 交叉分析 : __gcov_flush() does not flush coverage data for shared libraries,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30929205/
在MySQL中,执行FLUSH TABLES, PRIVILEGES;和执行FLUSH TABLES;再执行FLUSH PRIVILEGES;效果一样吗?此外,这是否适用于任何刷新选项(FLUSH L
在spring security生成类UserRole或 SecUserSecRole (你可以随便叫它)有一个命令可以创建 new UserRole()并用 .save(flush:flush, i
我正在使用 Hibernate 3.2.6。我正面临异常(exception)情况 save the transient instance before flushing 在我的代码中,有时我们在一个
我有一个 StreamWriter,它的底层流是一个 FileStream。以下代码是否保证 FileStream 也将其缓冲区刷新到文件系统上的实际文件中,还是我需要在 上显式调用 Flush()文
我在 ASP.NET Web API 中使用 PushStreamContent 将事件从服务器推送到客户端(使用服务器发送事件)。每次发送事件后,我都会在 Stream 上调用 Flush 以将缓冲
MSDN说FileStream.Flush(True) “还清除所有中间文件缓冲区。”。 “所有中间文件缓冲区”到底是什么意思? 最佳答案 它会将缓冲在文件系统缓存中的文件数据写入磁盘。该数据通常是根
在我的项目中,我有很多嵌套的对象,几天后服务器在每次查询执行时都变得非常缓慢。 我从object.save(flush:true)中删除了flush:true,这应该避免对象立即被数据库持久化,因为我
假设您需要将二进制数据写入标准输出: sys.stdout.buffer.write(data) 然后要刷新它,您可以使用以下两种方法之一: sys.stdout.flush() sys.stdout
我已经覆盖了 std::ostream::flush() 函数。下面我从示例中删除了所有其他代码: #include #include class CMyStream : public std::
我在我的服务中实现了取消 http 请求,我想测试它: angular.module('EmsWeb.Services').factory('DalService', ['$q', '$http',
有这个 Angular 组件: import { Component, OnDestroy, OnInit } from '@angular/core'; import { asyncSchedule
magento的缓存管理中“Flush Magento Cache”和“Flush Cache Storage”有什么区别? 最佳答案 有时,缓存位置(如 /tmp/)或服务(如 Memcache)会
我有一个实现 postFlush() 的 Hibernate 拦截器.据我了解,刷新后是数据已保存到数据库中,但在调用提交之前可能会回滚。如果我有一个看起来像这样的 hibernate 配置: tru
这是我第一次接触 Clojure,所以我尝试编写一个简单的脚本,它提供基于维基百科的翻译(欢迎任何批评/评论) 问题是:当我从翻译中删除(刷新)时,脚本输出 nil 而不是翻译后的单词。这是为什么?我
我正在开发 iPhone 应用程序并希望使用: CFStreamCreatePairWithSocketToHost(NULL, url, port, &serverReadStream, &serv
我有一个相机将图片发送到回调函数,我想使用 FFmpeg 用这些图片制作一部电影。我遵循了 decoding_encoding 示例 here但我不确定如何使用 got_output 刷新编码器并获取
is_master_def: volatile bool is_master_; is_master_ 值被另一个线程设置为 true,但似乎 is_master_ 值 dosnt 刷新(它没有计算出
什么意思 “我会在您将所有内容发送给客户端并刷新后执行此操作。” 谢谢你 最佳答案 刷新是对数据流进行缓冲时涉及的操作。 让我们假设一个普通的stdout 流。每个字节一到达就打印出来效率很低,这就是
我们正在开发 iMX6Sx Freescale 开发板,使用 Yocto 构建 Linux 内核发行版。我想知道是否有办法检查是否有可能检查文件系统操作(特别是写入)是否真的终止,避免在操作仍在进行时
我已经实现了一个 Java 程序,它通过 ServerSocket 从 GPS 设备读取数据。 ServerSocket serverSocket = new ServerSocket(13811);
我是一名优秀的程序员,十分优秀!