xref: /freebsd/contrib/llvm-project/lldb/source/Target/TraceExporter.cpp (revision ec0ea6efa1ad229d75c394c1a9b9cac33af2b1d3)
1 //===-- TraceExporter.cpp -------------------------------------------------===//
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 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/Target/TraceExporter.h"
10 
11 #include "lldb/Core/PluginManager.h"
12 
13 using namespace lldb;
14 using namespace lldb_private;
15 using namespace llvm;
16 
17 static Error createInvalidPlugInError(StringRef plugin_name) {
18   return createStringError(
19       std::errc::invalid_argument,
20       "no trace expoter plug-in matches the specified type: \"%s\"",
21       plugin_name.data());
22 }
23 
24 Expected<lldb::TraceExporterUP>
25 TraceExporter::FindPlugin(llvm::StringRef plugin_name) {
26   ConstString name(plugin_name);
27   if (auto create_callback =
28           PluginManager::GetTraceExporterCreateCallback(name))
29     return create_callback();
30 
31   return createInvalidPlugInError(plugin_name);
32 }
33