1 if(CLANG_ENABLE_PROTO_FUZZER)
2 set(LLVM_LINK_COMPONENTS
6 add_llvm_fuzzer(lldb-expression-fuzzer
8 lldb-expression-fuzzer.cpp
11 if(TARGET lldb-expression-fuzzer)
12 target_include_directories(lldb-expression-fuzzer PRIVATE ..)
13 find_package(Protobuf REQUIRED)
14 add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
15 include_directories(${PROTOBUF_INCLUDE_DIRS})
16 include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../../clang/tools/clang-fuzzer PRIVATE ..)
17 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/tools/clang-fuzzer)
19 set(CLANG_CMAKE_MODULE_PATH
20 ${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/cmake/modules)
24 ${CLANG_CMAKE_MODULE_PATH})
27 set (PBM_PREFIX lldb_protobuf_mutator)
28 include(ProtobufMutator)
29 include_directories(${ProtobufMutator_INCLUDE_DIRS})
31 target_link_libraries(lldb-expression-fuzzer
33 ${ProtobufMutator_LIBRARIES}
34 ${LLVM_LIB_FUZZING_ENGINE}
41 add_custom_command(TARGET lldb-expression-fuzzer PRE_BUILD
42 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/fuzzer-artifacts/expression-artifacts
43 # Create and compile a simple C program using the command line. This is
44 # needed because LLDB's expression evaluator needs a legitmate target
45 # instead of a dummy target
46 COMMAND echo 'int main (int argc, char** argv) { return 0\; }' | clang -o main.out -xc -
49 # Create a directory for storing the fuzzer's artifacts and run the fuzzer with arguments that will
50 # not attempt to reduce the size of the inputs being generated
51 # Also set the executable that's created above as an environment variable for the
53 add_custom_target(fuzz-lldb-expression
54 COMMENT "Running the LLDB expression evaluator fuzzer..."
55 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/fuzzer-artifacts/expression-artifacts
56 COMMAND ${CMAKE_COMMAND} -E env LLDB_FUZZER_TARGET=${CMAKE_CURRENT_BINARY_DIR}/main.out $<TARGET_FILE:lldb-expression-fuzzer> -artifact_prefix=expression- -reduce_inputs=0