Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / tools / lldb-fuzzer / lldb-target-fuzzer / lldb-target-fuzzer.cpp
blobb7103789f5a570c4a4c13c34a92b547a46850e35
1 //===-- lldb-target-fuzzer.cpp - Fuzz target creation ---------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "utils/TempFile.h"
11 #include "lldb/API/SBDebugger.h"
12 #include "lldb/API/SBTarget.h"
14 using namespace lldb;
15 using namespace lldb_fuzzer;
16 using namespace llvm;
18 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
19 SBDebugger::Initialize();
20 return 0;
23 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
24 std::unique_ptr<TempFile> file = TempFile::Create(data, size);
25 if (!file)
26 return 1;
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();
34 return 0;