Add a cmake option
This commit is contained in:
parent
80f0898740
commit
d87791329f
@ -64,6 +64,7 @@ include(cmake/bundle_static.cmake)
|
|||||||
# compatability.
|
# compatability.
|
||||||
option(BUILD_SHARED_LIBS "Build shared instead of static library" ${PROJECT_IS_TOP_LEVEL})
|
option(BUILD_SHARED_LIBS "Build shared instead of static library" ${PROJECT_IS_TOP_LEVEL})
|
||||||
option(UNICORN_FUZZ "Enable fuzzing" OFF)
|
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_BUILD_TESTS "Build unicorn tests" ${PROJECT_IS_TOP_LEVEL})
|
||||||
option(UNICORN_INSTALL "Enable unicorn installation" ${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")
|
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/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
|
# Some distributions on some rare architecures don't auto link atomic for us and
|
||||||
# we do this manually by adding flags.
|
# we do this manually by adding flags.
|
||||||
set(ATOMIC_LINKAGE_FIX FALSE)
|
set(ATOMIC_LINKAGE_FIX FALSE)
|
||||||
|
@ -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.
|
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.
|
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.
|
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.
|
To control the log level information, two environment variables could be used.
|
||||||
|
@ -31,15 +31,16 @@
|
|||||||
/* Logging functions: */
|
/* Logging functions: */
|
||||||
|
|
||||||
/* To verbose logging, enable the next line. */
|
/* 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 <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the @p env_name and tries to parse the value into an uint32_t.
|
* 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;
|
return false;
|
||||||
}
|
}
|
||||||
#endif /* LOGGING_ENABLED */
|
#endif /* UNICORN_LOGGING */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs only if the right log level is set.
|
* Logs only if the right log level is set.
|
||||||
|
Loading…
Reference in New Issue
Block a user