Files
clang-p2996/lldb/source/Symbol/SaveCoreOptions.cpp
Jacob Lalonde 4120570dc4 [LLDB][SaveCore] Add SBSaveCoreOptions Object, and SBProcess::SaveCore() overload (#98403)
This PR adds `SBSaveCoreOptions`, which is a container class for options
when LLDB is taking coredumps. For this first iteration this container
just keeps parity with the extant API of `file, style, plugin`. In the
future this options object can be extended to allow users to take a
subset of their core dumps.
2024-07-18 17:10:15 -07:00

54 lines
1.4 KiB
C++

//===-- SaveCoreOptions.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Symbol/SaveCoreOptions.h"
#include "lldb/Core/PluginManager.h"
using namespace lldb;
using namespace lldb_private;
Status SaveCoreOptions::SetPluginName(const char *name) {
Status error;
if (!name || !name[0]) {
m_plugin_name = std::nullopt;
return error;
}
if (!PluginManager::IsRegisteredObjectFilePluginName(name)) {
error.SetErrorStringWithFormat(
"plugin name '%s' is not a valid ObjectFile plugin name", name);
return error;
}
m_plugin_name = name;
return error;
}
void SaveCoreOptions::SetStyle(lldb::SaveCoreStyle style) { m_style = style; }
void SaveCoreOptions::SetOutputFile(FileSpec file) { m_file = file; }
std::optional<std::string> SaveCoreOptions::GetPluginName() const {
return m_plugin_name;
}
lldb::SaveCoreStyle SaveCoreOptions::GetStyle() const {
return m_style.value_or(lldb::eSaveCoreUnspecified);
}
const std::optional<lldb_private::FileSpec>
SaveCoreOptions::GetOutputFile() const {
return m_file;
}
void SaveCoreOptions::Clear() {
m_file = std::nullopt;
m_plugin_name = std::nullopt;
m_style = std::nullopt;
}