1 //===-- lldb-target-fuzzer.cpp - Fuzz target creation ---------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "utils/TempFile.h"
11 #include "lldb/API/SBDebugger.h"
12 #include "lldb/API/SBTarget.h"
15 using namespace lldb_fuzzer
;
18 extern "C" int LLVMFuzzerInitialize(int *argc
, char ***argv
) {
19 SBDebugger::Initialize();
23 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data
, size_t size
) {
24 std::unique_ptr
<TempFile
> file
= TempFile::Create(data
, size
);
28 SBDebugger debugger
= SBDebugger::Create(false);
29 SBTarget target
= debugger
.CreateTarget(file
->GetPath().data());
30 debugger
.DeleteTarget(target
);
31 SBDebugger::Destroy(debugger
);
32 SBModule::GarbageCollectAllocatedModules();