================
@@ -0,0 +1,67 @@
+//===-- SBCoreDumpOptions.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/API/SBCoreDumpOptions.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Symbol/CoreDumpOptions.h"
+#include "lldb/Utility/Instrumentation.h"
+
+#include "Utils.h"
+
+using namespace lldb;
+
+SBCoreDumpOptions::SBCoreDumpOptions(const char *filePath) {
+  LLDB_INSTRUMENT_VA(this, filePath);
+  lldb_private::FileSpec fspec(filePath);
+  lldb_private::FileSystem::Instance().Resolve(fspec);
+  m_opaque_up = std::make_unique<lldb_private::CoreDumpOptions>(fspec);
+}
+
+SBCoreDumpOptions::SBCoreDumpOptions(const SBCoreDumpOptions &rhs) {
+  LLDB_INSTRUMENT_VA(this, rhs);
+
+  m_opaque_up = clone(rhs.m_opaque_up);
+}
+
+const SBCoreDumpOptions &
+SBCoreDumpOptions::operator=(const SBCoreDumpOptions &rhs) {
+  LLDB_INSTRUMENT_VA(this, rhs);
+
+  if (this != &rhs)
+    m_opaque_up = clone(rhs.m_opaque_up);
+  return *this;
+}
+
+void SBCoreDumpOptions::SetCoreDumpPluginName(const char *name) {
+  m_opaque_up->SetCoreDumpPluginName(name);
+}
+
+void SBCoreDumpOptions::SetCoreDumpStyle(lldb::SaveCoreStyle style) {
+  m_opaque_up->SetCoreDumpStyle(style);
+}
+
+const std::optional<const char *>
+SBCoreDumpOptions::GetCoreDumpPluginName() const {
+  const auto &name = m_opaque_up->GetCoreDumpPluginName();
+  if (name->empty())
+    return std::nullopt;
+  return name->data();
+}
+
+const char *SBCoreDumpOptions::GetOutputFile() const {
+  return m_opaque_up->GetOutputFile().GetFilename().AsCString();
+}
----------------
clayborg wrote:

Return a SBFileSpec object here. Also remove the "const" as it doesn't mean 
anything because it just means you can't change the `m_opaque_up` value, but it 
will still allow you to call a non const function on the pointer contained in 
`m_opaque_up`... You will need to add the `SBCoreDumpOptions` as friend class 
in SBFileSpec.h so that you can call the constructor that uses a 
`lldb_private::FileSpec`. Then this code becomes:
```
lldb::SBFileSpec SBCoreDumpOptions::GetOutputFile() {
  return lldb::SBFileSpec(m_opaque_up->GetOutputFile());
}
```

https://github.com/llvm/llvm-project/pull/98403
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to