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