[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:51:01 PDT 2024


================
@@ -0,0 +1,86 @@
+//===-- 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/API/SBError.h"
+#include "lldb/API/SBFileSpec.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Symbol/CoreDumpOptions.h"
+#include "lldb/Utility/Instrumentation.h"
+
+#include "Utils.h"
+
+using namespace lldb;
+
+SBCoreDumpOptions::SBCoreDumpOptions() {
+  LLDB_INSTRUMENT_VA(this)
+
+  m_opaque_up = std::make_unique<lldb_private::CoreDumpOptions>();
+}
+
+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;
+}
+
+SBError SBCoreDumpOptions::SetPluginName(const char *name) {
+  LLDB_INSTRUMENT_VA(this, name);
+  lldb_private::Status error = m_opaque_up->SetPluginName(name);
+  return SBError(error);
+}
+
+void SBCoreDumpOptions::SetStyle(lldb::SaveCoreStyle style) {
+  LLDB_INSTRUMENT_VA(this, style);
+  m_opaque_up->SetStyle(style);
+}
+
+void SBCoreDumpOptions::SetOutputFile(lldb::SBFileSpec file_spec) {
+  LLDB_INSTRUMENT_VA(this, file_spec);
+  m_opaque_up->SetOutputFile(file_spec.ref());
+}
+
+const char *SBCoreDumpOptions::GetPluginName() const {
+  LLDB_INSTRUMENT_VA(this);
+  const auto name = m_opaque_up->GetPluginName();
+  if (!name)
+    return nullptr;
+  return lldb_private::ConstString(name.value()).GetCString();
+}
+
+SBFileSpec SBCoreDumpOptions::GetOutputFile() const {
+  LLDB_INSTRUMENT_VA(this);
+  const auto file_spec = m_opaque_up->GetOutputFile();
+  if (file_spec)
+    return SBFileSpec(file_spec.value());
+  return SBFileSpec();
+}
+
+lldb::SaveCoreStyle SBCoreDumpOptions::GetStyle() const {
+  LLDB_INSTRUMENT_VA(this);
+  return m_opaque_up->GetStyle();
+}
+
+lldb_private::CoreDumpOptions &SBCoreDumpOptions::ref() const {
+  LLDB_INSTRUMENT_VA(this);
----------------
clayborg wrote:

This is an internal API we don't need to log... Anything private or protected doesn't need to be instrumented.

https://github.com/llvm/llvm-project/pull/98403


More information about the lldb-commits mailing list