Skip to content

Commit d877913

Browse files
committedSep 21, 2024··
Add a cmake option
1 parent 80f0898 commit d877913

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed
 

‎CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ include(cmake/bundle_static.cmake)
6464
# compatability.
6565
option(BUILD_SHARED_LIBS "Build shared instead of static library" ${PROJECT_IS_TOP_LEVEL})
6666
option(UNICORN_FUZZ "Enable fuzzing" OFF)
67+
option(UNICORN_LOGGING "Enable logging" OFF)
6768
option(UNICORN_BUILD_TESTS "Build unicorn tests" ${PROJECT_IS_TOP_LEVEL})
6869
option(UNICORN_INSTALL "Enable unicorn installation" ${PROJECT_IS_TOP_LEVEL})
6970
set(UNICORN_ARCH "x86;arm;aarch64;riscv;mips;sparc;m68k;ppc;s390x;tricore" CACHE STRING "Enabled unicorn architectures")
@@ -92,6 +93,11 @@ include_directories(
9293
qemu/tcg
9394
)
9495

96+
# QEMU logging facility
97+
if (UNICORN_LOGGING)
98+
add_compile_options(-DUNICORN_LOGGING)
99+
endif()
100+
95101
# Some distributions on some rare architecures don't auto link atomic for us and
96102
# we do this manually by adding flags.
97103
set(ATOMIC_LINKAGE_FIX FALSE)

‎docs/FAQ.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ However, the qemu logs are partially commented-out and incomplete, but give it a
134134
You might want to dig deeper - and add your own log messages where you expect or try to find the bug.
135135

136136
See the `unicorn/qemu/include/qemu/log.h` file for details.
137-
To enable logs, you must recompile Unicorn with the enabled `LOGGING_ENABLED` define.
137+
To enable logs, you must recompile Unicorn with the enabled `UNICORN_LOGGING` define.
138138

139139
Logs are written in different log levels, which might result into a very verbose logging if enabled.
140140
To control the log level information, two environment variables could be used.

‎qemu/include/qemu/log.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@
3131
/* Logging functions: */
3232

3333
/* To verbose logging, enable the next line. */
34-
//#define LOGGING_ENABLED // to enable logging
34+
//#define UNICORN_LOGGING // to enable logging
3535

36-
#ifdef LOGGING_ENABLED
36+
#ifdef UNICORN_LOGGING
3737

3838
#include <stdint.h>
3939
#include <string.h>
4040
#include <stdlib.h>
4141
#include <stdarg.h>
4242
#include <stdio.h>
43+
#include <stdbool.h>
4344

4445
/**
4546
* 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)
222223

223224
return false;
224225
}
225-
#endif /* LOGGING_ENABLED */
226+
#endif /* UNICORN_LOGGING */
226227

227228
/**
228229
* Logs only if the right log level is set.

0 commit comments

Comments
 (0)
Please sign in to comment.