[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 17 14:10:42 PDT 2024
================
@@ -0,0 +1,55 @@
+//===-- CoreDumpOptions.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/CoreDumpOptions.h"
+#include "lldb/Core/PluginManager.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+Status CoreDumpOptions::SetPluginName(const char *name) {
+ Status error;
+ if (!name || !name[0]) {
+ m_plugin_name = std::nullopt;
+ error.SetErrorString("no plugin name specified");
+ }
+
+ if (!PluginManager::IsRegisteredPluginName(name)) {
+ error.SetErrorStringWithFormat(
+ "plugin name '%s' is not a registered plugin", name);
+ return error;
+ }
+
+ m_plugin_name = name;
+ return error;
+}
+
+void CoreDumpOptions::SetStyle(lldb::SaveCoreStyle style) { m_style = style; }
+
+void CoreDumpOptions::SetOutputFile(FileSpec file) { m_file = file; }
+
+std::optional<std::string> CoreDumpOptions::GetPluginName() const {
+ return m_plugin_name;
+}
+
+lldb::SaveCoreStyle CoreDumpOptions::GetStyle() const {
+ if (!m_style.has_value())
+ return lldb::eSaveCoreUnspecified;
+ return m_style.value();
----------------
clayborg wrote:
These three lines can be:
```
return m_style.value_or(lldb::eSaveCoreUnspecified);
```
https://github.com/llvm/llvm-project/pull/98403
More information about the lldb-commits
mailing list