1 //===-- SaveCoreOptions.cpp -------------------------------------*- C++ -*-===// 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/Symbol/SaveCoreOptions.h" 10 #include "lldb/Core/PluginManager.h" 11 12 using namespace lldb; 13 using namespace lldb_private; 14 15 Status SaveCoreOptions::SetPluginName(const char *name) { 16 Status error; 17 if (!name || !name[0]) { 18 m_plugin_name = std::nullopt; 19 return error; 20 } 21 22 if (!PluginManager::IsRegisteredObjectFilePluginName(name)) { 23 error.SetErrorStringWithFormat( 24 "plugin name '%s' is not a valid ObjectFile plugin name", name); 25 return error; 26 } 27 28 m_plugin_name = name; 29 return error; 30 } 31 32 void SaveCoreOptions::SetStyle(lldb::SaveCoreStyle style) { m_style = style; } 33 34 void SaveCoreOptions::SetOutputFile(FileSpec file) { m_file = file; } 35 36 std::optional<std::string> SaveCoreOptions::GetPluginName() const { 37 return m_plugin_name; 38 } 39 40 lldb::SaveCoreStyle SaveCoreOptions::GetStyle() const { 41 return m_style.value_or(lldb::eSaveCoreUnspecified); 42 } 43 44 const std::optional<lldb_private::FileSpec> 45 SaveCoreOptions::GetOutputFile() const { 46 return m_file; 47 } 48 49 void SaveCoreOptions::Clear() { 50 m_file = std::nullopt; 51 m_plugin_name = std::nullopt; 52 m_style = std::nullopt; 53 } 54