File tree 4 files changed +56
-3
lines changed
4 files changed +56
-3
lines changed Original file line number Diff line number Diff line change 92
92
AM_CONDITIONAL(ARCH64, test `getconf LONG_BIT` = "64")
93
93
fi
94
94
95
+ AC_ARG_ENABLE ( asan ,
96
+ [ --enable-asan Compile with address sanitizer] ,
97
+ [ case "${enableval}" in
98
+ yes) asan_enabled=true ;;
99
+ no) asan_enabled=false ;;
100
+ *) AC_MSG_ERROR ( bad value ${enableval} for -- enable-asan ) ;;
101
+ esac] ,[ asan_enabled=false] )
102
+
103
+ if test "x$asan_enabled" = "xtrue"; then
104
+ CFLAGS_ASAN+=" -fsanitize=address"
105
+ CFLAGS_ASAN+=" -DASAN_ENABLED"
106
+ CFLAGS_ASAN+=" -ggdb -fno-omit-frame-pointer -U_FORTIFY_SOURCE"
107
+ AC_SUBST ( CFLAGS_ASAN )
108
+
109
+ LDFLAGS_ASAN+=" -lasan"
110
+ AC_SUBST ( LDFLAGS_ASAN )
111
+ fi
112
+
113
+ AM_CONDITIONAL(ASAN_ENABLED, test x$asan_enabled = xtrue)
114
+
95
115
AC_PATH_PROGS ( SWIG , [ swig3.0 swig] )
96
116
97
117
CXXFLAGS_COMMON=""
Original file line number Diff line number Diff line change @@ -67,9 +67,14 @@ binary-syncd-vs:
67
67
# dh_auto_configure -- \
68
68
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
69
69
70
+ configure_opts =
71
+ ifeq ($(ENABLE_ASAN ) , y)
72
+ configure_opts += --enable-asan
73
+ endif
74
+
70
75
override_dh_auto_configure :
71
76
./autogen.sh
72
- dh_auto_configure -- $(DEB_CONFIGURE_EXTRA_FLAGS ) $(shell cat /tmp/syncd-build) ${SWSS_COMMON_CONFIG}
77
+ dh_auto_configure -- $(DEB_CONFIGURE_EXTRA_FLAGS ) $(shell cat /tmp/syncd-build) ${SWSS_COMMON_CONFIG} $( configure_opts )
73
78
74
79
override_dh_install :
75
80
dh_install
Original file line number Diff line number Diff line change
1
+ #include " swss/logger.h"
2
+
3
+ #include < csignal>
4
+ #include < sanitizer/lsan_interface.h>
5
+
6
+ static void sigterm_handler (int signo)
7
+ {
8
+ SWSS_LOG_ENTER ();
9
+
10
+ __lsan_do_leak_check ();
11
+ signal (signo, SIG_DFL);
12
+ raise (signo);
13
+ }
14
+
15
+ __attribute__ ((constructor))
16
+ static void asan_init()
17
+ {
18
+ SWSS_LOG_ENTER ();
19
+
20
+ if (signal (SIGTERM, sigterm_handler) == SIG_ERR)
21
+ {
22
+ SWSS_LOG_ERROR (" failed to setup SIGTERM action" );
23
+ exit (1 );
24
+ }
25
+ }
Original file line number Diff line number Diff line change @@ -56,11 +56,14 @@ libSyncd_a_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS)
56
56
libSyncd_a_CXXFLAGS = $(DBGFLAGS ) $(AM_CXXFLAGS ) $(CXXFLAGS_COMMON ) $(CODE_COVERAGE_CXXFLAGS )
57
57
58
58
syncd_SOURCES = main.cpp
59
+ if ASAN_ENABLED
60
+ syncd_SOURCES += Asan.cpp
61
+ endif
59
62
syncd_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS )
60
- syncd_CXXFLAGS = $(DBGFLAGS ) $(AM_CXXFLAGS ) $(CXXFLAGS_COMMON ) $(CODE_COVERAGE_CXXFLAGS )
63
+ syncd_CXXFLAGS = $(DBGFLAGS ) $(AM_CXXFLAGS ) $(CXXFLAGS_COMMON ) $(CODE_COVERAGE_CXXFLAGS ) $( CFLAGS_ASAN )
61
64
syncd_LDADD = libSyncd.a $(top_srcdir ) /lib/libSaiRedis.a -L$(top_srcdir ) /meta/.libs -lsaimetadata -lsaimeta \
62
65
-ldl -lhiredis -lswsscommon $(SAILIB ) -lpthread -lzmq $(CODE_COVERAGE_LIBS )
63
- syncd_LDFLAGS = -rdynamic
66
+ syncd_LDFLAGS = $( LDFLAGS_ASAN ) -rdynamic
64
67
65
68
if SAITHRIFT
66
69
libSyncd_a_CXXFLAGS += -DSAITHRIFT=yes
You can’t perform that action at this time.
0 commit comments