summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lipka <clipka@jp.adit-jv.com>2017-02-02 15:04:24 +0900
committerChristoph Lipka <clipka@jp.adit-jv.com>2017-02-02 15:04:24 +0900
commitfc91110918e948b006fdd18d9851a95c00fc95c3 (patch)
tree7d396bfaf8516cb69b2eeec37338c59d40eb9363
parenta961dba0013ed2119aa719546c63212459753549 (diff)
downloadDLT-daemon-fc91110918e948b006fdd18d9851a95c00fc95c3.tar.gz
CMake Option: Trigger segmentation fault in case of FATAL log
When the user library receives a log with log level DLT_LOG_FATAL it triggers a segmentation fault to provide information to the developer via tools like coredump. Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
-rw-r--r--CMakeLists.txt6
-rw-r--r--src/lib/dlt_user.c14
2 files changed, 20 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f97e491..f05d566 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -79,6 +79,8 @@ option(WITH_DLT_LOGSTORAGE_CTRL_UDEV "PROTOTYPE! Set to ON to build logstorage c
option(WITH_DLT_LOGSTORAGE_CTRL_PROP "PROTOTYPE! Set to ON to build logstorage control application with proprietary support" OFF)
option(WITH_DLT_USE_IPv6 "Set to ON for IPv6 support" ON)
option(WITH_DLT_KPI "Set to ON to build src/kpi binaries" ON)
+option(WITH_DLT_FATAL_LOG_TRAP "Set to ON to enable DLT_LOG_FATAL trap (trigger segv inside dlt-user library)" OFF)
+
# RPM settings
set( GENIVI_RPM_RELEASE "1")#${DLT_REVISION}")
set( LICENSE "Mozilla Public License Version 2.0" )
@@ -194,6 +196,10 @@ if(WITH_DLT_LOGSTORAGE_CTRL_PROP)
add_definitions( -DDLT_LOGSTORAGE_CTRL_PROP)
endif(WITH_DLT_LOGSTORAGE_CTRL_PROP)
+if (WITH_DLT_FATAL_LOG_TRAP)
+ add_definitions( -DDLT_FATAL_LOG_RESET_ENABLE)
+endif(WITH_DLT_FATAL_LOG_TRAP)
+
add_subdirectory( doc )
add_subdirectory( src )
add_subdirectory( include )
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
index 0b00070..713bea3 100644
--- a/src/lib/dlt_user.c
+++ b/src/lib/dlt_user.c
@@ -63,6 +63,18 @@
#include "dlt_user_shared_cfg.h"
#include "dlt_user_cfg.h"
+#ifdef DLT_FATAL_LOG_RESET_ENABLE
+#define DLT_LOG_FATAL_RESET_TRAP(LOGLEVEL) \
+ do { \
+ if (LOGLEVEL == DLT_LOG_FATAL) { \
+ int *p = NULL; \
+ *p = 0; \
+ } \
+ } while(0)
+#else /* DLT_FATAL_LOG_RESET_ENABLE */
+#define DLT_LOG_FATAL_RESET_TRAP(LOGLEVEL)
+#endif /* DLT_FATAL_LOG_RESET_ENABLE */
+
static DltUser dlt_user;
static bool dlt_user_initialised = false;
static int dlt_user_freeing = 0;
@@ -1420,6 +1432,8 @@ inline DltReturnValue dlt_user_log_write_start(DltContext *handle, DltContextDat
DltReturnValue dlt_user_log_write_start_id(DltContext *handle, DltContextData *log, DltLogLevelType loglevel, uint32_t messageid)
{
+ DLT_LOG_FATAL_RESET_TRAP(loglevel);
+
// check nullpointer
if (handle == NULL || log == NULL)
return DLT_RETURN_WRONG_PARAMETER;