diff --git a/CMakeLists.txt b/CMakeLists.txt index 03978a86..21c5831a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,7 @@ include(cmake/bundle_static.cmake) # compatability. option(BUILD_SHARED_LIBS "Build shared instead of static library" ${PROJECT_IS_TOP_LEVEL}) option(UNICORN_FUZZ "Enable fuzzing" OFF) +option(UNICORN_LOGGING "Enable logging" OFF) option(UNICORN_BUILD_TESTS "Build unicorn tests" ${PROJECT_IS_TOP_LEVEL}) option(UNICORN_INSTALL "Enable unicorn installation" ${PROJECT_IS_TOP_LEVEL}) set(UNICORN_ARCH "x86;arm;aarch64;riscv;mips;sparc;m68k;ppc;s390x;tricore" CACHE STRING "Enabled unicorn architectures") @@ -92,6 +93,11 @@ include_directories( qemu/tcg ) +# QEMU logging facility +if (UNICORN_LOGGING) + add_compile_options(-DUNICORN_LOGGING) +endif() + # Some distributions on some rare architecures don't auto link atomic for us and # we do this manually by adding flags. set(ATOMIC_LINKAGE_FIX FALSE) diff --git a/docs/FAQ.md b/docs/FAQ.md index 835760d2..99ec7648 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -134,7 +134,7 @@ However, the qemu logs are partially commented-out and incomplete, but give it a You might want to dig deeper - and add your own log messages where you expect or try to find the bug. See the `unicorn/qemu/include/qemu/log.h` file for details. -To enable logs, you must recompile Unicorn with the enabled `LOGGING_ENABLED` define. +To enable logs, you must recompile Unicorn with the enabled `UNICORN_LOGGING` define. Logs are written in different log levels, which might result into a very verbose logging if enabled. To control the log level information, two environment variables could be used. diff --git a/qemu/include/qemu/log.h b/qemu/include/qemu/log.h index 83b65c03..10c298cb 100644 --- a/qemu/include/qemu/log.h +++ b/qemu/include/qemu/log.h @@ -31,15 +31,16 @@ /* Logging functions: */ /* To verbose logging, enable the next line. */ -//#define LOGGING_ENABLED // to enable logging +//#define UNICORN_LOGGING // to enable logging -#ifdef LOGGING_ENABLED +#ifdef UNICORN_LOGGING #include #include #include #include #include +#include /** * Reads the @p env_name and tries to parse the value into an uint32_t. @@ -222,7 +223,7 @@ static inline bool is_log_level_active(uint32_t level) return false; } -#endif /* LOGGING_ENABLED */ +#endif /* UNICORN_LOGGING */ /** * Logs only if the right log level is set.