Add "VALGRIND" build type 93/107893/4
authorRafal Krypa <r.krypa@samsung.com>
Fri, 30 Dec 2016 13:49:03 +0000 (14:49 +0100)
committerRafal Krypa <r.krypa@samsung.com>
Tue, 28 Mar 2017 07:42:49 +0000 (09:42 +0200)
Separate build type specialized for debugging memory leaks.
Example usage with GBS for Tizen:
  $ gbs build --define "build_type VALGRIND"

Change-Id: I7e150609021508541427ff009fa28b97a6004daf

CMakeLists.txt
packaging/security-manager.spec
systemd/CMakeLists.txt
systemd/security-manager-valgrind.service.in [new file with mode: 0644]

index 77a6a35..d3d885a 100644 (file)
@@ -62,6 +62,7 @@ SET(CMAKE_CXX_FLAGS_PROFILING  "-g -std=c++0x -O0 -pg -Wp,-U_FORTIFY_SOURCE")
 SET(CMAKE_CXX_FLAGS_DEBUG      "-g -std=c++0x -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
 SET(CMAKE_CXX_FLAGS_RELEASE    "-g -std=c++0x -O2")
 SET(CMAKE_CXX_FLAGS_CCOV       "-g -std=c++0x -O2 --coverage")
+SET(CMAKE_CXX_FLAGS_VALGRIND   "-ggdb -std=c++0x -O0 -fno-inline -Wp,-U_FORTIFY_SOURCE")
 
 # If supported for the target machine, emit position-independent code,suitable
 # for dynamic linking and avoiding any limit on the size of the global offset
index a03f207..8d24815 100644 (file)
@@ -11,6 +11,9 @@ Source4:    libnss-security-manager.manifest
 Source5:    security-manager-tests.manifest
 Requires: security-manager-policy
 Requires: nether
+%if "%{build_type}" == "VALGRIND"
+Requires: valgrind
+%endif
 Requires(post): sqlite3
 Requires(post): smack
 BuildRequires: cmake
index 8d0a1aa..3e20c9b 100644 (file)
@@ -1,4 +1,9 @@
-CONFIGURE_FILE(security-manager.service.in security-manager.service @ONLY)
+IF(CMAKE_BUILD_TYPE MATCHES "VALGRIND")
+    CONFIGURE_FILE(security-manager-valgrind.service.in security-manager.service @ONLY)
+ELSE()
+    CONFIGURE_FILE(security-manager.service.in security-manager.service @ONLY)
+ENDIF()
+
 CONFIGURE_FILE(security-manager-cleanup.service.in security-manager-cleanup.service @ONLY)
 CONFIGURE_FILE(security-manager-rules-loader.service.in security-manager-rules-loader.service @ONLY)
 
diff --git a/systemd/security-manager-valgrind.service.in b/systemd/security-manager-valgrind.service.in
new file mode 100644 (file)
index 0000000..ad02fcf
--- /dev/null
@@ -0,0 +1,15 @@
+[Unit]
+Description=Start the security manager
+Before=dbus.service
+
+[Service]
+Type=notify
+Environment="GLIBCXX_FORCE_NEW=1"
+ExecStart=@BIN_INSTALL_DIR@/valgrind -v --tool=memcheck --log-file=/tmp/security-manager.valgrind.%%p.log --num-callers=20 --leak-resolution=high --leak-check=full --show-reachable=yes --track-origins=yes @BIN_INSTALL_DIR@/security-manager
+#ExecStart=@BIN_INSTALL_DIR@/valgrind -v --tool=massif --log-file=/tmp/security-manager.valgrind.%%p.log --massif-out-file=/tmp/security-manager.massif.%%p.log @BIN_INSTALL_DIR@/security-manager
+Sockets=security-manager.socket
+Restart=always
+SmackProcessLabel=System::Privileged
+
+[Install]
+WantedBy=dbus.service