-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from Comcast/kraj/master
Fix cppsdk/webbridge for backtrace() API
- Loading branch information
Showing
8 changed files
with
259 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
recipes-metrological/cppsdk/cppsdk/0001-Detect-libexecinfo-if-available-on-platform.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
From 1be47b8dbaa7ee9ccd297b674861793bd7f9231d Mon Sep 17 00:00:00 2001 | ||
From: Khem Raj <raj.khem@gmail.com> | ||
Date: Fri, 24 Mar 2017 18:31:49 -0700 | ||
Subject: [PATCH] Detect libexecinfo if available on platform | ||
|
||
Some platform e.g. freebsd or musl based linux platforms | ||
where backtrace() API is not available, there is external | ||
library libexecinfo which provides same funcitonality | ||
try to find this library if available add it to linker | ||
cmdline | ||
|
||
Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
--- | ||
CMakeLists.txt | 2 ++ | ||
cmake/FindExecInfo.cmake | 14 ++++++++++++++ | ||
config.h.in | 1 + | ||
generics/CMakeLists.txt | 4 ++++ | ||
generics/Portability.cpp | 5 ++++- | ||
generics/SocketPort.cpp | 4 ++++ | ||
6 files changed, 29 insertions(+), 1 deletion(-) | ||
create mode 100644 cmake/FindExecInfo.cmake | ||
create mode 100644 config.h.in | ||
|
||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 13a795c..79990dd 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -12,6 +12,7 @@ set (CPPSDK_PLATFORM "PC_UNIX" CACHE STRING "Defines on what platform cppsdk wil | ||
add_definitions(-DPLATFORM_${CPPSDK_PLATFORM}=1) | ||
|
||
include_directories (${CMAKE_SOURCE_DIR}) | ||
+include_directories (${CMAKE_BINARY_DIR}) | ||
|
||
add_definitions (-Wall -fPIC) | ||
|
||
@@ -28,6 +29,7 @@ else() | ||
endif() | ||
|
||
find_package(Threads REQUIRED) | ||
+find_package(ExecInfo) | ||
|
||
option (CPPSDK_GENERICS | ||
"Include the generics library." ON) | ||
diff --git a/cmake/FindExecInfo.cmake b/cmake/FindExecInfo.cmake | ||
new file mode 100644 | ||
index 0000000..b7fb396 | ||
--- /dev/null | ||
+++ b/cmake/FindExecInfo.cmake | ||
@@ -0,0 +1,14 @@ | ||
+include (CheckIncludeFiles) | ||
+find_library (EXECINFO_LIBRARY NAMES execinfo) | ||
+ | ||
+if (EXECINFO_LIBRARY) | ||
+ set (CPPSDK_EXECINFO_LIBRARY ${EXEXINFO_LIBRARY}) | ||
+endif() | ||
+ | ||
+CHECK_INCLUDE_FILE (execinfo.h HAVE_EXECINFO_H) | ||
+ | ||
+configure_file( | ||
+ "${CMAKE_SOURCE_DIR}/config.h.in" | ||
+ "${CMAKE_BINARY_DIR}/config.h" | ||
+ @ONLY) | ||
+ | ||
diff --git a/config.h.in b/config.h.in | ||
new file mode 100644 | ||
index 0000000..6de91b7 | ||
--- /dev/null | ||
+++ b/config.h.in | ||
@@ -0,0 +1 @@ | ||
+#cmakedefine HAVE_EXECINFO_H 1 | ||
diff --git a/generics/CMakeLists.txt b/generics/CMakeLists.txt | ||
index a48eae6..b068367 100755 | ||
--- a/generics/CMakeLists.txt | ||
+++ b/generics/CMakeLists.txt | ||
@@ -14,6 +14,9 @@ set(GENERICS_LIBS | ||
${CMAKE_DL_LIBS} | ||
${GENERICS_RT_LIBRARY} | ||
) | ||
+if (EXECINFO_LIBRARY) | ||
+ list(APPEND GENERICS_LIBS ${EXECINFO_LIBRARY}) | ||
+endif () | ||
|
||
set(GENERICS_SOURCES | ||
SystemInfo.cpp | ||
@@ -44,6 +47,7 @@ set(GENERICS_SOURCES | ||
ProcessInfo.cpp | ||
) | ||
|
||
+ | ||
if(${CPPSDK_PLATFORM} STREQUAL "INTELCE") | ||
include_directories( ${INTELCE_OSAL_INCLUDE_DIRS} ${INTELCE_GDL_INCLUDE_DIRS}) | ||
list(APPEND GENERICS_LIBS ${INTELCE_OSAL_LIBRARIES} ${INTELCE_GDL_LIBRARIES}) | ||
diff --git a/generics/Portability.cpp b/generics/Portability.cpp | ||
index 9f10106..d9ed05b 100644 | ||
--- a/generics/Portability.cpp | ||
+++ b/generics/Portability.cpp | ||
@@ -1,12 +1,15 @@ | ||
#include <stdlib.h> | ||
|
||
+#include "config.h" | ||
#include "Portability.h" | ||
#include "SystemInfo.h" | ||
#include "Sync.h" | ||
|
||
#ifdef __LINUX__ | ||
#include <signal.h> | ||
- | ||
+#ifdef HAVE_EXECINFO_H | ||
+#include <execinfo.h> | ||
+#endif | ||
#define CALLSTACK_SIG SIGUSR2 | ||
#endif | ||
|
||
diff --git a/generics/SocketPort.cpp b/generics/SocketPort.cpp | ||
index 0295676..7aaff33 100644 | ||
--- a/generics/SocketPort.cpp | ||
+++ b/generics/SocketPort.cpp | ||
@@ -3,6 +3,7 @@ | ||
#include "Sync.h" | ||
#include "Singleton.h" | ||
#include "Timer.h" | ||
+#include "config.h" | ||
|
||
#ifdef __POSIX__ | ||
#include <arpa/inet.h> | ||
@@ -21,6 +22,9 @@ | ||
#include <sys/ioctl.h> | ||
#include <sys/signalfd.h> | ||
#include <signal.h> | ||
+#ifdef HAVE_EXECINFO_H | ||
+#include <execinfo.h> | ||
+#endif | ||
#endif | ||
|
||
#ifdef __WIN32__ | ||
-- | ||
2.12.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
recipes-metrological/webbridge/files/0001-Link-libexecinfo-if-platform-provides-it.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
From 0b5b9ebd38380315adeeba1a49dae03dfa5d6f74 Mon Sep 17 00:00:00 2001 | ||
From: Khem Raj <raj.khem@gmail.com> | ||
Date: Fri, 24 Mar 2017 21:42:40 -0700 | ||
Subject: [PATCH] Link libexecinfo if platform provides it | ||
|
||
Platforms e.g. FreeBSD do not have backtrace APIs which | ||
are glibc specific, also systems based on musl/linux | ||
are in same boat. This patch checks for libexecinfo | ||
which provides backtrace functionality on these platforms | ||
|
||
Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
--- | ||
CMakeLists.txt | 5 ++++- | ||
WebBridge/CMakeLists.txt | 5 ++++- | ||
WebBridge/WebBridge.cpp | 4 ++++ | ||
cmake/FindExecInfo.cmake | 14 ++++++++++++++ | ||
config.h.in | 1 + | ||
5 files changed, 27 insertions(+), 2 deletions(-) | ||
create mode 100644 cmake/FindExecInfo.cmake | ||
create mode 100644 config.h.in | ||
|
||
Index: git/CMakeLists.txt | ||
=================================================================== | ||
--- git.orig/CMakeLists.txt | ||
+++ git/CMakeLists.txt | ||
@@ -60,9 +60,12 @@ add_custom_target(install_${PROJECT_NAME | ||
# add cmake custom module directory | ||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) | ||
|
||
+include_directories (${CMAKE_BINARY_DIR}) | ||
+ | ||
find_package(ZLIB REQUIRED) | ||
find_package(Threads REQUIRED) | ||
find_package(Cppsdk REQUIRED COMPONENTS generics) | ||
+find_package(ExecInfo) | ||
|
||
# include staging directory. | ||
if (CMAKE_CROSSCOMPILING) | ||
Index: git/WebBridge/CMakeLists.txt | ||
=================================================================== | ||
--- git.orig/WebBridge/CMakeLists.txt | ||
+++ git/WebBridge/CMakeLists.txt | ||
@@ -18,11 +18,15 @@ set(WEBBRIDGE_POLICY 0 CACHE STRING "NA" | ||
set(WEBBRIDGE_OOMADJUST 0 CACHE STRING "Adapt the OOM score [-15 - 15]") | ||
set(WEBBRIDGE_STACKSIZE 0 CACHE STRING "Default stack size per thread") | ||
|
||
- | ||
set(WEBBRIDGE_WEBBRIDGE_LIBS | ||
webbridgesupport | ||
${LIBGENERICS_LIBRARIES} | ||
) | ||
+ | ||
+if (EXECINFO_LIBRARY) | ||
+ list(APPEND WEBBRIDGE_WEBBRIDGE_LIBS ${EXECINFO_LIBRARY}) | ||
+endif () | ||
+ | ||
set(WEBBRIDGE_WEBBRIDGE_SOURCES | ||
WebBridge.cpp | ||
Controller.cpp | ||
Index: git/WebBridge/WebBridge.cpp | ||
=================================================================== | ||
--- git.orig/WebBridge/WebBridge.cpp | ||
+++ git/WebBridge/WebBridge.cpp | ||
@@ -1,9 +1,14 @@ | ||
#include "WebBridgePluginServer.h" | ||
+#include "config.h" | ||
|
||
#ifndef __WIN32__ | ||
#include <syslog.h> | ||
#endif | ||
|
||
+#if defined(__linux__) && defined(HAVE_EXECINFO_H) | ||
+#include <execinfo.h> | ||
+#endif | ||
+ | ||
MODULE_NAME_DECLARATION(BUILDREF_WEBBRIDGE) | ||
|
||
#define MAX_EXTERNAL_WAITS 2000 /* Wait for 2 Seconds */ | ||
Index: git/cmake/FindExecInfo.cmake | ||
=================================================================== | ||
--- /dev/null | ||
+++ git/cmake/FindExecInfo.cmake | ||
@@ -0,0 +1,10 @@ | ||
+include (CheckIncludeFiles) | ||
+find_library (EXECINFO_LIBRARY NAMES execinfo) | ||
+ | ||
+CHECK_INCLUDE_FILE (execinfo.h HAVE_EXECINFO_H) | ||
+ | ||
+configure_file( | ||
+ "${CMAKE_SOURCE_DIR}/config.h.in" | ||
+ "${CMAKE_BINARY_DIR}/config.h" | ||
+ @ONLY) | ||
+ | ||
Index: git/config.h.in | ||
=================================================================== | ||
--- /dev/null | ||
+++ git/config.h.in | ||
@@ -0,0 +1 @@ | ||
+#cmakedefine HAVE_EXECINFO_H 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters