xref: /freebsd/contrib/llvm-project/lldb/source/Target/TraceExporter.cpp (revision fe6060f10f634930ff71b7c50291ddc610da2475)
1*fe6060f1SDimitry Andric //===-- TraceExporter.cpp -------------------------------------------------===//
2*fe6060f1SDimitry Andric //
3*fe6060f1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*fe6060f1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*fe6060f1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*fe6060f1SDimitry Andric //
7*fe6060f1SDimitry Andric //===----------------------------------------------------------------------===//
8*fe6060f1SDimitry Andric 
9*fe6060f1SDimitry Andric #include "lldb/Target/TraceExporter.h"
10*fe6060f1SDimitry Andric 
11*fe6060f1SDimitry Andric #include "lldb/Core/PluginManager.h"
12*fe6060f1SDimitry Andric 
13*fe6060f1SDimitry Andric using namespace lldb;
14*fe6060f1SDimitry Andric using namespace lldb_private;
15*fe6060f1SDimitry Andric using namespace llvm;
16*fe6060f1SDimitry Andric 
17*fe6060f1SDimitry Andric static Error createInvalidPlugInError(StringRef plugin_name) {
18*fe6060f1SDimitry Andric   return createStringError(
19*fe6060f1SDimitry Andric       std::errc::invalid_argument,
20*fe6060f1SDimitry Andric       "no trace expoter plug-in matches the specified type: \"%s\"",
21*fe6060f1SDimitry Andric       plugin_name.data());
22*fe6060f1SDimitry Andric }
23*fe6060f1SDimitry Andric 
24*fe6060f1SDimitry Andric Expected<lldb::TraceExporterUP>
25*fe6060f1SDimitry Andric TraceExporter::FindPlugin(llvm::StringRef plugin_name) {
26*fe6060f1SDimitry Andric   ConstString name(plugin_name);
27*fe6060f1SDimitry Andric   if (auto create_callback =
28*fe6060f1SDimitry Andric           PluginManager::GetTraceExporterCreateCallback(name))
29*fe6060f1SDimitry Andric     return create_callback();
30*fe6060f1SDimitry Andric 
31*fe6060f1SDimitry Andric   return createInvalidPlugInError(plugin_name);
32*fe6060f1SDimitry Andric }
33