xref: /src/contrib/llvm-project/lldb/source/Symbol/SaveCoreOptions.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1ac9a064cSDimitry Andric //===-- SaveCoreOptions.cpp -------------------------------------*- C++ -*-===//
2ac9a064cSDimitry Andric //
3ac9a064cSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4ac9a064cSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5ac9a064cSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6ac9a064cSDimitry Andric //
7ac9a064cSDimitry Andric //===----------------------------------------------------------------------===//
8ac9a064cSDimitry Andric 
9ac9a064cSDimitry Andric #include "lldb/Symbol/SaveCoreOptions.h"
10ac9a064cSDimitry Andric #include "lldb/Core/PluginManager.h"
11ac9a064cSDimitry Andric 
12ac9a064cSDimitry Andric using namespace lldb;
13ac9a064cSDimitry Andric using namespace lldb_private;
14ac9a064cSDimitry Andric 
SetPluginName(const char * name)15ac9a064cSDimitry Andric Status SaveCoreOptions::SetPluginName(const char *name) {
16ac9a064cSDimitry Andric   Status error;
17ac9a064cSDimitry Andric   if (!name || !name[0]) {
18ac9a064cSDimitry Andric     m_plugin_name = std::nullopt;
19ac9a064cSDimitry Andric     return error;
20ac9a064cSDimitry Andric   }
21ac9a064cSDimitry Andric 
22ac9a064cSDimitry Andric   if (!PluginManager::IsRegisteredObjectFilePluginName(name)) {
23ac9a064cSDimitry Andric     error.SetErrorStringWithFormat(
24ac9a064cSDimitry Andric         "plugin name '%s' is not a valid ObjectFile plugin name", name);
25ac9a064cSDimitry Andric     return error;
26ac9a064cSDimitry Andric   }
27ac9a064cSDimitry Andric 
28ac9a064cSDimitry Andric   m_plugin_name = name;
29ac9a064cSDimitry Andric   return error;
30ac9a064cSDimitry Andric }
31ac9a064cSDimitry Andric 
SetStyle(lldb::SaveCoreStyle style)32ac9a064cSDimitry Andric void SaveCoreOptions::SetStyle(lldb::SaveCoreStyle style) { m_style = style; }
33ac9a064cSDimitry Andric 
SetOutputFile(FileSpec file)34ac9a064cSDimitry Andric void SaveCoreOptions::SetOutputFile(FileSpec file) { m_file = file; }
35ac9a064cSDimitry Andric 
GetPluginName() const36ac9a064cSDimitry Andric std::optional<std::string> SaveCoreOptions::GetPluginName() const {
37ac9a064cSDimitry Andric   return m_plugin_name;
38ac9a064cSDimitry Andric }
39ac9a064cSDimitry Andric 
GetStyle() const40ac9a064cSDimitry Andric lldb::SaveCoreStyle SaveCoreOptions::GetStyle() const {
41ac9a064cSDimitry Andric   return m_style.value_or(lldb::eSaveCoreUnspecified);
42ac9a064cSDimitry Andric }
43ac9a064cSDimitry Andric 
44ac9a064cSDimitry Andric const std::optional<lldb_private::FileSpec>
GetOutputFile() const45ac9a064cSDimitry Andric SaveCoreOptions::GetOutputFile() const {
46ac9a064cSDimitry Andric   return m_file;
47ac9a064cSDimitry Andric }
48ac9a064cSDimitry Andric 
Clear()49ac9a064cSDimitry Andric void SaveCoreOptions::Clear() {
50ac9a064cSDimitry Andric   m_file = std::nullopt;
51ac9a064cSDimitry Andric   m_plugin_name = std::nullopt;
52ac9a064cSDimitry Andric   m_style = std::nullopt;
53ac9a064cSDimitry Andric }
54