Skip to content

Commit

Permalink
Fix: debug log cannot be print when build in debug mode (#317)
Browse files Browse the repository at this point in the history
* fix: the spdlog debug is not enable on debujg mode

* fix when not spec INFO

* fix get memory size config from env
  • Loading branch information
yunwei37 authored Aug 9, 2024
1 parent b86c6a3 commit 611ff5a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ endif()

# spdlog
add_subdirectory(third_party/spdlog)
if(NOT DEFINED SPDLOG_ACTIVE_LEVEL)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG)
else()
add_compile_definitions(SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO)
endif()
endif()



set(SPDLOG_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog/include)

Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,18 @@ build-wo-libbpf: ## build the package with iouring extension

release: ## build the release version
cmake -Bbuild -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO
-DBUILD_BPFTIME_DAEMON=1
cmake --build build --config RelWithDebInfo --target install -j$(JOBS)

release-with-llvm-jit: ## build the package, with llvm-jit
cmake -Bbuild -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
-DBPFTIME_LLVM_JIT=1
-DBUILD_BPFTIME_DAEMON=1
cmake --build build --config RelWithDebInfo --target install -j$(JOBS)

release-with-static-lib: ## build the release version with libbpftime archive
cmake -Bbuild -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO -DBPFTIME_BUILD_STATIC_LIB=ON
-DBPFTIME_BUILD_STATIC_LIB=ON
cmake --build build --config RelWithDebInfo --target install -j$(JOBS)

build-vm: ## build only the core library
Expand Down
5 changes: 0 additions & 5 deletions attach/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG)
else()
add_definitions(-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO)
endif()
add_subdirectory(base_attach_impl)
add_subdirectory(frida_uprobe_attach_impl)
if(UNIX AND NOT APPLE)
Expand Down
3 changes: 2 additions & 1 deletion runtime/src/bpftime_shm_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,8 @@ bool bpftime_shm::is_exist_fake_fd(int fd) const
bpftime_shm::bpftime_shm(const char *shm_name, shm_open_type type)
: open_type(type)
{
size_t memory_size = get_agent_config().shm_memory_size;
// Get the config from env because the shared memory is not initialized
size_t memory_size = get_agent_config_from_env().shm_memory_size;
if (type == shm_open_type::SHM_OPEN_ONLY) {
SPDLOG_DEBUG("start: bpftime_shm for client setup");
// open the shm
Expand Down

0 comments on commit 611ff5a

Please sign in to comment.