??C++???????и????????
???????????? ???????[ 2014/7/17 11:28:19 ] ????????C++ net
??????1????????????????????????б?????????????????????????????????????????spec????????
1 sed -i '$ aexport LD_PRELOAD=/usr/local/bin/ccover_tool/gcov_out.so' /home/ads/.bash_profile
2 SPECFILE=`dirname $(gcc -print-libgcc-file-name)`/specs
3 gcc -dumpspecs >$SPECFILE
4 sed -i '/^*libgcc:/ { n; s/$/ -lgcov/; }' $SPECFILE
5 sed -i '/^*cc1:/ {n; s/$/ -fprofile-arcs -ftest-coverage/; }' $SPECFILE
6 sed -i '/^*cc1plus:/ {n; s/$/ -fprofile-arcs -ftest-coverage/; }' $SPECFILE
|
????(2)??Σ?????????????????????????exit()???dump???????????????????????kill -9 ??????????kill???
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#define SIMPLE_WAY
void sighandler(int signo)
{
#ifdef SIMPLE_WAY
exit(signo);
#else
extern void __gcov_flush();
// flush out gcov stats data
__gcov_flush();
// raise the signal again to crash process
raise(signo);
#endif
}
__attribute__ ((constructor))
void ctor()
{
int sigs[] = {
SIGILL?? SIGFPE?? SIGABRT?? SIGBUS??
SIGSEGV?? SIGHUP?? SIGINT?? SIGQUIT??
SIGTERM
};
int i;
struct sigaction sa;
sa.sa_handler = sighandler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESETHAND;
for(i = 0; i < sizeof(sigs)/sizeof(sigs[0]); ++i) {
if (sigaction(sigs[i]?? &sa?? NULL) == -1) {
perror("Could not set signal handler");
}
}
}
|
??????????????.so
????gcov_out.so:gcov_out.c
????gcc -shared -fPIC gcov_out.c -o gcov_out.so
???????????export LD_PRELOAD=gcov_out.so
????(3)??????У???????к??????????????????????????????·????
????(4)????????????????????????????????????????????????????????к????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11