mirror of
https://github.com/emqx/neuron.git
synced 2026-10-17 04:40:42 +08:00
OS X support AddressSanitizer
This commit is contained in:
+3
-6
@@ -13,19 +13,16 @@ endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "$ENV{CFLAGS} -Wall -Wextra")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O2")
|
||||
if(APPLE)
|
||||
set(CMAKE_C_FLAGS_DEBUG
|
||||
"${CMAKE_C_FLAGS} -g -O0 -fsanitize=address \
|
||||
-fsanitize-recover=address -fsanitize-address-use-after-scope \
|
||||
-fno-stack-protector -fno-omit-frame-pointer -fno-var-tracking -static-libsan"
|
||||
-fno-stack-protector -fno-omit-frame-pointer -fno-var-tracking"
|
||||
)
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS_DEBUG
|
||||
"${CMAKE_C_FLAGS} -g -O0 -fsanitize=address \
|
||||
-fsanitize-recover=address -fsanitize-address-use-after-scope \
|
||||
-fno-stack-protector -fno-omit-frame-pointer -fno-var-tracking -static-libasan"
|
||||
-fno-stack-protector -fno-omit-frame-pointer -fno-var-tracking"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_SUPPRESS_DEVELOPER_WARNINGS)
|
||||
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS
|
||||
@@ -94,7 +91,7 @@ add_library(neuron-base SHARED)
|
||||
target_sources(neuron-base PRIVATE ${NEURON_BASE_SOURCES})
|
||||
target_include_directories(neuron-base
|
||||
PRIVATE ${NEURON_BASE_INCLUDE_DIRECTORIES})
|
||||
target_link_libraries(neuron-base vector-static jansson ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries(neuron-base paho-mqtt3as vector-static jansson ssl crypto ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
# define for plugins
|
||||
set(SAMPLE_PLUGIN_SOURCES plugins/plugin_sample.c)
|
||||
|
||||
+14
-7
@@ -562,10 +562,11 @@ static int manager_stop_adapter(neu_manager_t *manager, neu_adapter_t *adapter)
|
||||
// Call this function before start manager loop, so it don't need lock
|
||||
static int register_default_plugins(neu_manager_t *manager)
|
||||
{
|
||||
int rv = 0;
|
||||
uint32_t i, j;
|
||||
plugin_id_t plugin_id;
|
||||
const plugin_reg_param_t *reg_param;
|
||||
int rv = 0;
|
||||
uint32_t i, j;
|
||||
plugin_id_t plugin_id;
|
||||
plugin_reg_param_t reg_param;
|
||||
int path_len = 64;
|
||||
|
||||
for (i = 0; i < DEFAULT_PLUGIN_COUNT; i++) {
|
||||
plugin_id.id_val = 0;
|
||||
@@ -577,13 +578,19 @@ static int register_default_plugins(neu_manager_t *manager)
|
||||
}
|
||||
|
||||
if (j < SYSTEM_PLUGIN_INFO_SIZE) {
|
||||
reg_param = &system_plugin_infos[j];
|
||||
reg_param = system_plugin_infos[j];
|
||||
reg_param.plugin_lib_name = calloc(1, path_len);
|
||||
|
||||
snprintf(reg_param.plugin_lib_name, path_len, "./%s",
|
||||
system_plugin_infos[j].plugin_lib_name);
|
||||
plugin_id =
|
||||
plugin_manager_reg_plugin(manager->plugin_manager, reg_param);
|
||||
plugin_manager_reg_plugin(manager->plugin_manager, ®_param);
|
||||
if (plugin_id.id_val == 0) {
|
||||
log_warn("Failed to register plugin: %s",
|
||||
reg_param->plugin_name);
|
||||
reg_param.plugin_name);
|
||||
}
|
||||
|
||||
free(reg_param.plugin_lib_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -158,8 +158,8 @@ static void reg_entity_init(plugin_reg_entity_t * reg_entity,
|
||||
reg_entity->plugin_id = plugin_id;
|
||||
reg_entity->plugin_kind = param->plugin_kind;
|
||||
reg_entity->adapter_type = param->adapter_type;
|
||||
reg_entity->plugin_name = param->plugin_name;
|
||||
reg_entity->plugin_lib_name = param->plugin_lib_name;
|
||||
reg_entity->plugin_name = strdup(param->plugin_name);
|
||||
reg_entity->plugin_lib_name = strdup(param->plugin_lib_name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ typedef struct plugin_reg_param {
|
||||
// The buffer should be move to plugin manager, don't free it
|
||||
const char *plugin_name;
|
||||
// The buffer should be move to plugin manager, don't free it
|
||||
const char *plugin_lib_name;
|
||||
char *plugin_lib_name;
|
||||
} plugin_reg_param_t;
|
||||
|
||||
typedef struct plugin_reg_info {
|
||||
|
||||
@@ -4,7 +4,7 @@ include_directories(../../../plugins/mqtt)
|
||||
file(GLOB MQTT_SRC "../../../plugins/mqtt/*.c")
|
||||
set(src ${MQTT_SRC} paho_client_test.cc)
|
||||
add_executable(paho_client_test ${src})
|
||||
target_link_libraries(paho_client_test neuron-base paho-mqtt3as gtest gtest_main pthread)
|
||||
target_link_libraries(paho_client_test neuron-base gtest gtest_main)
|
||||
|
||||
# add_test(
|
||||
# NAME
|
||||
|
||||
Reference in New Issue
Block a user