-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce gcovpreload repo to support code coverage report generation for swss and sairedis #11323
base: master
Are you sure you want to change the base?
Changes from all commits
ab433a1
e2fbf90
685fa8f
3957337
ba21501
2b9eaea
e9a3e6b
b28e173
f858d26
f0dabfd
d507796
928f04d
446e6f6
710da0c
f868eb6
7d158d0
88cdfe3
45bbeb5
ccdb1e2
465c9ad
3a00844
932ded8
a429f44
1173bb2
0525e1f
733ceae
39f4256
d3eef75
6cde260
b0bbc1d
0828cce
fc04151
a6d97d0
e9c60ab
59af7a2
c306750
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# libgcovpreload package | ||
# Created for gcda files generations | ||
|
||
GCOV_PRELOAD_VERSION = 0.0.1 | ||
GCOV_PRELOAD_VERSION_FULL = $(GCOV_PRELOAD_VERSION)-1 | ||
|
||
export GCOV_PRELOAD_VERSION GCOV_PRELOAD_VERSION_FULL | ||
|
||
LIBGCOV_PRELOAD = libgcovpreload_$(GCOV_PRELOAD_VERSION_FULL)_$(CONFIGURED_ARCH).deb | ||
$(LIBGCOV_PRELOAD)_SRC_PATH = $(SRC_PATH)/preload | ||
|
||
SONIC_MAKE_DEBS += $(LIBGCOV_PRELOAD) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,40 +8,43 @@ $(LIBSAIREDIS)_DPKG_TARGET = binary-sairedis | |
$(LIBSAIREDIS)_SRC_PATH = $(SRC_PATH)/sonic-sairedis | ||
$(LIBSAIREDIS)_VERSION = $(LIBSAIREDIS_VERSION) | ||
$(LIBSAIREDIS)_NAME = $(LIBSAIREDIS_NAME) | ||
$(LIBSAIREDIS)_DEPENDS += $(LIBSWSSCOMMON_DEV) | ||
$(LIBSAIREDIS)_DEPENDS += $(LIBSWSSCOMMON_DEV) $(LIBGCOV_PRELOAD) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure my understanding is correct. Is it for code coverage? Is it possible to install it on demand, we can enable it in PR build, for official build to install in devices, looks like it is not necessary. We may need to clean some tools for build/test only in the image. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, I have raised a sairedis PR to support GCOV, but need preload lib(the reason why can't build with sairedis repo together has mentioned in PR: sonic-net/sonic-sairedis#972). As I know, pipeline framework will download vs docker and install sairedis deb into it, and then do testing. So i need to make sure that the downloaded docker encompass preload lib. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do not want LIBGCOV_PRELOAD in the sonic image. You only need it in test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there other ways to solve this problem? to make sure that vs docker downloaded by pipeline framework when testing encompass gcov preload lib and this lib will not in sonic image ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Do you have any idea about how to solve this problem? |
||
$(LIBSAIREDIS)_RDEPENDS += $(LIBSWSSCOMMON) | ||
$(LIBSAIREDIS)_DEB_BUILD_OPTIONS = nocheck | ||
SONIC_DPKG_DEBS += $(LIBSAIREDIS) | ||
|
||
LIBSAIREDIS_DEV = $(LIBSAIREDIS_NAME)-dev_$(LIBSAIREDIS_VERSION)_$(CONFIGURED_ARCH).deb | ||
$(LIBSAIREDIS_DEV)_DEPENDS += $(LIBGCOV_PRELOAD) | ||
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIREDIS_DEV))) | ||
|
||
LIBSAIVS = libsaivs_$(LIBSAIREDIS_VERSION)_$(CONFIGURED_ARCH).deb | ||
$(LIBSAIVS)_DEPENDS += $(LIBGCOV_PRELOAD) | ||
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIVS))) | ||
|
||
LIBSAIVS_DEV = libsaivs-dev_$(LIBSAIREDIS_VERSION)_$(CONFIGURED_ARCH).deb | ||
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIVS_DEV))) | ||
$(LIBSAIVS_DEV)_DEPENDS += $(LIBSAIVS) | ||
$(LIBSAIVS_DEV)_DEPENDS += $(LIBSAIVS) $(LIBGCOV_PRELOAD) | ||
|
||
LIBSAIMETADATA = libsaimetadata_$(LIBSAIREDIS_VERSION)_$(CONFIGURED_ARCH).deb | ||
$(LIBSAIMETADATA)_DEPENDS += $(LIBGCOV_PRELOAD) | ||
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIMETADATA))) | ||
|
||
LIBSAIMETADATA_DEV = libsaimetadata-dev_$(LIBSAIREDIS_VERSION)_$(CONFIGURED_ARCH).deb | ||
$(LIBSAIMETADATA_DEV)_DEPENDS += $(LIBSAIMETADATA) | ||
$(LIBSAIMETADATA_DEV)_DEPENDS += $(LIBSAIMETADATA) $(LIBGCOV_PRELOAD) | ||
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIMETADATA_DEV))) | ||
|
||
LIBSAIREDIS_DBG = $(LIBSAIREDIS_NAME)-dbg_$(LIBSAIREDIS_VERSION)_$(CONFIGURED_ARCH).deb | ||
$(LIBSAIREDIS_DBG)_DEPENDS += $(LIBSAIREDIS) | ||
$(LIBSAIREDIS_DBG)_DEPENDS += $(LIBSAIREDIS) $(LIBGCOV_PRELOAD) | ||
$(LIBSAIREDIS_DBG)_RDEPENDS += $(LIBSAIREDIS) | ||
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIREDIS_DBG))) | ||
|
||
LIBSAIVS_DBG = libsaivs-dbg_$(LIBSAIREDIS_VERSION)_$(CONFIGURED_ARCH).deb | ||
$(LIBSAIVS_DBG)_DEPENDS += $(LIBSAIVS) | ||
$(LIBSAIVS_DBG)_DEPENDS += $(LIBSAIVS) $(LIBGCOV_PRELOAD) | ||
$(LIBSAIVS_DBG)_RDEPENDS += $(LIBSAIVS) | ||
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIVS_DBG))) | ||
|
||
LIBSAIMETADATA_DBG = libsaimetadata-dbg_$(LIBSAIREDIS_VERSION)_$(CONFIGURED_ARCH).deb | ||
$(LIBSAIMETADATA_DBG)_DEPENDS += $(LIBSAIMETADATA) | ||
$(LIBSAIMETADATA_DBG)_DEPENDS += $(LIBSAIMETADATA) $(LIBGCOV_PRELOAD) | ||
$(LIBSAIMETADATA_DBG)_RDEPENDS += $(LIBSAIMETADATA) | ||
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIMETADATA_DBG))) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
gcovpreload/debian/* | ||
!gcovpreload/debian/changelog | ||
!gcovpreload/debian/control | ||
!gcovpreload/debian/rules | ||
!gcovpreload/debian/libgcovpreload.postinst |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.ONESHELL: | ||
SHELL = /bin/bash | ||
.SHELLFLAGS += -e | ||
|
||
MAIN_TARGET = libgcovpreload_$(GCOV_PRELOAD_VERSION_FULL)_$(CONFIGURED_ARCH).deb | ||
|
||
$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : | ||
pushd gcov_preload | ||
dpkg-buildpackage -rfakeroot -d -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) | ||
popd | ||
mv $* $(DEST)/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#gcov Makefile | ||
|
||
MKDIR := mkdir | ||
MV := mv | ||
#OBJ=gcov_preload.o | ||
LIBNAME=libgcovpreload | ||
|
||
# Fallback to gcc when $CC is not in $PATH. | ||
CC:=$(shell sh -c 'type $${CC%% *} >/dev/null 2>/dev/null && echo $(CC) || echo gcc') | ||
CXX:=$(shell sh -c 'type $${CXX%% *} >/dev/null 2>/dev/null && echo $(CXX) || echo g++') | ||
|
||
DYLIBSUFFIX=so | ||
DYLIBNAME=$(LIBNAME).$(DYLIBSUFFIX) | ||
DYLIB_MAKE_CMD=$(CC) -shared -fpic gcov_preload.c -o ${DYLIBNAME} | ||
|
||
$(DYLIBNAME): | ||
$(DYLIB_MAKE_CMD) | ||
|
||
# Other Targets | ||
install: | ||
$(MKDIR) -p $(DESTDIR)/usr/lib | ||
$(MV) $(DYLIBNAME) $(DESTDIR)/usr/lib |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
gcovpreload (0.0.1-1) stretch-backports; urgency=medium | ||
|
||
* Rebuild for stretch-backports. (Closes: #911732) | ||
|
||
--Petter Shao <pettershao@ragilenetworks> Wed, 07 Nov 2021 11:26:50 +0000 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Source: gcovpreload | ||
Priority: optional | ||
Maintainer: Petter Shao <pettershao@ragilenetworks> | ||
Build-Depends: | ||
debhelper-compat (= 11), | ||
procps <!nocheck>, | ||
redis-server (>= 2:2.4.2-2) [linux-any kfreebsd-any] <!nocheck>, | ||
Standards-Version: 4.2.1 | ||
Section: libs | ||
Homepage: | ||
Vcs-Git: | ||
Vcs-Browser: | ||
|
||
Package: libgcovpreload | ||
Architecture: any | ||
Depends: | ||
${misc:Depends}, | ||
${shlibs:Depends}, | ||
Pre-Depends: | ||
${misc:Pre-Depends}, | ||
Multi-Arch: same | ||
Description: minimalistic C client library for Redis |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ | ||
Upstream-Name: gcovpreload | ||
Upstream-Contact: Petter Shao <pettershao@ragilenetworks> | ||
Source: | ||
|
||
Files: * | ||
Copyright: | ||
License: BSD-3-Clause |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
libgcovpreload |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# !/bin/sh | ||
# postinst | ||
echo /usr/lib/libgcovpreload.so > /etc/ld.so.preload | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/make -f | ||
|
||
%: | ||
dh $@ | ||
|
||
override_dh_auto_install: | ||
dh_auto_install -- LIBRARY_PATH="lib/" \ | ||
PREFIX=/usr |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <signal.h> | ||
#include <signal.h> | ||
#define SIMPLE_WAY | ||
|
||
void sighandler(int signo) | ||
{ | ||
#ifdef SIMPLE_WAY | ||
exit(signo); | ||
#else | ||
extern void __gcov_flush(); /* flush*/ | ||
__gcov_flush(); /* flush out gcov stats data */ | ||
raise(signo); /* raise the signal again to crash process */ | ||
#endif | ||
} | ||
|
||
/** | ||
* The code for cracking the preloaded dynamic library gcov_preload.so is as follows, where __attribute__((constructor)) is the symbol of gcc, | ||
* The modified function will be called before the main function is executed. We use it to intercept the exception signal to our own function, and then call __gcov_flush() to output the error message | ||
*/ | ||
|
||
__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"); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the change is not necessary, may need to remove the last character "\", or miss a dependent target name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have the same concern.